diff --git a/.gitignore b/.gitignore index e879638f..4a2e7f36 100644 --- a/.gitignore +++ b/.gitignore @@ -167,7 +167,6 @@ GitHub.sublime-settings Session.vim # temporary .netrwhist -*~ # auto-generated tag files tags diff --git a/pom.xml b/pom.xml index 216a6295..8b50cc9f 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ com.massivecraft.massivecore MassiveCore - RELEASE + 3.3.3 system ${project.basedir}\lib\MassiveCore.jar @@ -76,12 +76,12 @@ com.sk89q.worldguard worldguard-core - RELEASE + 7.0.5 com.sk89q.worldguard worldguard-bukkit - RELEASE + 7.0.5 @@ -93,7 +93,7 @@ com.griefcraft lwc - RELEASE + 4.4.0 system ${project.basedir}\lib\LWC.jar @@ -108,7 +108,7 @@ mineverse.Aust1n46.chat VentureChat - RELEASE + 3.4.1_1.19_patch system ${project.basedir}\lib\VentureChat.jar diff --git a/src/main/java/net/knarcraft/factions/ExtractorFactionAccountId.java b/src/main/java/net/knarcraft/factions/ExtractorFactionAccountId.java index 0cee67ef..c6da33f9 100644 --- a/src/main/java/net/knarcraft/factions/ExtractorFactionAccountId.java +++ b/src/main/java/net/knarcraft/factions/ExtractorFactionAccountId.java @@ -1,14 +1,14 @@ package net.knarcraft.factions; -import net.knarcraft.factions.entity.Faction; import com.massivecraft.massivecore.util.extractor.Extractor; +import net.knarcraft.factions.entity.Faction; public class ExtractorFactionAccountId implements Extractor { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ExtractorFactionAccountId i = new ExtractorFactionAccountId(); + private static final ExtractorFactionAccountId i = new ExtractorFactionAccountId(); public static ExtractorFactionAccountId get() { return i; @@ -22,9 +22,9 @@ public class ExtractorFactionAccountId implements Extractor { public Object extract(Object o) { if (o instanceof Faction) { String factionId = ((Faction) o).getId(); - if (factionId == null) { - return null; - } + if (factionId == null) { + return null; + } return Factions.FACTION_MONEY_ACCOUNT_ID_PREFIX + factionId; } diff --git a/src/main/java/net/knarcraft/factions/Factions.java b/src/main/java/net/knarcraft/factions/Factions.java index c5e5fb3c..10448ce8 100644 --- a/src/main/java/net/knarcraft/factions/Factions.java +++ b/src/main/java/net/knarcraft/factions/Factions.java @@ -1,6 +1,10 @@ package net.knarcraft.factions; import com.google.gson.GsonBuilder; +import com.massivecraft.massivecore.MassivePlugin; +import com.massivecraft.massivecore.command.type.RegistryType; +import com.massivecraft.massivecore.store.migrator.MigratorUtil; +import com.massivecraft.massivecore.util.MUtil; import net.knarcraft.factions.adapter.BoardAdapter; import net.knarcraft.factions.adapter.BoardMapAdapter; import net.knarcraft.factions.adapter.TerritoryAccessAdapter; @@ -76,10 +80,6 @@ import net.knarcraft.factions.mixin.PowerMixin; import net.knarcraft.factions.task.TaskFlagPermCreate; import net.knarcraft.factions.task.TaskPlayerPowerUpdate; import net.knarcraft.factions.task.TaskTax; -import com.massivecraft.massivecore.MassivePlugin; -import com.massivecraft.massivecore.command.type.RegistryType; -import com.massivecraft.massivecore.store.migrator.MigratorUtil; -import com.massivecraft.massivecore.util.MUtil; import org.bukkit.ChatColor; import java.util.List; @@ -95,7 +95,7 @@ public class Factions extends MassivePlugin { public final static String ID_SAFEZONE = "safezone"; public final static String ID_WARZONE = "warzone"; - public final static String NAME_NONE_DEFAULT = ChatColor.DARK_GREEN.toString() + "Wilderness"; + public final static String NAME_NONE_DEFAULT = ChatColor.DARK_GREEN + "Wilderness"; public final static String NAME_SAFEZONE_DEFAULT = "SafeZone"; public final static String NAME_WARZONE_DEFAULT = "WarZone"; diff --git a/src/main/java/net/knarcraft/factions/FactionsIndex.java b/src/main/java/net/knarcraft/factions/FactionsIndex.java index 076cbfa8..3b1d36e1 100644 --- a/src/main/java/net/knarcraft/factions/FactionsIndex.java +++ b/src/main/java/net/knarcraft/factions/FactionsIndex.java @@ -1,10 +1,10 @@ package net.knarcraft.factions; +import com.massivecraft.massivecore.collections.MassiveSet; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.FactionColl; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.MPlayerColl; -import com.massivecraft.massivecore.collections.MassiveSet; import java.util.Collections; import java.util.Map; @@ -24,7 +24,7 @@ public class FactionsIndex { // INSTANCE // -------------------------------------------- // - private static FactionsIndex i = new FactionsIndex(); + private static final FactionsIndex i = new FactionsIndex(); public static FactionsIndex get() { return i; @@ -35,7 +35,7 @@ public class FactionsIndex { // -------------------------------------------- // private final Map mplayer2faction; - private final Map> faction2mplayers; + private final Map> faction2mPlayers; // -------------------------------------------- // // CONSTRUCT @@ -43,7 +43,7 @@ public class FactionsIndex { private FactionsIndex() { this.mplayer2faction = new WeakHashMap<>(); - this.faction2mplayers = new WeakHashMapCreativeImpl(); + this.faction2mPlayers = new WeakHashMapCreativeImpl(); } // -------------------------------------------- // @@ -51,12 +51,12 @@ public class FactionsIndex { // -------------------------------------------- // private boolean isConnected(MPlayer mplayer, Faction faction) { - if (mplayer == null) { - throw new NullPointerException("mplayer"); - } - if (faction == null) { - throw new NullPointerException("faction"); - } + if (mplayer == null) { + throw new NullPointerException("mplayer"); + } + if (faction == null) { + throw new NullPointerException("faction"); + } return mplayer.getFaction() == faction; } @@ -70,7 +70,7 @@ public class FactionsIndex { } public synchronized Set getMPlayers(Faction faction) { - return new MassiveSet<>(this.faction2mplayers.get(faction)); + return new MassiveSet<>(this.faction2mPlayers.get(faction)); } // -------------------------------------------- // @@ -78,20 +78,20 @@ public class FactionsIndex { // -------------------------------------------- // public synchronized void updateAll() { - if (!MPlayerColl.get().isActive()) { - throw new IllegalStateException("The MPlayerColl is not yet fully activated."); - } + if (!MPlayerColl.get().isActive()) { + throw new IllegalStateException("The MPlayerColl is not yet fully activated."); + } MPlayerColl.get().getAll().forEach(this::update); } public synchronized void update(MPlayer mplayer) { - if (mplayer == null) { - throw new NullPointerException("mplayer"); - } - if (!FactionColl.get().isActive()) { - throw new IllegalStateException("The FactionColl is not yet fully activated."); - } + if (mplayer == null) { + throw new NullPointerException("mplayer"); + } + if (!FactionColl.get().isActive()) { + throw new IllegalStateException("The FactionColl is not yet fully activated."); + } // TODO: This is not optimal but here we remove a player from the index when // the mplayer object is deattached. Optimally it should be removed @@ -101,7 +101,7 @@ public class FactionsIndex { if (!mplayer.attached()) { Faction factionIndexed = this.mplayer2faction.remove(mplayer); if (factionIndexed != null) { - faction2mplayers.get(factionIndexed).remove(mplayer); + faction2mPlayers.get(factionIndexed).remove(mplayer); } return; } @@ -110,19 +110,19 @@ public class FactionsIndex { Faction factionIndexed = this.getFaction(mplayer); Set factions = new MassiveSet<>(); - if (factionActual != null) { - factions.add(factionActual); - } - if (factionIndexed != null) { - factions.add(factionIndexed); - } + if (factionActual != null) { + factions.add(factionActual); + } + if (factionIndexed != null) { + factions.add(factionIndexed); + } for (Faction faction : factions) { boolean connected = this.isConnected(mplayer, faction); if (connected) { - this.faction2mplayers.get(faction).add(mplayer); + this.faction2mPlayers.get(faction).add(mplayer); } else { - this.faction2mplayers.get(faction).remove(mplayer); + this.faction2mPlayers.get(faction).remove(mplayer); } } @@ -130,9 +130,9 @@ public class FactionsIndex { } public synchronized void update(Faction faction) { - if (faction == null) { - throw new NullPointerException("faction"); - } + if (faction == null) { + throw new NullPointerException("faction"); + } this.getMPlayers(faction).forEach(this::update); } diff --git a/src/main/java/net/knarcraft/factions/Rel.java b/src/main/java/net/knarcraft/factions/Rel.java index 9047691a..3178fc5c 100644 --- a/src/main/java/net/knarcraft/factions/Rel.java +++ b/src/main/java/net/knarcraft/factions/Rel.java @@ -1,10 +1,10 @@ package net.knarcraft.factions; -import net.knarcraft.factions.entity.MConf; -import net.knarcraft.factions.entity.MPerm; import com.massivecraft.massivecore.Colorized; import com.massivecraft.massivecore.Named; import com.massivecraft.massivecore.collections.MassiveSet; +import net.knarcraft.factions.entity.MConf; +import net.knarcraft.factions.entity.MPerm; import org.bukkit.ChatColor; import java.util.Collections; diff --git a/src/main/java/net/knarcraft/factions/TerritoryAccess.java b/src/main/java/net/knarcraft/factions/TerritoryAccess.java index 9a0c09ea..87383eaa 100644 --- a/src/main/java/net/knarcraft/factions/TerritoryAccess.java +++ b/src/main/java/net/knarcraft/factions/TerritoryAccess.java @@ -1,10 +1,10 @@ package net.knarcraft.factions; +import com.massivecraft.massivecore.collections.MassiveSet; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.util.RelationUtil; -import com.massivecraft.massivecore.collections.MassiveSet; import java.util.Collection; import java.util.Collections; @@ -47,7 +47,7 @@ public class TerritoryAccess { // FIELDS: VERSION // -------------------------------------------- // - public int version = 1; + public final int version = 1; // -------------------------------------------- // // FIELDS: DELTA @@ -116,12 +116,12 @@ public class TerritoryAccess { } private TerritoryAccess(String hostFactionId, Boolean hostFactionAllowed, Collection grantedIds, String chunkName) { - if (hostFactionId == null) { - throw new NullPointerException("hostFactionId"); - } - if (grantedIds == null) { - throw new NullPointerException("grantedIds"); - } + if (hostFactionId == null) { + throw new NullPointerException("hostFactionId"); + } + if (grantedIds == null) { + throw new NullPointerException("grantedIds"); + } this.hostFactionId = hostFactionId; Set grantedIdsInner = new MassiveSet<>(); @@ -141,19 +141,19 @@ public class TerritoryAccess { // -------------------------------------------- // public static TerritoryAccess valueOf(String hostFactionId, Boolean hostFactionAllowed, Collection grantedIds, String chunkName) { - if (hostFactionId == null) { - throw new NullPointerException("hostFactionId"); - } - if (grantedIds == null) { - throw new NullPointerException("grantedIds"); - } + if (hostFactionId == null) { + throw new NullPointerException("hostFactionId"); + } + if (grantedIds == null) { + throw new NullPointerException("grantedIds"); + } return new TerritoryAccess(hostFactionId, hostFactionAllowed, grantedIds, chunkName); } public static TerritoryAccess valueOf(String hostFactionId) { - if (hostFactionId == null) { - throw new NullPointerException("hostFactionId"); - } + if (hostFactionId == null) { + throw new NullPointerException("hostFactionId"); + } return valueOf(hostFactionId, null, Collections.emptySet(), null); } @@ -166,9 +166,9 @@ public class TerritoryAccess { } public boolean isGranted(String permableId) { - if (permableId.equals(this.hostFactionId)) { - return this.isHostFactionAllowed(); - } + if (permableId.equals(this.hostFactionId)) { + return this.isHostFactionAllowed(); + } return this.getGrantedIds().contains(permableId); } @@ -183,26 +183,26 @@ public class TerritoryAccess { // -------------------------------------------- // public AccessStatus getTerritoryAccess(MPlayer mplayer) { - if (isGranted(mplayer.getId())) { - return AccessStatus.ELEVATED; - } - if (isGranted(mplayer.getRank().getId())) { - return AccessStatus.ELEVATED; - } + if (isGranted(mplayer.getId())) { + return AccessStatus.ELEVATED; + } + if (isGranted(mplayer.getRank().getId())) { + return AccessStatus.ELEVATED; + } if (this.getHostFactionId().equals(mplayer.getFaction().getId())) { - if (this.isHostFactionAllowed()) { - return AccessStatus.STANDARD; - } else { - return AccessStatus.DECREASED; - } + if (this.isHostFactionAllowed()) { + return AccessStatus.STANDARD; + } else { + return AccessStatus.DECREASED; + } + } + if (isGranted(mplayer.getFaction().getId())) { + return AccessStatus.ELEVATED; + } + if (isGranted(RelationUtil.getRelationOfThatToMe(mplayer, this.getHostFaction()).toString())) { + return AccessStatus.ELEVATED; } - if (isGranted(mplayer.getFaction().getId())) { - return AccessStatus.ELEVATED; - } - if (isGranted(RelationUtil.getRelationOfThatToMe(mplayer, this.getHostFaction()).toString())) { - return AccessStatus.ELEVATED; - } return AccessStatus.STANDARD; } diff --git a/src/main/java/net/knarcraft/factions/adapter/BoardAdapter.java b/src/main/java/net/knarcraft/factions/adapter/BoardAdapter.java index c8b77d0e..e869112b 100644 --- a/src/main/java/net/knarcraft/factions/adapter/BoardAdapter.java +++ b/src/main/java/net/knarcraft/factions/adapter/BoardAdapter.java @@ -15,7 +15,7 @@ public class BoardAdapter implements JsonDeserializer, JsonSerializer, JsonSerializer entry : jsonObject.entrySet()) { - String[] ChunkCoordParts = entry.getKey().split("[,\\s]+"); - int chunkX = Integer.parseInt(ChunkCoordParts[0]); - int chunkZ = Integer.parseInt(ChunkCoordParts[1]); + String[] chunkCoordinateParts = entry.getKey().split("[,\\s]+"); + int chunkX = Integer.parseInt(chunkCoordinateParts[0]); + int chunkZ = Integer.parseInt(chunkCoordinateParts[1]); PS chunk = PS.valueOf(chunkX, chunkZ); TerritoryAccess territoryAccess = context.deserialize(entry.getValue(), TerritoryAccess.class); diff --git a/src/main/java/net/knarcraft/factions/adapter/TerritoryAccessAdapter.java b/src/main/java/net/knarcraft/factions/adapter/TerritoryAccessAdapter.java index fa738f08..02f31078 100644 --- a/src/main/java/net/knarcraft/factions/adapter/TerritoryAccessAdapter.java +++ b/src/main/java/net/knarcraft/factions/adapter/TerritoryAccessAdapter.java @@ -10,8 +10,8 @@ import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.google.gson.reflect.TypeToken; -import net.knarcraft.factions.TerritoryAccess; import com.massivecraft.massivecore.store.migrator.MigratorUtil; +import net.knarcraft.factions.TerritoryAccess; import java.lang.reflect.Type; import java.util.Collections; @@ -34,7 +34,7 @@ public class TerritoryAccessAdapter implements JsonDeserializer // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static TerritoryAccessAdapter i = new TerritoryAccessAdapter(); + private static final TerritoryAccessAdapter i = new TerritoryAccessAdapter(); public static TerritoryAccessAdapter get() { return i; @@ -68,28 +68,28 @@ public class TerritoryAccessAdapter implements JsonDeserializer hostFactionId = element.getAsString(); element = obj.get(HOST_FACTION_ALLOWED); - if (element != null) { - hostFactionAllowed = element.getAsBoolean(); - } + if (element != null) { + hostFactionAllowed = element.getAsBoolean(); + } element = obj.get(GRANTED_IDS); - if (element != null) { - grantedIds = context.deserialize(element, SET_OF_STRING_TYPE); - } + if (element != null) { + grantedIds = context.deserialize(element, SET_OF_STRING_TYPE); + } element = obj.get(CHUNK_NAME); - if (element != null) { - chunkName = element.getAsString(); - } + if (element != null) { + chunkName = element.getAsString(); + } return TerritoryAccess.valueOf(hostFactionId, hostFactionAllowed, grantedIds, chunkName); } @Override public JsonElement serialize(TerritoryAccess src, Type typeOfSrc, JsonSerializationContext context) { - if (src == null) { - return null; - } + if (src == null) { + return null; + } // isDefault <=> simple hostFactionId string if (src.isDefault()) { diff --git a/src/main/java/net/knarcraft/factions/chat/ChatFormatter.java b/src/main/java/net/knarcraft/factions/chat/ChatFormatter.java index 5dc769f2..c2e77a29 100644 --- a/src/main/java/net/knarcraft/factions/chat/ChatFormatter.java +++ b/src/main/java/net/knarcraft/factions/chat/ChatFormatter.java @@ -9,10 +9,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** - * The ChatFormater is a system offered by factions for tag parsing. + * The ChatFormatter is a system offered by factions for tag parsing. *

* Note that every tag and modifier id must be lowercase. - * A tag with id "derp" is allowed but not with id "Derp". For that reason the tag {sender} will work but {Sender} wont. + * A tag with id "derp" is allowed but not with id "Derp". For that reason the tag {sender} will work but {Sender} won't. */ public class ChatFormatter { // -------------------------------------------- // @@ -33,23 +33,23 @@ public class ChatFormatter { // FORMAT // -------------------------------------------- // - public static String format(String msg, CommandSender sender, CommandSender recipient) { + public static String format(String message, CommandSender sender, CommandSender recipient) { // We build the return value in this string buffer - StringBuffer ret = new StringBuffer(); + StringBuilder returnValue = new StringBuilder(); // A matcher to match all the tags in the msg - Matcher matcher = pattern.matcher(msg); + Matcher matcher = pattern.matcher(message); // For each tag we find while (matcher.find()) { - // The fullmatch is something like "{sender|lp|rp}" - String fullmatch = matcher.group(0); + // The fullMatch is something like "{sender|lp|rp}" + String fullMatch = matcher.group(0); - // The submatch is something like "sender|lp|rp" - String submatch = matcher.group(1); + // The subMatch is something like "sender|lp|rp" + String subMatch = matcher.group(1); // The parts are something like ["sender", "lp", "rp"] - String[] parts = submatch.split(ESC_SEPARATOR); + String[] parts = subMatch.split(ESC_SEPARATOR); // The modifier ids are something like ["lp", "rp"] and tagId something like "sender" List modifierIds = new ArrayList<>(Arrays.asList(parts)); @@ -61,23 +61,23 @@ public class ChatFormatter { String replacement; if (tag == null) { // No change if tag wasn't found - replacement = fullmatch; + replacement = fullMatch; } else { replacement = compute(tag, modifierIds, sender, recipient); if (replacement == null) { // If a tag or modifier returns null it's the same as opting out. - replacement = fullmatch; + replacement = fullMatch; } } - matcher.appendReplacement(ret, replacement); + matcher.appendReplacement(returnValue, replacement); } // Append the rest - matcher.appendTail(ret); + matcher.appendTail(returnValue); // And finally we return the string value of the buffer we built - return ret.toString(); + return returnValue.toString(); } // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierLc.java b/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierLc.java index 69c9e772..79a7653d 100644 --- a/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierLc.java +++ b/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierLc.java @@ -12,7 +12,7 @@ public class ChatModifierLc extends ChatModifier { super("lc"); } - private static ChatModifierLc i = new ChatModifierLc(); + private static final ChatModifierLc i = new ChatModifierLc(); public static ChatModifierLc get() { return i; diff --git a/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierLp.java b/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierLp.java index f06290af..e4206da0 100644 --- a/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierLp.java +++ b/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierLp.java @@ -13,7 +13,7 @@ public class ChatModifierLp extends ChatModifier { super("lp"); } - private static ChatModifierLp i = new ChatModifierLp(); + private static final ChatModifierLp i = new ChatModifierLp(); public static ChatModifierLp get() { return i; diff --git a/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierParse.java b/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierParse.java index 64559a10..2509d8f1 100644 --- a/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierParse.java +++ b/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierParse.java @@ -1,7 +1,7 @@ package net.knarcraft.factions.chat.modifier; -import net.knarcraft.factions.chat.ChatModifier; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.chat.ChatModifier; import org.bukkit.command.CommandSender; public class ChatModifierParse extends ChatModifier { @@ -13,7 +13,7 @@ public class ChatModifierParse extends ChatModifier { super("parse"); } - private static ChatModifierParse i = new ChatModifierParse(); + private static final ChatModifierParse i = new ChatModifierParse(); public static ChatModifierParse get() { return i; diff --git a/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierRp.java b/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierRp.java index ef78ae58..d73254d6 100644 --- a/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierRp.java +++ b/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierRp.java @@ -12,7 +12,7 @@ public class ChatModifierRp extends ChatModifier { super("rp"); } - private static ChatModifierRp i = new ChatModifierRp(); + private static final ChatModifierRp i = new ChatModifierRp(); public static ChatModifierRp get() { return i; @@ -24,9 +24,9 @@ public class ChatModifierRp extends ChatModifier { @Override public String getModified(String subject, CommandSender sender, CommandSender recipient) { - if (subject.equals("")) { - return subject; - } + if (subject.equals("")) { + return subject; + } return subject + " "; } diff --git a/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierUc.java b/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierUc.java index 9c927a19..e18f5efe 100644 --- a/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierUc.java +++ b/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierUc.java @@ -12,7 +12,7 @@ public class ChatModifierUc extends ChatModifier { super("uc"); } - private static ChatModifierUc i = new ChatModifierUc(); + private static final ChatModifierUc i = new ChatModifierUc(); public static ChatModifierUc get() { return i; diff --git a/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierUcf.java b/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierUcf.java index dfe2b140..2530721c 100644 --- a/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierUcf.java +++ b/src/main/java/net/knarcraft/factions/chat/modifier/ChatModifierUcf.java @@ -1,7 +1,7 @@ package net.knarcraft.factions.chat.modifier; -import net.knarcraft.factions.chat.ChatModifier; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.chat.ChatModifier; import org.bukkit.command.CommandSender; public class ChatModifierUcf extends ChatModifier { @@ -13,7 +13,7 @@ public class ChatModifierUcf extends ChatModifier { super("ucf"); } - private static ChatModifierUcf i = new ChatModifierUcf(); + private static final ChatModifierUcf i = new ChatModifierUcf(); public static ChatModifierUcf get() { return i; diff --git a/src/main/java/net/knarcraft/factions/chat/tag/ChatTagName.java b/src/main/java/net/knarcraft/factions/chat/tag/ChatTagName.java index 2c093c83..fcf53699 100644 --- a/src/main/java/net/knarcraft/factions/chat/tag/ChatTagName.java +++ b/src/main/java/net/knarcraft/factions/chat/tag/ChatTagName.java @@ -14,7 +14,7 @@ public class ChatTagName extends ChatTag { super("factions_name"); } - private static ChatTagName i = new ChatTagName(); + private static final ChatTagName i = new ChatTagName(); public static ChatTagName get() { return i; @@ -27,13 +27,13 @@ public class ChatTagName extends ChatTag { @Override public String getReplacement(CommandSender sender, CommandSender recipient) { // Get entities - MPlayer usender = MPlayer.get(sender); + MPlayer uSender = MPlayer.get(sender); // No "force" - Faction faction = usender.getFaction(); - if (faction.isNone()) { - return ""; - } + Faction faction = uSender.getFaction(); + if (faction.isNone()) { + return ""; + } return faction.getName(); } diff --git a/src/main/java/net/knarcraft/factions/chat/tag/ChatTagNameforce.java b/src/main/java/net/knarcraft/factions/chat/tag/ChatTagNameforce.java index 8a0612a1..749c20e9 100644 --- a/src/main/java/net/knarcraft/factions/chat/tag/ChatTagNameforce.java +++ b/src/main/java/net/knarcraft/factions/chat/tag/ChatTagNameforce.java @@ -14,7 +14,7 @@ public class ChatTagNameforce extends ChatTag { super("factions_nameforce"); } - private static ChatTagNameforce i = new ChatTagNameforce(); + private static final ChatTagNameforce i = new ChatTagNameforce(); public static ChatTagNameforce get() { return i; diff --git a/src/main/java/net/knarcraft/factions/chat/tag/ChatTagRelcolor.java b/src/main/java/net/knarcraft/factions/chat/tag/ChatTagRelcolor.java index 00935d2b..148bdbb6 100644 --- a/src/main/java/net/knarcraft/factions/chat/tag/ChatTagRelcolor.java +++ b/src/main/java/net/knarcraft/factions/chat/tag/ChatTagRelcolor.java @@ -13,7 +13,7 @@ public class ChatTagRelcolor extends ChatTag { super("factions_relcolor"); } - private static ChatTagRelcolor i = new ChatTagRelcolor(); + private static final ChatTagRelcolor i = new ChatTagRelcolor(); public static ChatTagRelcolor get() { return i; @@ -26,9 +26,9 @@ public class ChatTagRelcolor extends ChatTag { @Override public String getReplacement(CommandSender sender, CommandSender recipient) { // Opt out if no recipient - if (recipient == null) { - return null; - } + if (recipient == null) { + return null; + } // Get entities MPlayer usender = MPlayer.get(sender); diff --git a/src/main/java/net/knarcraft/factions/chat/tag/ChatTagRole.java b/src/main/java/net/knarcraft/factions/chat/tag/ChatTagRole.java index 9e721146..42d9ae77 100644 --- a/src/main/java/net/knarcraft/factions/chat/tag/ChatTagRole.java +++ b/src/main/java/net/knarcraft/factions/chat/tag/ChatTagRole.java @@ -1,8 +1,8 @@ package net.knarcraft.factions.chat.tag; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.chat.ChatTag; import net.knarcraft.factions.entity.MPlayer; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.command.CommandSender; public class ChatTagRole extends ChatTag { @@ -14,7 +14,7 @@ public class ChatTagRole extends ChatTag { super("factions_role"); } - private static ChatTagRole i = new ChatTagRole(); + private static final ChatTagRole i = new ChatTagRole(); public static ChatTagRole get() { return i; diff --git a/src/main/java/net/knarcraft/factions/chat/tag/ChatTagRoleprefix.java b/src/main/java/net/knarcraft/factions/chat/tag/ChatTagRoleprefix.java index 4f7a8838..84d61a38 100644 --- a/src/main/java/net/knarcraft/factions/chat/tag/ChatTagRoleprefix.java +++ b/src/main/java/net/knarcraft/factions/chat/tag/ChatTagRoleprefix.java @@ -14,7 +14,7 @@ public class ChatTagRoleprefix extends ChatTag { super("factions_roleprefix"); } - private static ChatTagRoleprefix i = new ChatTagRoleprefix(); + private static final ChatTagRoleprefix i = new ChatTagRoleprefix(); public static ChatTagRoleprefix get() { return i; diff --git a/src/main/java/net/knarcraft/factions/chat/tag/ChatTagRoleprefixforce.java b/src/main/java/net/knarcraft/factions/chat/tag/ChatTagRoleprefixforce.java index d617d681..97cf06ae 100644 --- a/src/main/java/net/knarcraft/factions/chat/tag/ChatTagRoleprefixforce.java +++ b/src/main/java/net/knarcraft/factions/chat/tag/ChatTagRoleprefixforce.java @@ -13,7 +13,7 @@ public class ChatTagRoleprefixforce extends ChatTag { super("factions_roleprefixforce"); } - private static ChatTagRoleprefixforce i = new ChatTagRoleprefixforce(); + private static final ChatTagRoleprefixforce i = new ChatTagRoleprefixforce(); public static ChatTagRoleprefixforce get() { return i; diff --git a/src/main/java/net/knarcraft/factions/chat/tag/ChatTagTitle.java b/src/main/java/net/knarcraft/factions/chat/tag/ChatTagTitle.java index 41f66c39..cc6b9f99 100644 --- a/src/main/java/net/knarcraft/factions/chat/tag/ChatTagTitle.java +++ b/src/main/java/net/knarcraft/factions/chat/tag/ChatTagTitle.java @@ -13,7 +13,7 @@ public class ChatTagTitle extends ChatTag { super("factions_title"); } - private static ChatTagTitle i = new ChatTagTitle(); + private static final ChatTagTitle i = new ChatTagTitle(); public static ChatTagTitle get() { return i; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactions.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactions.java index ab3f5a99..a60c649f 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactions.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactions.java @@ -1,9 +1,9 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.entity.MConf; import com.massivecraft.massivecore.command.MassiveCommandDeprecated; import com.massivecraft.massivecore.command.MassiveCommandVersion; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.entity.MConf; import java.util.List; @@ -12,7 +12,7 @@ public class CmdFactions extends FactionsCommand { // INSTANCE // -------------------------------------------- // - private static CmdFactions i = new CmdFactions(); + private static final CmdFactions i = new CmdFactions(); public static CmdFactions get() { return i; @@ -28,21 +28,21 @@ public class CmdFactions extends FactionsCommand { public CmdFactionsPlayer cmdFactionsPlayer = new CmdFactionsPlayer(); public CmdFactionsStatus cmdFactionsStatus = new CmdFactionsStatus(); public CmdFactionsJoin cmdFactionsJoin = new CmdFactionsJoin(); - public CmdFactionsLeave cmdFactionsLeave = new CmdFactionsLeave(); - public CmdFactionsWarp cmdFactionsWarp = new CmdFactionsWarp(); + public final CmdFactionsLeave cmdFactionsLeave = new CmdFactionsLeave(); + public final CmdFactionsWarp cmdFactionsWarp = new CmdFactionsWarp(); public CmdFactionsHome cmdFactionsHome = new CmdFactionsHome(); public CmdFactionsSethome cmdFactionsSethome = new CmdFactionsSethome(); public CmdFactionsUnsethome cmdFactionsUnsethome = new CmdFactionsUnsethome(); - public CmdFactionsVote cmdFactionsVote = new CmdFactionsVote(); + public final CmdFactionsVote cmdFactionsVote = new CmdFactionsVote(); public CmdFactionsMap cmdFactionsMap = new CmdFactionsMap(); - public CmdFactionsCreate cmdFactionsCreate = new CmdFactionsCreate(); - public CmdFactionsName cmdFactionsName = new CmdFactionsName(); - public CmdFactionsDescription cmdFactionsDescription = new CmdFactionsDescription(); + public final CmdFactionsCreate cmdFactionsCreate = new CmdFactionsCreate(); + public final CmdFactionsName cmdFactionsName = new CmdFactionsName(); + public final CmdFactionsDescription cmdFactionsDescription = new CmdFactionsDescription(); public CmdFactionsMotd cmdFactionsMotd = new CmdFactionsMotd(); - public CmdFactionsInvite cmdFactionsInvite = new CmdFactionsInvite(); - public CmdFactionsKick cmdFactionsKick = new CmdFactionsKick(); - public CmdFactionsTitle cmdFactionsTitle = new CmdFactionsTitle(); - public CmdFactionsRank cmdFactionsRank = new CmdFactionsRank(); + public final CmdFactionsInvite cmdFactionsInvite = new CmdFactionsInvite(); + public final CmdFactionsKick cmdFactionsKick = new CmdFactionsKick(); + public final CmdFactionsTitle cmdFactionsTitle = new CmdFactionsTitle(); + public final CmdFactionsRank cmdFactionsRank = new CmdFactionsRank(); public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney(); public CmdFactionsTop cmdFactionsTop = new CmdFactionsTop(); public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk(); @@ -52,17 +52,17 @@ public class CmdFactions extends FactionsCommand { public CmdFactionsUnclaim cmdFactionsUnclaim = new CmdFactionsUnclaim(); public CmdFactionsAccess cmdFactionsAccess = new CmdFactionsAccess(); public CmdFactionsChunkname cmdFactionsChunkname = new CmdFactionsChunkname(); - public CmdFactionsRelation cmdFactionsRelation = new CmdFactionsRelation(); + public final CmdFactionsRelation cmdFactionsRelation = new CmdFactionsRelation(); public CmdFactionsRelationOld cmdFactionsRelationOldAlly = new CmdFactionsRelationOld("ally"); public CmdFactionsRelationOld cmdFactionsRelationOldTruce = new CmdFactionsRelationOld("truce"); public CmdFactionsRelationOld cmdFactionsRelationOldNeutral = new CmdFactionsRelationOld("neutral"); public CmdFactionsRelationOld cmdFactionsRelationOldEnemy = new CmdFactionsRelationOld("enemy"); public CmdFactionsTax cmdFactionsTax = new CmdFactionsTax(); - public CmdFactionsPerm cmdFactionsPerm = new CmdFactionsPerm(); - public CmdFactionsFlag cmdFactionsFlag = new CmdFactionsFlag(); + public final CmdFactionsPerm cmdFactionsPerm = new CmdFactionsPerm(); + public final CmdFactionsFlag cmdFactionsFlag = new CmdFactionsFlag(); public CmdFactionsFly cmdFactionsFly = new CmdFactionsFly(); public CmdFactionsUnstuck cmdFactionsUnstuck = new CmdFactionsUnstuck(); - public CmdFactionsOverride cmdFactionsOverride = new CmdFactionsOverride(); + public final CmdFactionsOverride cmdFactionsOverride = new CmdFactionsOverride(); public CmdFactionsDisband cmdFactionsDisband = new CmdFactionsDisband(); public CmdFactionsPowerboost cmdFactionsPowerBoost = new CmdFactionsPowerboost(); public CmdFactionsSetpower cmdFactionsSetpower = new CmdFactionsSetpower(); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessAbstract.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessAbstract.java index ecd9e5c7..31bae7a3 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessAbstract.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessAbstract.java @@ -1,13 +1,13 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.TerritoryAccess; import net.knarcraft.factions.entity.BoardColl; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.util.AsciiMap; -import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; -import com.massivecraft.massivecore.ps.PS; -import com.massivecraft.massivecore.util.Txt; import java.util.Collection; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessInspect.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessInspect.java index 636aa443..2ed862a4 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessInspect.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessInspect.java @@ -1,17 +1,17 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeFaction; -import net.knarcraft.factions.cmd.type.TypeMPermable; -import net.knarcraft.factions.entity.Board; -import net.knarcraft.factions.entity.BoardColl; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.MPerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.collections.MassiveMap; import com.massivecraft.massivecore.mixin.MixinWorld; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PSFormatHumanSpace; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.cmd.type.TypeFaction; +import net.knarcraft.factions.cmd.type.TypeMPermable; +import net.knarcraft.factions.entity.Board; +import net.knarcraft.factions.entity.BoardColl; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.MPerm; import java.util.List; import java.util.Map; @@ -44,9 +44,9 @@ public class CmdFactionsAccessInspect extends FactionsCommand { // Check if they have access perms, unless they are checking for their own access if (mpermable != msender && mpermable != msenderFaction && mpermable != msender.getRank()) { - if (!MPerm.getPermAccess().has(msender, faction, true)) { - return; - } + if (!MPerm.getPermAccess().has(msender, faction, true)) { + return; + } } // Turn into id->chunks @@ -59,9 +59,9 @@ public class CmdFactionsAccessInspect extends FactionsCommand { .filter(e -> e.getValue().isGranted(mpermable)) .map(Entry::getKey) .collect(Collectors.toSet()); - if (!chunks.isEmpty()) { - world2Chunks.put(worldId, chunks); - } + if (!chunks.isEmpty()) { + world2Chunks.put(worldId, chunks); + } } if (world2Chunks.isEmpty()) { diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetCircle.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetCircle.java index c126a6f1..2a867e82 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetCircle.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetCircle.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Perm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.ChunkUtil; +import net.knarcraft.factions.Perm; import java.util.Set; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetFill.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetFill.java index 6a69874d..0c8e731e 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetFill.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetFill.java @@ -1,14 +1,13 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Perm; -import net.knarcraft.factions.entity.BoardColl; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.MConf; -import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.ChunkUtil; +import net.knarcraft.factions.Perm; +import net.knarcraft.factions.entity.BoardColl; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.MConf; import java.util.Set; import java.util.function.Predicate; @@ -36,7 +35,7 @@ public class CmdFactionsAccessSetFill extends CmdFactionsAccessSetXSimple { // -------------------------------------------- // @Override - public Set getChunks() throws MassiveException { + public Set getChunks() { // Common Startup final PS chunk = PS.valueOf(me.getLocation()).getChunk(true); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetOne.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetOne.java index de7025df..93a9c525 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetOne.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetOne.java @@ -1,9 +1,9 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Perm; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.ps.PS; +import net.knarcraft.factions.Perm; import java.util.Collections; import java.util.Set; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetSquare.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetSquare.java index 1cd51f4c..18fd2525 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetSquare.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetSquare.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Perm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.ChunkUtil; +import net.knarcraft.factions.Perm; import java.util.Set; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetX.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetX.java index 87432100..1a99a780 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetX.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetX.java @@ -1,9 +1,9 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeMPermable; -import net.knarcraft.factions.entity.Faction; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.ps.PS; +import net.knarcraft.factions.cmd.type.TypeMPermable; +import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MPerm; import java.util.Set; @@ -52,9 +52,9 @@ public abstract class CmdFactionsAccessSetX extends CmdFactionsAccessAbstract { final MPerm.MPermable mpermable = this.getMPermable(hostFaction); final Set chunks = this.getChunks(); - if (chunks == null) { - throw new NullPointerException("chunks"); - } + if (chunks == null) { + throw new NullPointerException("chunks"); + } // Apply / Inform setAccess(chunks, mpermable, this.isGranting()); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetXRadius.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetXRadius.java index db656c76..f44f8bee 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetXRadius.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsAccessSetXRadius.java @@ -1,9 +1,9 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeMPermable; -import net.knarcraft.factions.entity.MConf; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.type.primitive.TypeInteger; +import net.knarcraft.factions.cmd.type.TypeMPermable; +import net.knarcraft.factions.entity.MConf; public abstract class CmdFactionsAccessSetXRadius extends CmdFactionsAccessSetX { diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsChunkname.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsChunkname.java index ff52bffb..5d9465e1 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsChunkname.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsChunkname.java @@ -1,9 +1,5 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.TerritoryAccess; -import net.knarcraft.factions.entity.BoardColl; -import net.knarcraft.factions.entity.MPerm; -import net.knarcraft.factions.util.AsciiMap; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.command.type.TypeNullable; @@ -11,6 +7,10 @@ import com.massivecraft.massivecore.command.type.primitive.TypeString; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.TerritoryAccess; +import net.knarcraft.factions.entity.BoardColl; +import net.knarcraft.factions.entity.MPerm; +import net.knarcraft.factions.util.AsciiMap; public class CmdFactionsChunkname extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsClean.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsClean.java index 30da8493..7e41845a 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsClean.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsClean.java @@ -1,5 +1,9 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.collections.MassiveSet; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.store.EntityInternalMap; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.Rel; import net.knarcraft.factions.TerritoryAccess; import net.knarcraft.factions.entity.Board; @@ -10,11 +14,6 @@ import net.knarcraft.factions.entity.Invitation; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.MPlayerColl; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.collections.MassiveSet; -import com.massivecraft.massivecore.ps.PS; -import com.massivecraft.massivecore.store.EntityInternalMap; -import com.massivecraft.massivecore.util.Txt; import java.util.Iterator; import java.util.Map.Entry; @@ -26,7 +25,7 @@ public class CmdFactionsClean extends FactionsCommand { // -------------------------------------------- // @Override - public void perform() throws MassiveException { + public void perform() { Object message; int count; @@ -54,9 +53,9 @@ public class CmdFactionsClean extends FactionsCommand { int ret = 0; for (MPlayer mplayer : MPlayerColl.get().getAll()) { - if (!mplayer.isFactionOrphan()) { - continue; - } + if (!mplayer.isFactionOrphan()) { + continue; + } mplayer.resetFactionData(); ret += 1; @@ -70,9 +69,9 @@ public class CmdFactionsClean extends FactionsCommand { for (Faction faction : FactionColl.get().getAll()) { EntityInternalMap invitations = faction.getInvitations(); - if (invitations.isEmpty()) { - continue; - } + if (invitations.isEmpty()) { + continue; + } ret += invitations.size(); Set invitationIds = new MassiveSet<>(invitations.keySet()); @@ -93,9 +92,9 @@ public class CmdFactionsClean extends FactionsCommand { for (Iterator> iterator = faction.getRelationWishes().entrySet().iterator(); iterator.hasNext(); ) { Entry entry = iterator.next(); String factionId = entry.getKey(); - if (FactionColl.get().containsId(factionId)) { - continue; - } + if (FactionColl.get().containsId(factionId)) { + continue; + } iterator.remove(); ret += 1; @@ -115,9 +114,9 @@ public class CmdFactionsClean extends FactionsCommand { TerritoryAccess territoryAccess = entry.getValue(); String factionId = territoryAccess.getHostFactionId(); - if (FactionColl.get().containsId(factionId)) { - continue; - } + if (FactionColl.get().containsId(factionId)) { + continue; + } board.removeAt(ps); ret += 1; @@ -137,9 +136,9 @@ public class CmdFactionsClean extends FactionsCommand { boolean changed = false; for (String grantedIds : territoryAccess.getGrantedIds()) { - if (MPerm.idToMPermableOptional(grantedIds).isPresent()) { - continue; - } + if (MPerm.idToMPermableOptional(grantedIds).isPresent()) { + continue; + } territoryAccess = territoryAccess.withGrantedId(grantedIds, false); ret += 1; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsConfig.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsConfig.java index fb1bef81..020c0f76 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsConfig.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsConfig.java @@ -1,9 +1,9 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Perm; -import net.knarcraft.factions.entity.MConf; import com.massivecraft.massivecore.command.editor.CommandEditSingleton; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; +import net.knarcraft.factions.Perm; +import net.knarcraft.factions.entity.MConf; public class CmdFactionsConfig extends CommandEditSingleton { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsCreate.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsCreate.java index f040083f..927aebab 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsCreate.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsCreate.java @@ -1,5 +1,8 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.mson.Mson; +import com.massivecraft.massivecore.store.MStore; import net.knarcraft.factions.Factions; import net.knarcraft.factions.cmd.req.ReqHasntFaction; import net.knarcraft.factions.cmd.type.TypeFactionNameStrict; @@ -8,9 +11,6 @@ import net.knarcraft.factions.entity.FactionColl; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.event.EventFactionsCreate; import net.knarcraft.factions.event.EventFactionsMembershipChange; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.mson.Mson; -import com.massivecraft.massivecore.store.MStore; import org.bukkit.ChatColor; public class CmdFactionsCreate extends FactionsCommand { @@ -44,9 +44,9 @@ public class CmdFactionsCreate extends FactionsCommand { // Event EventFactionsCreate createEvent = new EventFactionsCreate(sender, factionId, newName); createEvent.run(); - if (createEvent.isCancelled()) { - return; - } + if (createEvent.isCancelled()) { + return; + } // Apply Faction faction = FactionColl.get().create(factionId); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDescription.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDescription.java index eb3d1546..3469348c 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDescription.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDescription.java @@ -1,12 +1,12 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeString; +import com.massivecraft.massivecore.mixin.MixinDisplayName; import net.knarcraft.factions.cmd.req.ReqHasFaction; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.event.EventFactionsDescriptionChange; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.type.primitive.TypeString; -import com.massivecraft.massivecore.mixin.MixinDisplayName; public class CmdFactionsDescription extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDisband.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDisband.java index 0550dd73..579880f2 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDisband.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDisband.java @@ -1,5 +1,10 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeStringConfirmation; +import com.massivecraft.massivecore.util.ConfirmationUtil; +import com.massivecraft.massivecore.util.IdUtil; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.Factions; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.entity.Faction; @@ -10,11 +15,6 @@ import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.event.EventFactionsDisband; import net.knarcraft.factions.event.EventFactionsMembershipChange; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.type.primitive.TypeStringConfirmation; -import com.massivecraft.massivecore.util.ConfirmationUtil; -import com.massivecraft.massivecore.util.IdUtil; -import com.massivecraft.massivecore.util.Txt; public class CmdFactionsDisband extends FactionsCommand { // -------------------------------------------- // @@ -37,14 +37,14 @@ public class CmdFactionsDisband extends FactionsCommand { Faction faction = this.readArg(); String confirmationString = this.readArg(null); - if (MConf.get().requireConfirmationForFactionDisbanding) { - ConfirmationUtil.tryConfirm(this); - } + if (MConf.get().requireConfirmationForFactionDisbanding) { + ConfirmationUtil.tryConfirm(this); + } // MPerm - if (!MPerm.getPermDisband().has(msender, faction, true)) { - return; - } + if (!MPerm.getPermDisband().has(msender, faction, true)) { + return; + } // Verify if (faction.getFlag(MFlag.getFlagPermanent())) { @@ -54,9 +54,9 @@ public class CmdFactionsDisband extends FactionsCommand { // Event EventFactionsDisband event = new EventFactionsDisband(me, faction); event.run(); - if (event.isCancelled()) { - return; - } + if (event.isCancelled()) { + return; + } // Merged Apply and Inform diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationFlags.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationFlags.java index 97229b30..bbe58a82 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationFlags.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationFlags.java @@ -1,9 +1,8 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.entity.MFlag; import net.knarcraft.factions.entity.MFlagColl; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.util.Txt; import java.util.List; import java.util.stream.Collectors; @@ -22,7 +21,7 @@ public class CmdFactionsDocumentationFlags extends FactionsCommandDocumentation // -------------------------------------------- // @Override - public void perform() throws MassiveException { + public void perform() { msgDoc("Flags are a way to give certain factions certain attributes " + " such as disabling pvp or enabling friendly fire."); msgDoc("To see all the flags type:"); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationPerms.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationPerms.java index 84b6cb62..9aba66f1 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationPerms.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationPerms.java @@ -1,7 +1,5 @@ package net.knarcraft.factions.cmd; -import com.massivecraft.massivecore.MassiveException; - public class CmdFactionsDocumentationPerms extends FactionsCommandDocumentation { // -------------------------------------------- // // CONSTRUCT @@ -16,7 +14,7 @@ public class CmdFactionsDocumentationPerms extends FactionsCommandDocumentation // -------------------------------------------- // @Override - public void perform() throws MassiveException { + public void perform() { msgDoc("Permissions decide who can do what in your faction. " + "Permissions can be given to a rank, a player, a relation, " + "everyone in another faction or everyone with a specific rank in another faction."); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationPower.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationPower.java index 84006e55..8ff1058e 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationPower.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationPower.java @@ -1,7 +1,6 @@ package net.knarcraft.factions.cmd; import net.knarcraft.factions.entity.MConf; -import com.massivecraft.massivecore.MassiveException; public class CmdFactionsDocumentationPower extends FactionsCommandDocumentation { // -------------------------------------------- // @@ -17,7 +16,7 @@ public class CmdFactionsDocumentationPower extends FactionsCommandDocumentation // -------------------------------------------- // @Override - public void perform() throws MassiveException { + public void perform() { msgDoc("All players have an amount of power ranging from %.2f to %.2f.", MConf.get().powerMin, MConf.get().powerMax); msgDoc("The power of a faction is equal to the combined power of all it's members."); msgDoc("Your power is %.2f", msender.getPower()); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationRanks.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationRanks.java index cf3a297d..cc495517 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationRanks.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationRanks.java @@ -1,9 +1,8 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.entity.Rank; -import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.entity.Rank; import org.bukkit.ChatColor; import java.util.Comparator; @@ -24,7 +23,7 @@ public class CmdFactionsDocumentationRanks extends FactionsCommandDocumentation // -------------------------------------------- // @Override - public void perform() throws MassiveException { + public void perform() { msgDoc("Ranks divide the faction into groups."); List ranks = msenderFaction.getRanks().getAll(Comparator.comparingInt(Rank::getPriority).reversed()); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationTax.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationTax.java index 4f8c2f80..8e01af1c 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationTax.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationTax.java @@ -1,12 +1,11 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.req.ReqTaxEnabled; -import net.knarcraft.factions.entity.MConf; -import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.money.Money; import com.massivecraft.massivecore.util.TimeDiffUtil; import com.massivecraft.massivecore.util.TimeUnit; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.cmd.req.ReqTaxEnabled; +import net.knarcraft.factions.entity.MConf; import java.util.LinkedHashMap; @@ -24,7 +23,7 @@ public class CmdFactionsDocumentationTax extends FactionsCommandDocumentation { // -------------------------------------------- // @Override - public void perform() throws MassiveException { + public void perform() { LinkedHashMap timeUnitcounts = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(MConf.get().taxTaskPeriodMillis, TimeUnit.getAll()), 3); String periodString = TimeDiffUtil.formatedVerboose(timeUnitcounts); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationWarps.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationWarps.java index fe960907..7d7b5740 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationWarps.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsDocumentationWarps.java @@ -3,7 +3,6 @@ package net.knarcraft.factions.cmd; import net.knarcraft.factions.cmd.req.ReqFactionWarpsEnabled; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPerm; -import com.massivecraft.massivecore.MassiveException; import java.util.Set; @@ -21,7 +20,7 @@ public class CmdFactionsDocumentationWarps extends FactionsCommandDocumentation // -------------------------------------------- // @Override - public void perform() throws MassiveException { + public void perform() { msgDoc("A faction can have warps which allows it's members to easily go to important places within the faction."); if (MConf.get().warpsMax < 0) { diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFaction.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFaction.java index 6b5ac26e..5195cd99 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFaction.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFaction.java @@ -1,13 +1,13 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.cmd.type.TypeFaction; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.event.EventFactionsFactionShowAsync; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.PriorityLines; import com.massivecraft.massivecore.mixin.MixinMessage; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.cmd.type.TypeFaction; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.event.EventFactionsFactionShowAsync; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFlag.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFlag.java index 9d5802ae..497218df 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFlag.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFlag.java @@ -5,8 +5,8 @@ public class CmdFactionsFlag extends FactionsCommand { // FIELDS // -------------------------------------------- // - public CmdFactionsFlagList cmdFactionsFlagList = new CmdFactionsFlagList(); + public final CmdFactionsFlagList cmdFactionsFlagList = new CmdFactionsFlagList(); public CmdFactionsFlagShow cmdFactionsFlagShow = new CmdFactionsFlagShow(); - public CmdFactionsFlagSet cmdFactionsFlagSet = new CmdFactionsFlagSet(); + public final CmdFactionsFlagSet cmdFactionsFlagSet = new CmdFactionsFlagSet(); } diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFlagList.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFlagList.java index fb1437d0..fe55bed3 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFlagList.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFlagList.java @@ -1,13 +1,13 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.entity.MFlag; -import net.knarcraft.factions.entity.MFlagColl; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.Parameter; import com.massivecraft.massivecore.pager.Pager; import com.massivecraft.massivecore.pager.Stringifier; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.entity.MFlag; +import net.knarcraft.factions.entity.MFlagColl; +import net.knarcraft.factions.entity.MPlayer; import org.bukkit.Bukkit; import java.util.List; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFlagSet.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFlagSet.java index cf6bf7ea..4428a4a8 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFlagSet.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFlagSet.java @@ -1,13 +1,13 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.cmd.type.TypeMFlag; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MFlag; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.event.EventFactionsFlagChange; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes; public class CmdFactionsFlagSet extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFlagShow.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFlagShow.java index 22967b8c..4e3a5dd0 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFlagShow.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFlagShow.java @@ -1,13 +1,13 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeFaction; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.MFlag; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.command.Parameter; import com.massivecraft.massivecore.pager.Pager; import com.massivecraft.massivecore.pager.Stringifier; +import net.knarcraft.factions.cmd.type.TypeFaction; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.MFlag; import java.util.List; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFly.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFly.java index c5bd7d67..0fe53df1 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFly.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsFly.java @@ -1,12 +1,12 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.engine.EngineFly; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.MassiveCommandToggle; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.engine.EngineMassiveCorePlayerUpdate; import com.massivecraft.massivecore.ps.PS; +import net.knarcraft.factions.engine.EngineFly; +import net.knarcraft.factions.entity.MPlayer; import org.bukkit.entity.Player; public class CmdFactionsFly extends MassiveCommandToggle { @@ -14,7 +14,7 @@ public class CmdFactionsFly extends MassiveCommandToggle { // INSTANCE // -------------------------------------------- // - private static CmdFactionsFly i = new CmdFactionsFly(); + private static final CmdFactionsFly i = new CmdFactionsFly(); public static CmdFactionsFly get() { return i; @@ -38,21 +38,21 @@ public class CmdFactionsFly extends MassiveCommandToggle { } @Override - public boolean getValue() throws MassiveException { + public boolean getValue() { return MPlayer.get(sender).isFlying(); } public void setValue(boolean value) throws MassiveException { MPlayer mplayer = MPlayer.get(sender); Player player = me; - if (player == null) { - throw new MassiveException().addMsg("Could not find player."); - } + if (player == null) { + throw new MassiveException().addMsg("Could not find player."); + } PS ps = PS.valueOf(player); - if (value) { - EngineFly.canFlyInTerritoryOrThrow(mplayer, ps); - } + if (value) { + EngineFly.canFlyInTerritoryOrThrow(mplayer, ps); + } mplayer.setFlying(value); EngineMassiveCorePlayerUpdate.update(player, false); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsHome.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsHome.java index 2daee424..2e2d51a6 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsHome.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsHome.java @@ -1,11 +1,10 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeFaction; -import net.knarcraft.factions.entity.MConf; -import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.Visibility; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.util.MUtil; +import net.knarcraft.factions.cmd.type.TypeFaction; +import net.knarcraft.factions.entity.MConf; import java.util.List; @@ -31,7 +30,7 @@ public class CmdFactionsHome extends FactionsCommandWarp { // -------------------------------------------- // @Override - public void perform() throws MassiveException { + public void perform() { List args = MUtil.list(MConf.get().warpsHomeName, this.argAt(0)); CmdFactions.get().cmdFactionsWarp.cmdFactionsWarpGo.execute(me, args); } diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsInvite.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsInvite.java index ad287ce5..b83b9e73 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsInvite.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsInvite.java @@ -6,7 +6,7 @@ public class CmdFactionsInvite extends FactionsCommand { // -------------------------------------------- // public CmdFactionsInviteList cmdFactionsInviteList = new CmdFactionsInviteList(); - public CmdFactionsInviteAdd cmdFactionsInviteAdd = new CmdFactionsInviteAdd(); - public CmdFactionsInviteRemove cmdFactionsInviteRemove = new CmdFactionsInviteRemove(); + public final CmdFactionsInviteAdd cmdFactionsInviteAdd = new CmdFactionsInviteAdd(); + public final CmdFactionsInviteRemove cmdFactionsInviteRemove = new CmdFactionsInviteRemove(); } diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsInviteAdd.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsInviteAdd.java index 0bebb44c..38416f00 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsInviteAdd.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsInviteAdd.java @@ -1,15 +1,15 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeMPlayer; -import net.knarcraft.factions.entity.Invitation; -import net.knarcraft.factions.entity.MPerm; -import net.knarcraft.factions.entity.MPlayer; -import net.knarcraft.factions.event.EventFactionsInvitedChange; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.type.container.TypeSet; import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.cmd.type.TypeMPlayer; +import net.knarcraft.factions.entity.Invitation; +import net.knarcraft.factions.entity.MPerm; +import net.knarcraft.factions.entity.MPlayer; +import net.knarcraft.factions.event.EventFactionsInvitedChange; import org.bukkit.ChatColor; import java.util.Collection; @@ -37,9 +37,9 @@ public class CmdFactionsInviteAdd extends FactionsCommand { long creationMillis = System.currentTimeMillis(); // MPerm - if (!MPerm.getPermInvite().has(msender, msenderFaction, true)) { - return; - } + if (!MPerm.getPermInvite().has(msender, msenderFaction, true)) { + return; + } for (MPlayer mplayer : mplayers) { // Already member? @@ -55,9 +55,9 @@ public class CmdFactionsInviteAdd extends FactionsCommand { // Event EventFactionsInvitedChange event = new EventFactionsInvitedChange(sender, mplayer, msenderFaction, isInvited); event.run(); - if (event.isCancelled()) { - continue; - } + if (event.isCancelled()) { + continue; + } isInvited = event.isNewInvited(); // Inform diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsInviteList.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsInviteList.java index 594aea61..79230a30 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsInviteList.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsInviteList.java @@ -1,10 +1,5 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Perm; -import net.knarcraft.factions.cmd.type.TypeFaction; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.Invitation; -import net.knarcraft.factions.entity.MPerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.command.Parameter; @@ -15,6 +10,11 @@ import com.massivecraft.massivecore.pager.Stringifier; import com.massivecraft.massivecore.util.TimeDiffUtil; import com.massivecraft.massivecore.util.TimeUnit; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.Perm; +import net.knarcraft.factions.cmd.type.TypeFaction; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.Invitation; +import net.knarcraft.factions.entity.MPerm; import java.util.LinkedHashMap; import java.util.List; @@ -42,14 +42,14 @@ public class CmdFactionsInviteList extends FactionsCommand { Faction faction = this.readArg(msenderFaction); - if (faction != msenderFaction && !Perm.INVITE_LIST_OTHER.has(sender, true)) { - return; - } + if (faction != msenderFaction && !Perm.INVITE_LIST_OTHER.has(sender, true)) { + return; + } // MPerm - if (!MPerm.getPermInvite().has(msender, msenderFaction, true)) { - return; - } + if (!MPerm.getPermInvite().has(msender, msenderFaction, true)) { + return; + } // Pager Create final List> invitations = new MassiveList<>(faction.getInvitations().entrySet()); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsInviteRemove.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsInviteRemove.java index 1eda9229..5f25cd00 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsInviteRemove.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsInviteRemove.java @@ -1,13 +1,13 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeMPlayer; -import net.knarcraft.factions.entity.MPerm; -import net.knarcraft.factions.entity.MPlayer; -import net.knarcraft.factions.event.EventFactionsInvitedChange; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.type.container.TypeSet; import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.cmd.type.TypeMPlayer; +import net.knarcraft.factions.entity.MPerm; +import net.knarcraft.factions.entity.MPlayer; +import net.knarcraft.factions.event.EventFactionsInvitedChange; import org.bukkit.ChatColor; import java.util.ArrayList; @@ -50,9 +50,9 @@ public class CmdFactionsInviteRemove extends FactionsCommand { } // MPerm - if (!MPerm.getPermInvite().has(msender, msenderFaction, true)) { - return; - } + if (!MPerm.getPermInvite().has(msender, msenderFaction, true)) { + return; + } for (MPlayer mplayer : mplayers) { // Already member? @@ -63,7 +63,7 @@ public class CmdFactionsInviteRemove extends FactionsCommand { Mson kick = Mson.mson( mson("You might want to kick him. ").color(ChatColor.YELLOW), - mson(ChatColor.RED.toString() + tooltip).tooltip(ChatColor.YELLOW.toString() + tooltip).suggest(command) + mson(ChatColor.RED + tooltip).tooltip(ChatColor.YELLOW + tooltip).suggest(command) ); // Inform @@ -79,9 +79,9 @@ public class CmdFactionsInviteRemove extends FactionsCommand { // Event EventFactionsInvitedChange event = new EventFactionsInvitedChange(sender, mplayer, msenderFaction, isInvited); event.run(); - if (event.isCancelled()) { - continue; - } + if (event.isCancelled()) { + continue; + } isInvited = event.isNewInvited(); // Inform Player @@ -96,9 +96,9 @@ public class CmdFactionsInviteRemove extends FactionsCommand { msenderFaction.uninvite(mplayer); // If all, we do this at last. So we only do it once. - if (!all) { - msenderFaction.changed(); - } + if (!all) { + msenderFaction.changed(); + } } else { // Mson String command = CmdFactions.get().cmdFactionsInvite.cmdFactionsInviteAdd.getCommandLine(mplayer.getName()); @@ -106,7 +106,7 @@ public class CmdFactionsInviteRemove extends FactionsCommand { Mson invite = Mson.mson( mson("You might want to invite him. ").color(ChatColor.YELLOW), - mson(ChatColor.GREEN.toString() + tooltip).tooltip(ChatColor.YELLOW.toString() + tooltip).suggest(command) + mson(ChatColor.GREEN + tooltip).tooltip(ChatColor.YELLOW + tooltip).suggest(command) ); // Inform diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsJoin.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsJoin.java index 550ee076..c3909b41 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsJoin.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsJoin.java @@ -1,5 +1,8 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.mson.Mson; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.Factions; import net.knarcraft.factions.Perm; import net.knarcraft.factions.cmd.type.TypeFaction; @@ -9,9 +12,6 @@ import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MFlag; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.event.EventFactionsMembershipChange; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.mson.Mson; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; public class CmdFactionsJoin extends FactionsCommand { diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsKick.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsKick.java index 1539cce2..65234d40 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsKick.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsKick.java @@ -1,5 +1,7 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.util.IdUtil; import net.knarcraft.factions.Factions; import net.knarcraft.factions.cmd.type.TypeMPlayer; import net.knarcraft.factions.entity.Faction; @@ -8,8 +10,6 @@ import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.event.EventFactionsMembershipChange; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.util.IdUtil; import org.bukkit.ChatColor; public class CmdFactionsKick extends FactionsCommand { diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsList.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsList.java index 60831648..ad4d1d5b 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsList.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsList.java @@ -1,15 +1,15 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.comparator.ComparatorFactionList; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.FactionColl; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.Parameter; import com.massivecraft.massivecore.pager.Pager; import com.massivecraft.massivecore.pager.Stringifier; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.comparator.ComparatorFactionList; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.FactionColl; +import net.knarcraft.factions.entity.MPlayer; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMap.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMap.java index 2ffb4236..bb161da3 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMap.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMap.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.util.AsciiMap; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.util.AsciiMap; public class CmdFactionsMap extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyBalance.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyBalance.java index 7c08d9fe..50d142e0 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyBalance.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyBalance.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; import net.knarcraft.factions.Perm; import net.knarcraft.factions.cmd.req.ReqBankCommandsEnabled; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.integration.Econ; -import com.massivecraft.massivecore.MassiveException; public class CmdFactionsMoneyBalance extends FactionsCommand { // -------------------------------------------- // @@ -28,9 +28,9 @@ public class CmdFactionsMoneyBalance extends FactionsCommand { public void perform() throws MassiveException { Faction faction = this.readArg(msenderFaction); - if (faction != msenderFaction && !Perm.MONEY_BALANCE_ANY.has(sender, true)) { - return; - } + if (faction != msenderFaction && !Perm.MONEY_BALANCE_ANY.has(sender, true)) { + return; + } Econ.sendBalanceInfo(msender, faction); } diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyDeposit.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyDeposit.java index 6c75014c..fb3fec65 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyDeposit.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyDeposit.java @@ -1,15 +1,15 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeDouble; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.Factions; import net.knarcraft.factions.cmd.req.ReqBankCommandsEnabled; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.integration.Econ; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.type.primitive.TypeDouble; -import com.massivecraft.massivecore.money.Money; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; public class CmdFactionsMoneyDeposit extends FactionsCommand { diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyTransferF2f.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyTransferF2f.java index 69e3db47..a6c70b24 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyTransferF2f.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyTransferF2f.java @@ -1,15 +1,15 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeDouble; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.Factions; import net.knarcraft.factions.cmd.req.ReqBankCommandsEnabled; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.integration.Econ; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.type.primitive.TypeDouble; -import com.massivecraft.massivecore.money.Money; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; public class CmdFactionsMoneyTransferF2f extends FactionsCommand { diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyTransferF2p.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyTransferF2p.java index efd46c5e..25261293 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyTransferF2p.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyTransferF2p.java @@ -1,5 +1,9 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeDouble; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.Factions; import net.knarcraft.factions.cmd.req.ReqBankCommandsEnabled; import net.knarcraft.factions.cmd.type.TypeFaction; @@ -8,10 +12,6 @@ import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.integration.Econ; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.type.primitive.TypeDouble; -import com.massivecraft.massivecore.money.Money; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; public class CmdFactionsMoneyTransferF2p extends FactionsCommand { diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyTransferP2f.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyTransferP2f.java index f7c21d4e..db7059b5 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyTransferP2f.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyTransferP2f.java @@ -1,5 +1,9 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeDouble; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.Factions; import net.knarcraft.factions.cmd.req.ReqBankCommandsEnabled; import net.knarcraft.factions.cmd.type.TypeFaction; @@ -8,10 +12,6 @@ import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.integration.Econ; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.type.primitive.TypeDouble; -import com.massivecraft.massivecore.money.Money; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; public class CmdFactionsMoneyTransferP2f extends FactionsCommand { diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyWithdraw.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyWithdraw.java index f116aad9..2e790583 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyWithdraw.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyWithdraw.java @@ -1,5 +1,9 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeDouble; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.Factions; import net.knarcraft.factions.cmd.req.ReqBankCommandsEnabled; import net.knarcraft.factions.cmd.type.TypeFaction; @@ -7,10 +11,6 @@ import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.integration.Econ; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.type.primitive.TypeDouble; -import com.massivecraft.massivecore.money.Money; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; public class CmdFactionsMoneyWithdraw extends FactionsCommand { diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyconvert.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyconvert.java index a4e5a55e..a4c592a4 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyconvert.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMoneyconvert.java @@ -1,13 +1,13 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.FactionColl; -import net.knarcraft.factions.entity.MConf; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.Visibility; import com.massivecraft.massivecore.command.type.primitive.TypeStringConfirmation; import com.massivecraft.massivecore.money.Money; import com.massivecraft.massivecore.util.ConfirmationUtil; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.FactionColl; +import net.knarcraft.factions.entity.MConf; public class CmdFactionsMoneyconvert extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMotd.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMotd.java index 4ba82840..192fa59c 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMotd.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsMotd.java @@ -1,14 +1,14 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.entity.MPerm; -import net.knarcraft.factions.entity.MPlayer; -import net.knarcraft.factions.event.EventFactionsMotdChange; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.type.TypeNullable; import com.massivecraft.massivecore.command.type.primitive.TypeString; import com.massivecraft.massivecore.mixin.MixinDisplayName; import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.entity.MPerm; +import net.knarcraft.factions.entity.MPlayer; +import net.knarcraft.factions.event.EventFactionsMotdChange; public class CmdFactionsMotd extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsName.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsName.java index 65eb50c8..5fdaa8d6 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsName.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsName.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.cmd.type.TypeFactionNameLenient; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.event.EventFactionsNameChange; -import com.massivecraft.massivecore.MassiveException; public class CmdFactionsName extends FactionsCommand { // -------------------------------------------- // @@ -29,16 +29,16 @@ public class CmdFactionsName extends FactionsCommand { Faction faction = this.readArg(msenderFaction); // MPerm - if (!MPerm.getPermName().has(msender, faction, true)) { - return; - } + if (!MPerm.getPermName().has(msender, faction, true)) { + return; + } // Event EventFactionsNameChange event = new EventFactionsNameChange(sender, faction, newName); event.run(); - if (event.isCancelled()) { - return; - } + if (event.isCancelled()) { + return; + } newName = event.getNewName(); // Apply diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsOverride.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsOverride.java index 8e645cb5..46a99e39 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsOverride.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsOverride.java @@ -1,10 +1,10 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Factions; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes; import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.Factions; public class CmdFactionsOverride extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPerm.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPerm.java index 0c56683d..93f98a72 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPerm.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPerm.java @@ -5,10 +5,10 @@ public class CmdFactionsPerm extends FactionsCommand { // FIELDS // -------------------------------------------- // - CmdFactionsPermList cmdFactionsPermList = new CmdFactionsPermList(); - CmdFactionsPermShow cmdFactionsPermShow = new CmdFactionsPermShow(); - CmdFactionsPermView cmdFactionsPermView = new CmdFactionsPermView(); - CmdFactionsPermViewall cmdFactionsPermViewall = new CmdFactionsPermViewall(); - CmdFactionsPermSet cmdFactionsPermSet = new CmdFactionsPermSet(); + final CmdFactionsPermList cmdFactionsPermList = new CmdFactionsPermList(); + final CmdFactionsPermShow cmdFactionsPermShow = new CmdFactionsPermShow(); + final CmdFactionsPermView cmdFactionsPermView = new CmdFactionsPermView(); + final CmdFactionsPermViewall cmdFactionsPermViewall = new CmdFactionsPermViewall(); + final CmdFactionsPermSet cmdFactionsPermSet = new CmdFactionsPermSet(); } diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermList.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermList.java index a1eb15c1..7bca15f5 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermList.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermList.java @@ -1,12 +1,12 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.entity.MPerm; -import net.knarcraft.factions.entity.MPermColl; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.Parameter; import com.massivecraft.massivecore.pager.Pager; import com.massivecraft.massivecore.pager.Stringifier; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.entity.MPerm; +import net.knarcraft.factions.entity.MPermColl; import org.bukkit.Bukkit; import java.util.List; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermSet.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermSet.java index 1e305391..d4568e7e 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermSet.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermSet.java @@ -1,5 +1,8 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.cmd.type.TypeMPerm; import net.knarcraft.factions.cmd.type.TypeMPermable; @@ -7,9 +10,6 @@ import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.event.EventFactionsPermChange; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.type.primitive.TypeBooleanYes; -import com.massivecraft.massivecore.util.Txt; public class CmdFactionsPermSet extends FactionsCommand { // -------------------------------------------- // @@ -38,9 +38,9 @@ public class CmdFactionsPermSet extends FactionsCommand { MPerm.MPermable permable = TypeMPermable.get(faction).read(this.argAt(1), sender); // Do the sender have the right to change perms for this faction? - if (!MPerm.getPermPerms().has(msender, faction, true)) { - return; - } + if (!MPerm.getPermPerms().has(msender, faction, true)) { + return; + } // Is this perm editable? if (!msender.isOverriding() && !perm.isEditable()) { @@ -54,9 +54,9 @@ public class CmdFactionsPermSet extends FactionsCommand { // Event EventFactionsPermChange event = new EventFactionsPermChange(sender, faction, perm, permable, value); event.run(); - if (event.isCancelled()) { - return; - } + if (event.isCancelled()) { + return; + } value = event.getNewValue(); // Apply diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermShow.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermShow.java index 9c695aa3..ff363dc6 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermShow.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermShow.java @@ -1,13 +1,13 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.collections.MassiveList; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.cmd.type.TypeMPerm; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPlayer; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.collections.MassiveList; -import com.massivecraft.massivecore.util.Txt; import java.util.Collection; import java.util.List; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermView.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermView.java index d4f88a49..42cc0e5b 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermView.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermView.java @@ -1,16 +1,16 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.collections.MassiveList; +import com.massivecraft.massivecore.mson.Mson; +import com.massivecraft.massivecore.util.MUtil; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.cmd.type.TypeMPermable; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.Rank; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.collections.MassiveList; -import com.massivecraft.massivecore.mson.Mson; -import com.massivecraft.massivecore.util.MUtil; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; import java.util.List; @@ -45,9 +45,9 @@ public class CmdFactionsPermView extends FactionsCommand { List perms = new MassiveList<>(); for (MPerm mperm : MPerm.getAll()) { - if (faction.isPermitted(permable.getId(), mperm.getId())) { - perms.add(mperm); - } + if (faction.isPermitted(permable.getId(), mperm.getId())) { + perms.add(mperm); + } } if (perms.isEmpty()) { @@ -60,31 +60,28 @@ public class CmdFactionsPermView extends FactionsCommand { String permissionSingularPlural = permNames.size() == 1 ? "permission" : "permissions"; msg("In %s %s specifically has the %s: %s.", faction.describeTo(msender), permable.getDisplayName(sender), permissionSingularPlural, names); } - if (permable instanceof MPlayer) { - MPlayer mplayer = (MPlayer) permable; + if (permable instanceof MPlayer mplayer) { msg("They may have other permissions through their faction membership, rank or relation to %s.", faction.describeTo(msender)); List msons = new MassiveList<>(); - if (mplayer.getFaction() != faction) { - msons.add(Mson.parse("[faction]").command(this, mplayer.getFaction().getName(), faction.getName())); - } + if (mplayer.getFaction() != faction) { + msons.add(Mson.parse("[faction]").command(this, mplayer.getFaction().getName(), faction.getName())); + } msons.add(Mson.parse("[rank]").command(this, mplayer.getFaction().getName() + "-" + mplayer.getRank().getName(), faction.getName())); - if (mplayer.getFaction() != faction) { - msons.add(Mson.parse("[relation]").command(this, faction.getRelationTo(mplayer).toString(), faction.getName())); - } + if (mplayer.getFaction() != faction) { + msons.add(Mson.parse("[relation]").command(this, faction.getRelationTo(mplayer).toString(), faction.getName())); + } Mson msons2 = Mson.implode(msons, Mson.SPACE); message(mson(mson("Commands: ").color(ChatColor.YELLOW), msons2)); } - if (permable instanceof Faction) { - Faction faction1 = (Faction) permable; + if (permable instanceof Faction faction1) { msg("They may have other permissions through their relation to %s.", faction.describeTo(msender)); Mson msonRelation = Mson.parse("[relation]").command(this, faction.getRelationTo(faction1).toString(), faction.getName()); Mson msons = Mson.implode(MUtil.list(msonRelation), Mson.SPACE); message(mson(mson("Commands: ").color(ChatColor.YELLOW), msons)); } - if (permable instanceof Rank && !faction.hasRank((Rank) permable)) { - Rank rank = (Rank) permable; + if (permable instanceof Rank rank && !faction.hasRank((Rank) permable)) { msg("They may have other permissions thorugh their faction membership or relation to %s.", faction.describeTo(msender)); Mson msonFaction = Mson.parse("[faction]").command(this, rank.getFaction().getName(), faction.getName()); Mson msonRelation = Mson.parse("[relation]").command(this, faction.getRelationTo(rank.getFaction()).toString(), faction.getName()); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermViewall.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermViewall.java index aa912e16..a20fe631 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermViewall.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPermViewall.java @@ -1,14 +1,14 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.collections.MassiveList; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.cmd.type.TypeMPermable; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.Rank; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.collections.MassiveList; -import com.massivecraft.massivecore.util.Txt; import java.util.List; import java.util.stream.Collectors; @@ -44,18 +44,15 @@ public class CmdFactionsPermViewall extends FactionsCommand { List permables = new MassiveList<>(); permables.add(permable); - if (permable instanceof MPlayer) { - MPlayer mplayer = (MPlayer) permable; + if (permable instanceof MPlayer mplayer) { permables.add(mplayer.getFaction()); permables.add(mplayer.getRank()); permables.add(faction.getRelationTo(mplayer)); } - if (permable instanceof Faction) { - Faction faction1 = (Faction) permable; + if (permable instanceof Faction faction1) { permables.add(faction.getRelationTo(faction1)); } - if (permable instanceof Rank && !faction.hasRank((Rank) permable)) { - Rank rank = (Rank) permable; + if (permable instanceof Rank rank && !faction.hasRank((Rank) permable)) { Faction faction1 = rank.getFaction(); permables.add(faction1); permables.add(faction.getRelationTo(faction1)); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPlayer.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPlayer.java index 2ccc6066..39befec5 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPlayer.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPlayer.java @@ -1,14 +1,14 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeMPlayer; -import net.knarcraft.factions.entity.MConf; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.Progressbar; import com.massivecraft.massivecore.event.EventMassiveCorePlayerCleanInactivityToleranceMillis; import com.massivecraft.massivecore.util.TimeDiffUtil; import com.massivecraft.massivecore.util.TimeUnit; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.cmd.type.TypeMPlayer; +import net.knarcraft.factions.entity.MConf; +import net.knarcraft.factions.entity.MPlayer; import java.util.LinkedHashMap; import java.util.Map.Entry; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPowerboost.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPowerboost.java index 9020cdfe..56176dec 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPowerboost.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPowerboost.java @@ -5,8 +5,8 @@ public class CmdFactionsPowerboost extends FactionsCommand { // FIELDS // -------------------------------------------- // - public CmdFactionsPowerboostPlayer cmdFactionsPowerBoostPlayer = new CmdFactionsPowerboostPlayer(); - public CmdFactionsPowerboostFaction cmdFactionsPowerBoostFaction = new CmdFactionsPowerboostFaction(); + public final CmdFactionsPowerboostPlayer cmdFactionsPowerBoostPlayer = new CmdFactionsPowerboostPlayer(); + public final CmdFactionsPowerboostFaction cmdFactionsPowerBoostFaction = new CmdFactionsPowerboostFaction(); // -------------------------------------------- // // CONSTRUCT diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPowerboostAbstract.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPowerboostAbstract.java index 1c556e5c..fab065ea 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPowerboostAbstract.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsPowerboostAbstract.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.FactionsParticipator; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.type.Type; import com.massivecraft.massivecore.command.type.primitive.TypeDouble; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.FactionsParticipator; public abstract class CmdFactionsPowerboostAbstract extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRank.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRank.java index d40b6646..9c2c3aaa 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRank.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRank.java @@ -5,7 +5,7 @@ public class CmdFactionsRank extends FactionsCommand { // FIELDS // -------------------------------------------- // - public CmdFactionsRankSet cmdFactionsRankSet = new CmdFactionsRankSet(); + public final CmdFactionsRankSet cmdFactionsRankSet = new CmdFactionsRankSet(); public CmdFactionsRankShow cmdFactionsRankShow = new CmdFactionsRankShow(); public CmdFactionsRankList cmdFactionsRankList = new CmdFactionsRankList(); public CmdFactionsRankEdit cmdFactionsRankEdit = new CmdFactionsRankEdit(); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEdit.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEdit.java index 92bdd101..64c85cc5 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEdit.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEdit.java @@ -1,8 +1,8 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MPlayer; -import com.massivecraft.massivecore.MassiveException; public class CmdFactionsRankEdit extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditCreate.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditCreate.java index 0b76b10e..5465e6ba 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditCreate.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditCreate.java @@ -1,12 +1,12 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeFaction; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.Rank; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.type.primitive.TypeInteger; import com.massivecraft.massivecore.command.type.primitive.TypeString; import com.massivecraft.massivecore.command.type.primitive.TypeStringParsed; +import net.knarcraft.factions.cmd.type.TypeFaction; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.Rank; import java.util.Collection; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditDelete.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditDelete.java index 1140186b..cef2cc1c 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditDelete.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditDelete.java @@ -1,13 +1,13 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeString; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.cmd.type.TypeRank; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.Rank; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.type.primitive.TypeString; -import com.massivecraft.massivecore.util.Txt; import java.util.Collection; import java.util.List; @@ -34,7 +34,7 @@ public class CmdFactionsRankEditDelete extends FactionsCommand { Faction faction = this.readArgAt(1, msenderFaction); // Rank if any passed. - TypeRank typeRank = new TypeRank(faction); + TypeRank typeRank = TypeRank.get(faction, null); Rank rank = typeRank.read(this.argAt(0), sender); CmdFactionsRankEdit.ensureAllowed(msender, faction, "delete"); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditName.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditName.java index f5aaa5c7..05b4e4cb 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditName.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditName.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeString; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.cmd.type.TypeRank; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.Rank; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.type.primitive.TypeString; import java.util.Collection; @@ -32,7 +32,7 @@ public class CmdFactionsRankEditName extends FactionsCommand { Faction faction = this.readArgAt(2, msenderFaction); // Rank if any passed. - TypeRank typeRank = new TypeRank(faction); + TypeRank typeRank = TypeRank.get(faction, null); Rank rank = typeRank.read(this.argAt(0), sender); // Args diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditPrefix.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditPrefix.java index 2b3c42b0..cadf6cf9 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditPrefix.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditPrefix.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeString; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.cmd.type.TypeRank; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.Rank; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.type.primitive.TypeString; public class CmdFactionsRankEditPrefix extends FactionsCommand { // -------------------------------------------- // @@ -30,7 +30,7 @@ public class CmdFactionsRankEditPrefix extends FactionsCommand { Faction faction = this.readArgAt(2, msenderFaction); // Rank if any passed. - TypeRank typeRank = new TypeRank(faction); + TypeRank typeRank = TypeRank.get(faction, null); Rank rank = typeRank.read(this.argAt(0), sender); // Args diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditPriority.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditPriority.java index 4f169edb..4663de2f 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditPriority.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankEditPriority.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeInteger; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.cmd.type.TypeRank; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.Rank; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.type.primitive.TypeInteger; import java.util.Collection; @@ -32,7 +32,7 @@ public class CmdFactionsRankEditPriority extends FactionsCommand { Faction faction = this.readArgAt(2, msenderFaction); // Rank if any passed. - TypeRank typeRank = new TypeRank(faction); + TypeRank typeRank = TypeRank.get(faction, null); Rank rank = typeRank.read(this.argAt(0), sender); CmdFactionsRankEdit.ensureAllowed(msender, faction, "edit"); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankList.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankList.java index 2cdbe718..dd974069 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankList.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankList.java @@ -1,12 +1,12 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeFaction; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.Rank; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.Parameter; import com.massivecraft.massivecore.pager.Pager; import com.massivecraft.massivecore.pager.Stringifier; +import net.knarcraft.factions.cmd.type.TypeFaction; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.Rank; import java.util.Comparator; import java.util.List; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankOld.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankOld.java index 3798eb63..33f8463d 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankOld.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankOld.java @@ -1,8 +1,8 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeMPlayer; import com.massivecraft.massivecore.command.Visibility; import com.massivecraft.massivecore.util.MUtil; +import net.knarcraft.factions.cmd.type.TypeMPlayer; public class CmdFactionsRankOld extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankSet.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankSet.java index ebb71f23..6314ffa6 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankSet.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankSet.java @@ -1,5 +1,8 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.collections.MassiveSet; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.Factions; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.cmd.type.TypeMPlayer; @@ -13,9 +16,6 @@ import net.knarcraft.factions.entity.MPlayerColl; import net.knarcraft.factions.entity.Rank; import net.knarcraft.factions.event.EventFactionsMembershipChange; import net.knarcraft.factions.event.EventFactionsRankChange; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.collections.MassiveSet; -import com.massivecraft.massivecore.util.Txt; import java.util.HashSet; import java.util.Set; @@ -75,9 +75,9 @@ public class CmdFactionsRankSet extends FactionsCommand { // Event EventFactionsRankChange event = new EventFactionsRankChange(sender, target, rank); event.run(); - if (event.isCancelled()) { - return; - } + if (event.isCancelled()) { + return; + } rank = event.getNewRank(); // Change the rank. @@ -135,9 +135,9 @@ public class CmdFactionsRankSet extends FactionsCommand { private void ensureAllowed() throws MassiveException { // People with permission don't follow the normal rules. - if (msender.isOverriding()) { - return; - } + if (msender.isOverriding()) { + return; + } // If somone gets the leadership of wilderness (Which has happened before). // We can at least try to limit their powers. @@ -204,9 +204,9 @@ public class CmdFactionsRankSet extends FactionsCommand { // Event EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, msender, endFaction, EventFactionsMembershipChange.MembershipChangeReason.RANK); membershipChangeEvent.run(); - if (membershipChangeEvent.isCancelled()) { - throw new MassiveException(); - } + if (membershipChangeEvent.isCancelled()) { + throw new MassiveException(); + } // Apply target.resetFactionData(); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankShow.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankShow.java index ee703c70..5f855f63 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankShow.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRankShow.java @@ -1,10 +1,10 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.cmd.type.TypeMPlayer; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.Rank; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.util.Txt; public class CmdFactionsRankShow extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelation.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelation.java index 20922eb9..4f528065 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelation.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelation.java @@ -5,7 +5,7 @@ public class CmdFactionsRelation extends FactionsCommand { // FIELDS // -------------------------------------------- // - public CmdFactionsRelationSet cmdFactionsRelationSet = new CmdFactionsRelationSet(); + public final CmdFactionsRelationSet cmdFactionsRelationSet = new CmdFactionsRelationSet(); public CmdFactionsRelationList cmdFactionsRelationList = new CmdFactionsRelationList(); public CmdFactionsRelationWishes cmdFactionsRelationWishes = new CmdFactionsRelationWishes(); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelationList.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelationList.java index bd563151..673084f2 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelationList.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelationList.java @@ -1,11 +1,5 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.Rel; -import net.knarcraft.factions.cmd.type.TypeFaction; -import net.knarcraft.factions.cmd.type.TypeRelation; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.FactionColl; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.collections.MassiveSet; @@ -14,6 +8,12 @@ import com.massivecraft.massivecore.command.type.container.TypeSet; import com.massivecraft.massivecore.pager.Pager; import com.massivecraft.massivecore.pager.Stringifier; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.Rel; +import net.knarcraft.factions.cmd.type.TypeFaction; +import net.knarcraft.factions.cmd.type.TypeRelation; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.FactionColl; import org.bukkit.Bukkit; import java.util.List; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelationOld.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelationOld.java index f7e446d8..9d576a04 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelationOld.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelationOld.java @@ -1,10 +1,10 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeFaction; -import net.knarcraft.factions.entity.Faction; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.Visibility; import com.massivecraft.massivecore.util.MUtil; +import net.knarcraft.factions.cmd.type.TypeFaction; +import net.knarcraft.factions.entity.Faction; public class CmdFactionsRelationOld extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelationSet.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelationSet.java index 2af42866..0debc486 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelationSet.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelationSet.java @@ -1,5 +1,8 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.MassiveCommand; +import com.massivecraft.massivecore.mson.Mson; import net.knarcraft.factions.Rel; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.cmd.type.TypeRelation; @@ -7,9 +10,6 @@ import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MFlag; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.event.EventFactionsRelationChange; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.MassiveCommand; -import com.massivecraft.massivecore.mson.Mson; import org.bukkit.ChatColor; public class CmdFactionsRelationSet extends FactionsCommand { @@ -34,9 +34,9 @@ public class CmdFactionsRelationSet extends FactionsCommand { Rel newRelation = this.readArg(); // MPerm - if (!MPerm.getPermRel().has(msender, msenderFaction, true)) { - return; - } + if (!MPerm.getPermRel().has(msender, msenderFaction, true)) { + return; + } // Verify if (otherFaction == msenderFaction) { @@ -49,9 +49,9 @@ public class CmdFactionsRelationSet extends FactionsCommand { // Event EventFactionsRelationChange event = new EventFactionsRelationChange(sender, msenderFaction, otherFaction, newRelation); event.run(); - if (event.isCancelled()) { - return; - } + if (event.isCancelled()) { + return; + } newRelation = event.getNewRelation(); // try to set the new relation diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelationWishes.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelationWishes.java index 40ca126e..0a765a09 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelationWishes.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsRelationWishes.java @@ -1,10 +1,5 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.Rel; -import net.knarcraft.factions.cmd.type.TypeFaction; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.FactionColl; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.collections.MassiveMap; import com.massivecraft.massivecore.command.Parameter; @@ -12,6 +7,11 @@ import com.massivecraft.massivecore.pager.Pager; import com.massivecraft.massivecore.pager.Stringifier; import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.Rel; +import net.knarcraft.factions.cmd.type.TypeFaction; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.FactionColl; import org.bukkit.Bukkit; import java.util.Map; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSeeChunkOld.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSeeChunkOld.java index b75b0de1..e10edccd 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSeeChunkOld.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSeeChunkOld.java @@ -1,10 +1,10 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.util.AsciiMap; -import net.knarcraft.factions.util.VisualizeUtil; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PSFormatHumanSpace; +import net.knarcraft.factions.util.AsciiMap; +import net.knarcraft.factions.util.VisualizeUtil; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; @@ -56,7 +56,7 @@ public class CmdFactionsSeeChunkOld extends FactionsCommand { showPillar(me, world, blockX, blockZ); // Inform - boolean showCoords = AsciiMap.showChunkCoords(chunk); + boolean showCoords = AsciiMap.showChunkCoordinates(chunk); String chunkDesc = showCoords ? chunk.toString(PSFormatHumanSpace.get()) : "chunk"; msg("Visualized %s", chunkDesc); } diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetAll.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetAll.java index 0fa1429b..134f26f8 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetAll.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetAll.java @@ -1,14 +1,14 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Perm; -import net.knarcraft.factions.entity.Board; -import net.knarcraft.factions.entity.BoardColl; -import net.knarcraft.factions.entity.Faction; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.mixin.MixinWorld; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.MUtil; +import net.knarcraft.factions.Perm; +import net.knarcraft.factions.entity.Board; +import net.knarcraft.factions.entity.BoardColl; +import net.knarcraft.factions.entity.Faction; import java.util.Collections; import java.util.List; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetAuto.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetAuto.java index 1c1fdc2b..d556b91e 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetAuto.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetAuto.java @@ -1,14 +1,14 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; +import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; +import com.massivecraft.massivecore.ps.PS; import net.knarcraft.factions.Perm; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.FactionColl; import net.knarcraft.factions.entity.MPerm; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; -import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; -import com.massivecraft.massivecore.ps.PS; import java.util.Collections; import java.util.Set; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetCircle.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetCircle.java index 8bbb770b..d360ea1f 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetCircle.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetCircle.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Perm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.ChunkUtil; +import net.knarcraft.factions.Perm; import java.util.Set; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetFill.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetFill.java index cef30c27..3a8051e4 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetFill.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetFill.java @@ -1,14 +1,13 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Perm; -import net.knarcraft.factions.entity.BoardColl; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.MConf; -import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.ChunkUtil; +import net.knarcraft.factions.Perm; +import net.knarcraft.factions.entity.BoardColl; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.MConf; import java.util.Set; import java.util.function.Predicate; @@ -41,7 +40,7 @@ public class CmdFactionsSetFill extends CmdFactionsSetXSimple { // -------------------------------------------- // @Override - public Set getChunks() throws MassiveException { + public Set getChunks() { // Common Startup final PS chunk = PS.valueOf(me.getLocation()).getChunk(true); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetOne.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetOne.java index 7409965b..c40c4112 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetOne.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetOne.java @@ -1,9 +1,9 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Perm; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.ps.PS; +import net.knarcraft.factions.Perm; import java.util.Collections; import java.util.Set; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetSquare.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetSquare.java index 9019d69b..b1ae715f 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetSquare.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetSquare.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Perm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.ChunkUtil; +import net.knarcraft.factions.Perm; import java.util.Set; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetX.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetX.java index 85642a8d..8f8d0be6 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetX.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetX.java @@ -1,9 +1,9 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.FactionColl; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.ps.PS; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.FactionColl; import java.util.Set; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetXAll.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetXAll.java index d6196043..0aab8116 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetXAll.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetXAll.java @@ -1,9 +1,9 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeFaction; -import net.knarcraft.factions.entity.Faction; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.type.primitive.TypeString; +import net.knarcraft.factions.cmd.type.TypeFaction; +import net.knarcraft.factions.entity.Faction; public abstract class CmdFactionsSetXAll extends CmdFactionsSetX { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetXRadius.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetXRadius.java index 5835229e..cbcc7ab5 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetXRadius.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetXRadius.java @@ -1,9 +1,9 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeFaction; -import net.knarcraft.factions.entity.MConf; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.type.primitive.TypeInteger; +import net.knarcraft.factions.cmd.type.TypeFaction; +import net.knarcraft.factions.entity.MConf; public abstract class CmdFactionsSetXRadius extends CmdFactionsSetX { diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSethome.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSethome.java index b27fdafe..1110e6a5 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSethome.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSethome.java @@ -1,11 +1,10 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeFaction; -import net.knarcraft.factions.entity.MConf; -import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.Visibility; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.util.MUtil; +import net.knarcraft.factions.cmd.type.TypeFaction; +import net.knarcraft.factions.entity.MConf; import java.util.List; @@ -30,7 +29,7 @@ public class CmdFactionsSethome extends FactionsCommandWarp { // -------------------------------------------- // @Override - public void perform() throws MassiveException { + public void perform() { List args = MUtil.list(MConf.get().warpsHomeName, this.argAt(0)); CmdFactions.get().cmdFactionsWarp.cmdFactionWarpAdd.execute(me, args); } diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetpower.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetpower.java index 807883f9..6bbd2f4f 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetpower.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsSetpower.java @@ -1,12 +1,12 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; +import com.massivecraft.massivecore.command.type.primitive.TypeDouble; import net.knarcraft.factions.Perm; import net.knarcraft.factions.cmd.type.TypeMPlayer; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.event.EventFactionsPowerChange; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; -import com.massivecraft.massivecore.command.type.primitive.TypeDouble; public class CmdFactionsSetpower extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsStatus.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsStatus.java index 9d563b39..c696ffe9 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsStatus.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsStatus.java @@ -1,10 +1,5 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeFaction; -import net.knarcraft.factions.cmd.type.TypeSortMPlayer; -import net.knarcraft.factions.comparator.ComparatorMPlayerInactivity; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.Parameter; import com.massivecraft.massivecore.pager.Pager; @@ -12,6 +7,11 @@ import com.massivecraft.massivecore.pager.Stringifier; import com.massivecraft.massivecore.util.TimeDiffUtil; import com.massivecraft.massivecore.util.TimeUnit; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.cmd.type.TypeFaction; +import net.knarcraft.factions.cmd.type.TypeSortMPlayer; +import net.knarcraft.factions.comparator.ComparatorMPlayerInactivity; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.MPlayer; import java.util.Comparator; import java.util.LinkedHashMap; diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTaxFaction.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTaxFaction.java index 3f28a304..566b2350 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTaxFaction.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTaxFaction.java @@ -1,14 +1,14 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.mson.Mson; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.cmd.req.ReqTaxEnabled; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MFlag; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.Rank; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.mson.Mson; -import com.massivecraft.massivecore.util.Txt; import java.util.Map.Entry; @@ -51,21 +51,21 @@ public class CmdFactionsTaxFaction extends FactionsCommand { MPlayer mplayer = MPlayer.get(id); String name; - if (Faction.IDENTIFIER_TAX_BASE.equals(id)) { - name = "Default"; - } else if (rank != null) { - name = rank.getName(); - } else if (mplayer != null) { - name = mplayer.getDisplayName(msender); - } else { - continue; - } + if (Faction.IDENTIFIER_TAX_BASE.equals(id)) { + name = "Default"; + } else if (rank != null) { + name = rank.getName(); + } else if (mplayer != null) { + name = mplayer.getDisplayName(msender); + } else { + continue; + } anyTax = true; msg("%s: %.2f", name, tax); } - if (!anyTax) { - msg("No players in this faction pays taxes."); - } + if (!anyTax) { + msg("No players in this faction pays taxes."); + } } } diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTaxPlayer.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTaxPlayer.java index 892c05db..fefce887 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTaxPlayer.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTaxPlayer.java @@ -1,12 +1,12 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.req.ReqTaxEnabled; -import net.knarcraft.factions.cmd.type.TypeMPlayer; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.money.Money; import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.cmd.req.ReqTaxEnabled; +import net.knarcraft.factions.cmd.type.TypeMPlayer; +import net.knarcraft.factions.entity.MPlayer; public class CmdFactionsTaxPlayer extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTaxRun.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTaxRun.java index 6e8f8090..1b9b13d3 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTaxRun.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTaxRun.java @@ -2,7 +2,6 @@ package net.knarcraft.factions.cmd; import net.knarcraft.factions.cmd.req.ReqTaxEnabled; import net.knarcraft.factions.task.TaskTax; -import com.massivecraft.massivecore.MassiveException; public class CmdFactionsTaxRun extends FactionsCommand { // -------------------------------------------- // @@ -18,7 +17,7 @@ public class CmdFactionsTaxRun extends FactionsCommand { // -------------------------------------------- // @Override - public void perform() throws MassiveException { + public void perform() { TaskTax.get().invoke(System.currentTimeMillis()); } diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTaxSet.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTaxSet.java index b7546966..3205dc87 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTaxSet.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTaxSet.java @@ -1,5 +1,9 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeDouble; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.util.MUtil; import net.knarcraft.factions.cmd.req.ReqTaxEnabled; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.cmd.type.TypeTaxable; @@ -9,10 +13,6 @@ import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.MPlayerColl; import net.knarcraft.factions.entity.Rank; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.type.primitive.TypeDouble; -import com.massivecraft.massivecore.money.Money; -import com.massivecraft.massivecore.util.MUtil; public class CmdFactionsTaxSet extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTerritorytitles.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTerritorytitles.java index a62d02ec..0785513d 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTerritorytitles.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTerritorytitles.java @@ -30,9 +30,9 @@ public class CmdFactionsTerritorytitles extends FactionsCommand { @Override public Visibility getVisibility() { // We hide the command if titles aren't available. - if (!MixinTitle.get().isAvailable()) { - return Visibility.INVISIBLE; - } + if (!MixinTitle.get().isAvailable()) { + return Visibility.INVISIBLE; + } return super.getVisibility(); } diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTitle.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTitle.java index c8c4196e..c570a5f5 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTitle.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTitle.java @@ -1,13 +1,13 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeString; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.Perm; import net.knarcraft.factions.cmd.type.TypeMPlayer; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.event.EventFactionsTitleChange; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.type.primitive.TypeString; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; public class CmdFactionsTitle extends FactionsCommand { diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTop.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTop.java index f2a01c14..ec4e4b3c 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTop.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsTop.java @@ -1,10 +1,5 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.FactionColl; -import net.knarcraft.factions.entity.MPlayer; -import net.knarcraft.factions.integration.Econ; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.Parameter; import com.massivecraft.massivecore.command.type.enumeration.TypeEnum; @@ -14,6 +9,11 @@ import com.massivecraft.massivecore.pager.Stringifier; import com.massivecraft.massivecore.util.TimeDiffUtil; import com.massivecraft.massivecore.util.TimeUnit; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.FactionColl; +import net.knarcraft.factions.entity.MPlayer; +import net.knarcraft.factions.integration.Econ; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -80,20 +80,14 @@ public class CmdFactionsTop extends FactionsCommand { private static String getValue(TopCategory category, Faction faction, MPlayer mplayer) { String ret = Txt.parse("%s: ", faction.getName(mplayer)); switch (category) { - case MONEY: - ret += Money.format(Econ.getMoney(faction), true); - break; - case MEMBERS: - ret += faction.getMPlayers().size() + " members"; - break; - case TERRITORY: - ret += faction.getLandCount() + " chunks"; - break; - case AGE: + case MONEY -> ret += Money.format(Econ.getMoney(faction), true); + case MEMBERS -> ret += faction.getMPlayers().size() + " members"; + case TERRITORY -> ret += faction.getLandCount() + " chunks"; + case AGE -> { long ageMillis = faction.getAge(); LinkedHashMap ageUnitcounts = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(ageMillis, TimeUnit.getAllButMillis()), 3); ret += TimeDiffUtil.formatedVerboose(ageUnitcounts); - break; + } } return ret; } diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsUnsethome.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsUnsethome.java index 5d8da840..5ddbb128 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsUnsethome.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsUnsethome.java @@ -1,11 +1,10 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeFaction; -import net.knarcraft.factions.entity.MConf; -import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.Visibility; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.util.MUtil; +import net.knarcraft.factions.cmd.type.TypeFaction; +import net.knarcraft.factions.entity.MConf; import java.util.List; @@ -30,7 +29,7 @@ public class CmdFactionsUnsethome extends FactionsCommandWarp { // -------------------------------------------- // @Override - public void perform() throws MassiveException { + public void perform() { List args = MUtil.list(MConf.get().warpsHomeName, this.argAt(0)); CmdFactions.get().cmdFactionsWarp.cmdFactionWarpRemove.execute(me, args); } diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsUnstuck.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsUnstuck.java index dda92da5..da3aacbe 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsUnstuck.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsUnstuck.java @@ -1,18 +1,17 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.entity.BoardColl; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.FactionColl; -import net.knarcraft.factions.entity.MConf; -import net.knarcraft.factions.entity.MPerm; -import net.knarcraft.factions.entity.MPlayer; -import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.mixin.MixinTeleport; import com.massivecraft.massivecore.mixin.TeleporterException; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.teleport.Destination; import com.massivecraft.massivecore.teleport.DestinationSimple; +import net.knarcraft.factions.entity.BoardColl; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.FactionColl; +import net.knarcraft.factions.entity.MConf; +import net.knarcraft.factions.entity.MPerm; +import net.knarcraft.factions.entity.MPlayer; import org.bukkit.Location; import org.bukkit.World; @@ -34,7 +33,7 @@ public class CmdFactionsUnstuck extends FactionsCommand { // -------------------------------------------- // @Override - public void perform() throws MassiveException { + public void perform() { // If the player is in a chunk ... final PS center = PS.valueOf(me.getLocation().getChunk()); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVote.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVote.java index dfcd7c14..86899ec1 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVote.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVote.java @@ -7,7 +7,7 @@ public class CmdFactionsVote extends FactionsCommand { public CmdFactionsVoteShow cmdFactionsVoteShow = new CmdFactionsVoteShow(); public CmdFactionsVoteList cmdFactionsVoteList = new CmdFactionsVoteList(); - public CmdFactionsVoteDo cmdFactionsVoteDo = new CmdFactionsVoteDo(); + public final CmdFactionsVoteDo cmdFactionsVoteDo = new CmdFactionsVoteDo(); public CmdFactionsVoteCreate cmdFactionsVoteCreate = new CmdFactionsVoteCreate(); public CmdFactionsVoteRemove cmdFactionsVoteRemove = new CmdFactionsVoteRemove(); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteCreate.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteCreate.java index b15a3dde..ac6841b7 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteCreate.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteCreate.java @@ -1,13 +1,13 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.entity.MPerm; -import net.knarcraft.factions.entity.Vote; -import net.knarcraft.factions.event.EventFactionsVoteAdd; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.command.type.container.TypeList; import com.massivecraft.massivecore.command.type.primitive.TypeString; import com.massivecraft.massivecore.util.IdUtil; +import net.knarcraft.factions.entity.MPerm; +import net.knarcraft.factions.entity.Vote; +import net.knarcraft.factions.event.EventFactionsVoteAdd; import java.util.List; @@ -33,9 +33,9 @@ public class CmdFactionsVoteCreate extends FactionsCommandWarp { List options = this.readArg(); // MPerm - if (!MPerm.getPermCreateVote().has(msender, msenderFaction, true)) { - return; - } + if (!MPerm.getPermCreateVote().has(msender, msenderFaction, true)) { + return; + } if (msenderFaction.getVoteByName(name).isPresent()) { throw new MassiveException().addMsg("There is already a vote called %s.", name); @@ -44,9 +44,9 @@ public class CmdFactionsVoteCreate extends FactionsCommandWarp { // Make sure there are no duplicated List options2 = new MassiveList<>(); for (String str : options) { - if (options2.stream().anyMatch(str::equalsIgnoreCase)) { - continue; - } + if (options2.stream().anyMatch(str::equalsIgnoreCase)) { + continue; + } options2.add(str); } @@ -56,9 +56,9 @@ public class CmdFactionsVoteCreate extends FactionsCommandWarp { // Event EventFactionsVoteAdd event = new EventFactionsVoteAdd(sender, msenderFaction, vote); event.run(); - if (event.isCancelled()) { - return; - } + if (event.isCancelled()) { + return; + } vote = event.getVote(); // Apply diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteDo.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteDo.java index cd229a9e..ccc83dd2 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteDo.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteDo.java @@ -1,10 +1,10 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeString; import net.knarcraft.factions.cmd.type.TypeVote; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.Vote; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.type.primitive.TypeString; public class CmdFactionsVoteDo extends FactionsCommandWarp { // -------------------------------------------- // @@ -28,9 +28,9 @@ public class CmdFactionsVoteDo extends FactionsCommandWarp { String option = this.readArg(); // Any and MPerm - if (!MPerm.getPermVote().has(msender, msenderFaction, true)) { - return; - } + if (!MPerm.getPermVote().has(msender, msenderFaction, true)) { + return; + } if (vote.getOptions().stream().noneMatch(option::equalsIgnoreCase)) { throw new MassiveException().addMsg("No option in %s matches %s.", vote.getName(), option); diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteList.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteList.java index be31fbfc..435522e7 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteList.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteList.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.entity.Vote; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.Parameter; import com.massivecraft.massivecore.pager.Pager; import com.massivecraft.massivecore.pager.Stringifier; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.entity.Vote; public class CmdFactionsVoteList extends FactionsCommandWarp { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteRemove.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteRemove.java index 21a2ba80..8ae7937b 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteRemove.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteRemove.java @@ -1,10 +1,10 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; import net.knarcraft.factions.cmd.type.TypeVote; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.Vote; import net.knarcraft.factions.event.EventFactionsVoteRemove; -import com.massivecraft.massivecore.MassiveException; public class CmdFactionsVoteRemove extends FactionsCommandWarp { // -------------------------------------------- // @@ -26,16 +26,16 @@ public class CmdFactionsVoteRemove extends FactionsCommandWarp { Vote vote = TypeVote.get(msenderFaction).read(this.arg(), sender); // Any and MPerm - if (!MPerm.getPermCreateVote().has(msender, msenderFaction, true)) { - return; - } + if (!MPerm.getPermCreateVote().has(msender, msenderFaction, true)) { + return; + } // Event EventFactionsVoteRemove event = new EventFactionsVoteRemove(sender, msenderFaction, vote); event.run(); - if (event.isCancelled()) { - return; - } + if (event.isCancelled()) { + return; + } vote = event.getVote(); // Apply diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteShow.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteShow.java index a16eb88b..dcdab242 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteShow.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsVoteShow.java @@ -1,9 +1,9 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeVote; -import net.knarcraft.factions.entity.Vote; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.cmd.type.TypeVote; +import net.knarcraft.factions.entity.Vote; public class CmdFactionsVoteShow extends FactionsCommandWarp { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarp.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarp.java index 983cd4b1..be47d4f0 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarp.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarp.java @@ -5,9 +5,9 @@ public class CmdFactionsWarp extends FactionsCommand { // FIELDS // -------------------------------------------- // - public CmdFactionsWarpGo cmdFactionsWarpGo = new CmdFactionsWarpGo(); + public final CmdFactionsWarpGo cmdFactionsWarpGo = new CmdFactionsWarpGo(); public CmdFactionsWarpList cmdFactionsWarpList = new CmdFactionsWarpList(); - public CmdFactionsWarpAdd cmdFactionWarpAdd = new CmdFactionsWarpAdd(); - public CmdFactionsWarpRemove cmdFactionWarpRemove = new CmdFactionsWarpRemove(); + public final CmdFactionsWarpAdd cmdFactionWarpAdd = new CmdFactionsWarpAdd(); + public final CmdFactionsWarpRemove cmdFactionWarpRemove = new CmdFactionsWarpRemove(); } diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarpAdd.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarpAdd.java index 3a643e60..cdce2dda 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarpAdd.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarpAdd.java @@ -1,15 +1,15 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; +import com.massivecraft.massivecore.command.type.primitive.TypeString; +import com.massivecraft.massivecore.ps.PS; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.Warp; import net.knarcraft.factions.event.EventFactionsWarpAdd; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; -import com.massivecraft.massivecore.command.type.primitive.TypeString; -import com.massivecraft.massivecore.ps.PS; public class CmdFactionsWarpAdd extends FactionsCommandWarp { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarpGo.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarpGo.java index 5f2bd11d..0e3593fd 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarpGo.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarpGo.java @@ -1,5 +1,15 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; +import com.massivecraft.massivecore.mixin.MixinMessage; +import com.massivecraft.massivecore.mixin.MixinTeleport; +import com.massivecraft.massivecore.mixin.TeleporterException; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.teleport.Destination; +import com.massivecraft.massivecore.teleport.DestinationSimple; +import com.massivecraft.massivecore.util.MUtil; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.Rel; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.cmd.type.TypeWarp; @@ -11,16 +21,6 @@ import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.Warp; import net.knarcraft.factions.event.EventFactionsWarpTeleport; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; -import com.massivecraft.massivecore.mixin.MixinMessage; -import com.massivecraft.massivecore.mixin.MixinTeleport; -import com.massivecraft.massivecore.mixin.TeleporterException; -import com.massivecraft.massivecore.ps.PS; -import com.massivecraft.massivecore.teleport.Destination; -import com.massivecraft.massivecore.teleport.DestinationSimple; -import com.massivecraft.massivecore.util.MUtil; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; @@ -51,14 +51,14 @@ public class CmdFactionsWarpGo extends FactionsCommandWarp { String warpDesc = Txt.parse("%s in %s", warp.getName(), faction.describeTo(msender, false)); // Must be valid - if (!warp.verifyIsValid()) { - return; - } + if (!warp.verifyIsValid()) { + return; + } // Any and MPerm - if (!MPerm.getPermWarp().has(msender, faction, true)) { - return; - } + if (!MPerm.getPermWarp().has(msender, faction, true)) { + return; + } if (!MConf.get().warpsTeleportAllowedFromEnemyTerritory && msender.isInEnemyTerritory()) { throw new MassiveException().addMsg("You cannot teleport to %s while in the territory of an enemy faction.", warp); @@ -94,18 +94,18 @@ public class CmdFactionsWarpGo extends FactionsCommandWarp { double z = locationHere.getZ(); for (Player p : w.getPlayers()) { - if (MUtil.isntPlayer(p)) { - continue; - } + if (MUtil.isntPlayer(p)) { + continue; + } - if (!p.isOnline() || p.isDead() || p == me || p.getWorld() != w) { - continue; - } + if (!p.isOnline() || p.isDead() || p == me || p.getWorld() != w) { + continue; + } MPlayer fp = MPlayer.get(p); - if (msender.getRelationTo(fp) != Rel.ENEMY) { - continue; - } + if (msender.getRelationTo(fp) != Rel.ENEMY) { + continue; + } Location l = p.getLocation(); double dx = Math.abs(x - l.getX()); @@ -114,9 +114,9 @@ public class CmdFactionsWarpGo extends FactionsCommandWarp { double max = MConf.get().warpsTeleportAllowedEnemyDistance; // box-shaped distance check - if (dx > max || dy > max || dz > max) { - continue; - } + if (dx > max || dy > max || dz > max) { + continue; + } throw new MassiveException().addMsg("You cannot teleport to %s while an enemy is within %f blocks of you.", warpDesc, max); } @@ -125,9 +125,9 @@ public class CmdFactionsWarpGo extends FactionsCommandWarp { // Event EventFactionsWarpTeleport event = new EventFactionsWarpTeleport(sender, warp); event.run(); - if (event.isCancelled()) { - return; - } + if (event.isCancelled()) { + return; + } // Apply try { diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarpList.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarpList.java index 148690f6..e39b1ee2 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarpList.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarpList.java @@ -1,15 +1,15 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.type.TypeFaction; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.MPerm; -import net.knarcraft.factions.entity.Warp; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.Parameter; import com.massivecraft.massivecore.pager.Pager; import com.massivecraft.massivecore.pager.Stringifier; import com.massivecraft.massivecore.ps.PSFormatDesc; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.cmd.type.TypeFaction; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.MPerm; +import net.knarcraft.factions.entity.Warp; public class CmdFactionsWarpList extends FactionsCommandWarp { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarpRemove.java b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarpRemove.java index 61f7c64e..3d265aa4 100644 --- a/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarpRemove.java +++ b/src/main/java/net/knarcraft/factions/cmd/CmdFactionsWarpRemove.java @@ -1,12 +1,12 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.MassiveException; import net.knarcraft.factions.cmd.type.TypeFaction; import net.knarcraft.factions.cmd.type.TypeWarp; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.Warp; import net.knarcraft.factions.event.EventFactionsWarpRemove; -import com.massivecraft.massivecore.MassiveException; public class CmdFactionsWarpRemove extends FactionsCommandWarp { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/FactionsCommand.java b/src/main/java/net/knarcraft/factions/cmd/FactionsCommand.java index fee3c555..7206fdab 100644 --- a/src/main/java/net/knarcraft/factions/cmd/FactionsCommand.java +++ b/src/main/java/net/knarcraft/factions/cmd/FactionsCommand.java @@ -1,8 +1,8 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.command.MassiveCommand; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MPlayer; -import com.massivecraft.massivecore.command.MassiveCommand; public class FactionsCommand extends MassiveCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/FactionsCommandDocumentation.java b/src/main/java/net/knarcraft/factions/cmd/FactionsCommandDocumentation.java index 216301c8..a5772dea 100644 --- a/src/main/java/net/knarcraft/factions/cmd/FactionsCommandDocumentation.java +++ b/src/main/java/net/knarcraft/factions/cmd/FactionsCommandDocumentation.java @@ -1,7 +1,7 @@ package net.knarcraft.factions.cmd; -import net.knarcraft.factions.cmd.req.ReqFactionWarpsEnabled; import com.massivecraft.massivecore.mson.Mson; +import net.knarcraft.factions.cmd.req.ReqFactionWarpsEnabled; public class FactionsCommandDocumentation extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/FactionsCommandWarp.java b/src/main/java/net/knarcraft/factions/cmd/FactionsCommandWarp.java index a7a1c3cd..144adcae 100644 --- a/src/main/java/net/knarcraft/factions/cmd/FactionsCommandWarp.java +++ b/src/main/java/net/knarcraft/factions/cmd/FactionsCommandWarp.java @@ -1,8 +1,8 @@ package net.knarcraft.factions.cmd; +import com.massivecraft.massivecore.command.Visibility; import net.knarcraft.factions.cmd.req.ReqFactionWarpsEnabled; import net.knarcraft.factions.entity.MConf; -import com.massivecraft.massivecore.command.Visibility; public class FactionsCommandWarp extends FactionsCommand { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/req/ReqBankCommandsEnabled.java b/src/main/java/net/knarcraft/factions/cmd/req/ReqBankCommandsEnabled.java index 7d8806b5..de01a2ff 100644 --- a/src/main/java/net/knarcraft/factions/cmd/req/ReqBankCommandsEnabled.java +++ b/src/main/java/net/knarcraft/factions/cmd/req/ReqBankCommandsEnabled.java @@ -1,24 +1,27 @@ package net.knarcraft.factions.cmd.req; -import net.knarcraft.factions.entity.MConf; -import net.knarcraft.factions.integration.Econ; import com.massivecraft.massivecore.command.MassiveCommand; import com.massivecraft.massivecore.command.requirement.RequirementAbstract; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.entity.MConf; +import net.knarcraft.factions.integration.Econ; import org.bukkit.command.CommandSender; +import java.io.Serial; + public class ReqBankCommandsEnabled extends RequirementAbstract { // -------------------------------------------- // // SERIALIZABLE // -------------------------------------------- // + @Serial private static final long serialVersionUID = 1L; // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ReqBankCommandsEnabled i = new ReqBankCommandsEnabled(); + private static final ReqBankCommandsEnabled i = new ReqBankCommandsEnabled(); public static ReqBankCommandsEnabled get() { return i; diff --git a/src/main/java/net/knarcraft/factions/cmd/req/ReqFactionWarpsEnabled.java b/src/main/java/net/knarcraft/factions/cmd/req/ReqFactionWarpsEnabled.java index db6ee513..0a56b5fd 100644 --- a/src/main/java/net/knarcraft/factions/cmd/req/ReqFactionWarpsEnabled.java +++ b/src/main/java/net/knarcraft/factions/cmd/req/ReqFactionWarpsEnabled.java @@ -1,23 +1,26 @@ package net.knarcraft.factions.cmd.req; -import net.knarcraft.factions.entity.MConf; import com.massivecraft.massivecore.command.MassiveCommand; import com.massivecraft.massivecore.command.requirement.RequirementAbstract; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.entity.MConf; import org.bukkit.command.CommandSender; +import java.io.Serial; + public class ReqFactionWarpsEnabled extends RequirementAbstract { // -------------------------------------------- // // SERIALIZABLE // -------------------------------------------- // + @Serial private static final long serialVersionUID = 1L; // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ReqFactionWarpsEnabled i = new ReqFactionWarpsEnabled(); + private static final ReqFactionWarpsEnabled i = new ReqFactionWarpsEnabled(); public static ReqFactionWarpsEnabled get() { return i; diff --git a/src/main/java/net/knarcraft/factions/cmd/req/ReqHasFaction.java b/src/main/java/net/knarcraft/factions/cmd/req/ReqHasFaction.java index c3e89129..a2fe71d7 100644 --- a/src/main/java/net/knarcraft/factions/cmd/req/ReqHasFaction.java +++ b/src/main/java/net/knarcraft/factions/cmd/req/ReqHasFaction.java @@ -1,24 +1,27 @@ package net.knarcraft.factions.cmd.req; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.command.MassiveCommand; import com.massivecraft.massivecore.command.requirement.RequirementAbstract; import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.entity.MPlayer; import org.bukkit.command.CommandSender; +import java.io.Serial; + public class ReqHasFaction extends RequirementAbstract { // -------------------------------------------- // // SERIALIZABLE // -------------------------------------------- // + @Serial private static final long serialVersionUID = 1L; // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ReqHasFaction i = new ReqHasFaction(); + private static final ReqHasFaction i = new ReqHasFaction(); public static ReqHasFaction get() { return i; @@ -30,9 +33,9 @@ public class ReqHasFaction extends RequirementAbstract { @Override public boolean apply(CommandSender sender, MassiveCommand command) { - if (MUtil.isntSender(sender)) { - return false; - } + if (MUtil.isntSender(sender)) { + return false; + } MPlayer mplayer = MPlayer.get(sender); return mplayer.hasFaction(); diff --git a/src/main/java/net/knarcraft/factions/cmd/req/ReqHasntFaction.java b/src/main/java/net/knarcraft/factions/cmd/req/ReqHasntFaction.java index 29ab08fa..e2996d89 100644 --- a/src/main/java/net/knarcraft/factions/cmd/req/ReqHasntFaction.java +++ b/src/main/java/net/knarcraft/factions/cmd/req/ReqHasntFaction.java @@ -1,24 +1,27 @@ package net.knarcraft.factions.cmd.req; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.command.MassiveCommand; import com.massivecraft.massivecore.command.requirement.RequirementAbstract; import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.entity.MPlayer; import org.bukkit.command.CommandSender; +import java.io.Serial; + public class ReqHasntFaction extends RequirementAbstract { // -------------------------------------------- // // SERIALIZABLE // -------------------------------------------- // + @Serial private static final long serialVersionUID = 1L; // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ReqHasntFaction i = new ReqHasntFaction(); + private static final ReqHasntFaction i = new ReqHasntFaction(); public static ReqHasntFaction get() { return i; @@ -30,9 +33,9 @@ public class ReqHasntFaction extends RequirementAbstract { @Override public boolean apply(CommandSender sender, MassiveCommand command) { - if (MUtil.isntSender(sender)) { - return true; - } + if (MUtil.isntSender(sender)) { + return true; + } MPlayer mplayer = MPlayer.get(sender); return !mplayer.hasFaction(); diff --git a/src/main/java/net/knarcraft/factions/cmd/req/ReqRankIsAtLeast.java b/src/main/java/net/knarcraft/factions/cmd/req/ReqRankIsAtLeast.java index 671411da..674254e1 100644 --- a/src/main/java/net/knarcraft/factions/cmd/req/ReqRankIsAtLeast.java +++ b/src/main/java/net/knarcraft/factions/cmd/req/ReqRankIsAtLeast.java @@ -1,18 +1,21 @@ package net.knarcraft.factions.cmd.req; -import net.knarcraft.factions.entity.MPlayer; -import net.knarcraft.factions.entity.Rank; import com.massivecraft.massivecore.command.MassiveCommand; import com.massivecraft.massivecore.command.requirement.RequirementAbstract; import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.entity.MPlayer; +import net.knarcraft.factions.entity.Rank; import org.bukkit.command.CommandSender; +import java.io.Serial; + public class ReqRankIsAtLeast extends RequirementAbstract { // -------------------------------------------- // // SERIALIZABLE // -------------------------------------------- // + @Serial private static final long serialVersionUID = 1L; // -------------------------------------------- // @@ -43,9 +46,9 @@ public class ReqRankIsAtLeast extends RequirementAbstract { @Override public boolean apply(CommandSender sender, MassiveCommand command) { - if (MUtil.isntSender(sender)) { - return false; - } + if (MUtil.isntSender(sender)) { + return false; + } MPlayer mplayer = MPlayer.get(sender); return mplayer.getRank().isAtLeast(this.getRank()); diff --git a/src/main/java/net/knarcraft/factions/cmd/req/ReqTaxEnabled.java b/src/main/java/net/knarcraft/factions/cmd/req/ReqTaxEnabled.java index 027ca8dc..431b24fc 100644 --- a/src/main/java/net/knarcraft/factions/cmd/req/ReqTaxEnabled.java +++ b/src/main/java/net/knarcraft/factions/cmd/req/ReqTaxEnabled.java @@ -1,23 +1,26 @@ package net.knarcraft.factions.cmd.req; -import net.knarcraft.factions.task.TaskTax; import com.massivecraft.massivecore.command.MassiveCommand; import com.massivecraft.massivecore.command.requirement.RequirementAbstract; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.task.TaskTax; import org.bukkit.command.CommandSender; +import java.io.Serial; + public class ReqTaxEnabled extends RequirementAbstract { // -------------------------------------------- // // SERIALIZABLE // -------------------------------------------- // + @Serial private static final long serialVersionUID = 1L; // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ReqTaxEnabled i = new ReqTaxEnabled(); + private static final ReqTaxEnabled i = new ReqTaxEnabled(); public static ReqTaxEnabled get() { return i; diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeEntityInternalFaction.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeEntityInternalFaction.java index 299fce3f..554dcd29 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeEntityInternalFaction.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeEntityInternalFaction.java @@ -1,10 +1,10 @@ package net.knarcraft.factions.cmd.type; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.command.type.TypeAbstractChoice; import com.massivecraft.massivecore.store.EntityInternal; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.MPlayer; import org.bukkit.command.CommandSender; import java.util.Collection; @@ -26,9 +26,9 @@ public abstract class TypeEntityInternalFaction> ext protected TypeEntityInternalFaction(Class clazz, Faction faction) { super(clazz); - if (faction == null) { - throw new NullPointerException("faction"); - } + if (faction == null) { + throw new NullPointerException("faction"); + } this.faction = faction; @@ -54,18 +54,18 @@ public abstract class TypeEntityInternalFaction> ext @Override public boolean isValid(String arg, CommandSender sender) { // In the generic case accept all - if (this.getAll().isEmpty()) { - return true; - } else { - return super.isValid(arg, sender); - } + if (this.getAll().isEmpty()) { + return true; + } else { + return super.isValid(arg, sender); + } } @Override public Collection getTabList(CommandSender sender, String arg) { - if (this.getFaction() != null) { - return super.getTabList(sender, arg); - } + if (this.getFaction() != null) { + return super.getTabList(sender, arg); + } // Default to tab list for the sender Faction faction = MPlayer.get(sender).getFaction(); diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeFaction.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeFaction.java index 2643c7be..95ff55cd 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeFaction.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeFaction.java @@ -1,14 +1,14 @@ package net.knarcraft.factions.cmd.type; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.FactionColl; -import net.knarcraft.factions.entity.MPlayer; -import net.knarcraft.factions.entity.MPlayerColl; import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.command.type.TypeAbstract; import com.massivecraft.massivecore.comparator.ComparatorCaseInsensitive; import com.massivecraft.massivecore.util.IdUtil; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.FactionColl; +import net.knarcraft.factions.entity.MPlayer; +import net.knarcraft.factions.entity.MPlayerColl; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -21,7 +21,7 @@ public class TypeFaction extends TypeAbstract { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static TypeFaction i = new TypeFaction(); + private static final TypeFaction i = new TypeFaction(); public static TypeFaction get() { return i; diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeFactionChunkChangeType.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeFactionChunkChangeType.java index 6271a0e8..6cda4b8b 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeFactionChunkChangeType.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeFactionChunkChangeType.java @@ -1,14 +1,14 @@ package net.knarcraft.factions.cmd.type; -import net.knarcraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.massivecore.command.type.enumeration.TypeEnum; +import net.knarcraft.factions.event.EventFactionsChunkChangeType; public class TypeFactionChunkChangeType extends TypeEnum { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static TypeFactionChunkChangeType i = new TypeFactionChunkChangeType(); + private static final TypeFactionChunkChangeType i = new TypeFactionChunkChangeType(); public static TypeFactionChunkChangeType get() { return i; diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeFactionNameAbstract.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeFactionNameAbstract.java index fbe0b8d9..51c44722 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeFactionNameAbstract.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeFactionNameAbstract.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.cmd.type; +import com.massivecraft.massivecore.Named; +import com.massivecraft.massivecore.command.type.TypeNameAbstract; import net.knarcraft.factions.entity.FactionColl; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.util.MiscUtil; -import com.massivecraft.massivecore.Named; -import com.massivecraft.massivecore.command.type.TypeNameAbstract; import org.bukkit.command.CommandSender; public class TypeFactionNameAbstract extends TypeNameAbstract { diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeFactionNameLenient.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeFactionNameLenient.java index 05ed788e..ada8247f 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeFactionNameLenient.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeFactionNameLenient.java @@ -5,7 +5,7 @@ public class TypeFactionNameLenient extends TypeFactionNameAbstract { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static TypeFactionNameLenient i = new TypeFactionNameLenient(); + private static final TypeFactionNameLenient i = new TypeFactionNameLenient(); public static TypeFactionNameLenient get() { return i; diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeFactionNameStrict.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeFactionNameStrict.java index 85864d2b..caeb2aef 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeFactionNameStrict.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeFactionNameStrict.java @@ -5,7 +5,7 @@ public class TypeFactionNameStrict extends TypeFactionNameAbstract { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static TypeFactionNameStrict i = new TypeFactionNameStrict(); + private static final TypeFactionNameStrict i = new TypeFactionNameStrict(); public static TypeFactionNameStrict get() { return i; diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeMFlag.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeMFlag.java index ecb3e86e..b81d4b81 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeMFlag.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeMFlag.java @@ -1,8 +1,8 @@ package net.knarcraft.factions.cmd.type; +import com.massivecraft.massivecore.command.type.store.TypeEntity; import net.knarcraft.factions.entity.MFlag; import net.knarcraft.factions.entity.MFlagColl; -import com.massivecraft.massivecore.command.type.store.TypeEntity; import java.util.Collection; @@ -11,7 +11,7 @@ public class TypeMFlag extends TypeEntity { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static TypeMFlag i = new TypeMFlag(); + private static final TypeMFlag i = new TypeMFlag(); public static TypeMFlag get() { return i; diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeMPerm.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeMPerm.java index 6a36fbe2..19d2bf62 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeMPerm.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeMPerm.java @@ -1,8 +1,8 @@ package net.knarcraft.factions.cmd.type; +import com.massivecraft.massivecore.command.type.store.TypeEntity; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPermColl; -import com.massivecraft.massivecore.command.type.store.TypeEntity; import java.util.Collection; @@ -11,7 +11,7 @@ public class TypeMPerm extends TypeEntity { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static TypeMPerm i = new TypeMPerm(); + private static final TypeMPerm i = new TypeMPerm(); public static TypeMPerm get() { return i; diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeMPermable.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeMPermable.java index 8cc68b6d..f8b28bf7 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeMPermable.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeMPermable.java @@ -1,14 +1,14 @@ package net.knarcraft.factions.cmd.type; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.collections.MassiveList; +import com.massivecraft.massivecore.command.type.TypeAbstract; +import com.massivecraft.massivecore.util.MUtil; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.FactionColl; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.Rank; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.collections.MassiveList; -import com.massivecraft.massivecore.command.type.TypeAbstract; -import com.massivecraft.massivecore.util.MUtil; import org.bukkit.command.CommandSender; import java.util.Collection; @@ -20,7 +20,7 @@ public class TypeMPermable extends TypeAbstract { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static TypeMPermable i = new TypeMPermable(); + private static final TypeMPermable i = new TypeMPermable(); public static TypeMPermable get() { return i; @@ -38,9 +38,9 @@ public class TypeMPermable extends TypeAbstract { public TypeMPermable(Faction faction) { super(MPerm.MPermable.class); - if (faction == null) { - throw new NullPointerException("faction"); - } + if (faction == null) { + throw new NullPointerException("faction"); + } this.faction = faction; } @@ -63,7 +63,7 @@ public class TypeMPermable extends TypeAbstract { public MPerm.MPermable read(String arg, CommandSender sender) throws MassiveException { if (arg.toLowerCase().startsWith("rank-")) { String subArg = arg.substring("rank-".length()); - return new TypeRank(this.getFaction()).read(subArg, sender); + return TypeRank.get(this.getFaction(), null).read(subArg, sender); } if (arg.toLowerCase().startsWith("relation-")) { @@ -81,7 +81,7 @@ public class TypeMPermable extends TypeAbstract { return TypeFaction.get().read(subArg, sender); } - TypeRank typeRank = new TypeRank(this.getFaction()); + TypeRank typeRank = TypeRank.get(this.getFaction(), null); try { return typeRank.read(arg, sender); } catch (MassiveException ex) { @@ -112,7 +112,7 @@ public class TypeMPermable extends TypeAbstract { String rankName = arg.substring(idx + 1); Faction faction = TypeFaction.get().read(factionName, sender); - return TypeRank.get(faction).read(rankName, sender); + return TypeRank.get(faction, null).read(rankName, sender); } throw new MassiveException().addMsg("No rank, relation, player or faction matches: %s.", arg); @@ -121,9 +121,9 @@ public class TypeMPermable extends TypeAbstract { public Collection getTabList(CommandSender sender, String arg) { List ret = new MassiveList<>(); Faction faction = this.getFaction(); - if (faction == null) { - faction = MPlayer.get(sender).getFaction(); - } + if (faction == null) { + faction = MPlayer.get(sender).getFaction(); + } // Always add ranks, relations, other factions and other players ret.addAll(faction.getRanks().getAll().stream().map(Rank::getName).collect(Collectors.toList())); @@ -135,12 +135,12 @@ public class TypeMPermable extends TypeAbstract { if (arg.length() >= 2) { for (Faction f : FactionColl.get().getAll()) { String name = f.getName(); - if (arg.length() <= name.length() && !name.toLowerCase().startsWith(arg.toLowerCase())) { - continue; - } - if (arg.length() > name.length() && !arg.toLowerCase().startsWith(name.toLowerCase())) { - continue; - } + if (arg.length() <= name.length() && !name.toLowerCase().startsWith(arg.toLowerCase())) { + continue; + } + if (arg.length() > name.length() && !arg.toLowerCase().startsWith(name.toLowerCase())) { + continue; + } ret.addAll(f.getRanks().getAll().stream().map(r -> name + "-" + r.getName()).collect(Collectors.toList())); } @@ -182,11 +182,11 @@ public class TypeMPermable extends TypeAbstract { @Override public boolean isValid(String arg, CommandSender sender) { // In the generic case accept all - if (this.getFaction() == null) { - return true; - } else { - return super.isValid(arg, sender); - } + if (this.getFaction() == null) { + return true; + } else { + return super.isValid(arg, sender); + } } } diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeMPlayer.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeMPlayer.java index 42d97f1c..c8d1b7c2 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeMPlayer.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeMPlayer.java @@ -1,8 +1,8 @@ package net.knarcraft.factions.cmd.type; +import com.massivecraft.massivecore.command.type.Type; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.MPlayerColl; -import com.massivecraft.massivecore.command.type.Type; public class TypeMPlayer { // -------------------------------------------- // diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeRank.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeRank.java index 69acaf7d..c836d0eb 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeRank.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeRank.java @@ -1,9 +1,9 @@ package net.knarcraft.factions.cmd.type; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.Rank; import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.collections.MassiveSet; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.Rank; import org.bukkit.command.CommandSender; import java.util.Collection; @@ -15,7 +15,7 @@ public class TypeRank extends TypeEntityInternalFaction { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static TypeRank i = new TypeRank(); + private static final TypeRank i = new TypeRank(); public static TypeRank get() { return i; @@ -77,13 +77,13 @@ public class TypeRank extends TypeEntityInternalFaction { if (this.currentRank != null) { // You can't use "promote" to make someone leader. Rank promote = getPromote(currentRank); - if (value == promote && !promote.isLeader()) { - names.add("promote"); - } + if (value == promote && !promote.isLeader()) { + names.add("promote"); + } - if (value == getDemote(currentRank)) { - names.add("demote"); - } + if (value == getDemote(currentRank)) { + names.add("demote"); + } } return names; @@ -92,15 +92,15 @@ public class TypeRank extends TypeEntityInternalFaction { private static Rank getPromote(Rank rank) { Rank ret = null; for (Rank r : rank.getFaction().getRanks().getAll()) { - if (rank == r) { - continue; - } - if (rank.isMoreThan(r)) { - continue; - } - if (ret != null && ret.isLessThan(r)) { - continue; - } + if (rank == r) { + continue; + } + if (rank.isMoreThan(r)) { + continue; + } + if (ret != null && ret.isLessThan(r)) { + continue; + } ret = r; } @@ -110,15 +110,15 @@ public class TypeRank extends TypeEntityInternalFaction { private static Rank getDemote(Rank rank) { Rank ret = null; for (Rank r : rank.getFaction().getRanks().getAll()) { - if (rank == r) { - continue; - } - if (rank.isLessThan(r)) { - continue; - } - if (ret != null && ret.isMoreThan(r)) { - continue; - } + if (rank == r) { + continue; + } + if (rank.isLessThan(r)) { + continue; + } + if (ret != null && ret.isMoreThan(r)) { + continue; + } ret = r; } diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeRel.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeRel.java index 1f3c2cf0..ab377109 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeRel.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeRel.java @@ -1,7 +1,7 @@ package net.knarcraft.factions.cmd.type; -import net.knarcraft.factions.Rel; import com.massivecraft.massivecore.command.type.enumeration.TypeEnum; +import net.knarcraft.factions.Rel; import java.util.Set; @@ -10,7 +10,7 @@ public class TypeRel extends TypeEnum { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static TypeRel i = new TypeRel(); + private static final TypeRel i = new TypeRel(); public static TypeRel get() { return i; diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeRelation.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeRelation.java index b820d712..39a978b3 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeRelation.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeRelation.java @@ -7,7 +7,7 @@ public class TypeRelation extends TypeRel { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static TypeRelation i = new TypeRelation(); + private static final TypeRelation i = new TypeRelation(); public static TypeRelation get() { return i; diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeSortMPlayer.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeSortMPlayer.java index 28b14788..68632d03 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeSortMPlayer.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeSortMPlayer.java @@ -1,10 +1,10 @@ package net.knarcraft.factions.cmd.type; +import com.massivecraft.massivecore.command.type.TypeAbstractChoice; import net.knarcraft.factions.comparator.ComparatorMPlayerInactivity; import net.knarcraft.factions.comparator.ComparatorMPlayerPower; import net.knarcraft.factions.comparator.ComparatorMPlayerRole; import net.knarcraft.factions.entity.MPlayer; -import com.massivecraft.massivecore.command.type.TypeAbstractChoice; import java.util.Comparator; @@ -13,7 +13,7 @@ public class TypeSortMPlayer extends TypeAbstractChoice> { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static TypeSortMPlayer i = new TypeSortMPlayer(); + private static final TypeSortMPlayer i = new TypeSortMPlayer(); public static TypeSortMPlayer get() { return i; diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeTaxable.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeTaxable.java index 1087a218..bfb39861 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeTaxable.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeTaxable.java @@ -1,12 +1,12 @@ package net.knarcraft.factions.cmd.type; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.MPlayer; -import net.knarcraft.factions.entity.Rank; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.command.type.TypeAbstract; import com.massivecraft.massivecore.util.MUtil; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.MPlayer; +import net.knarcraft.factions.entity.Rank; import org.bukkit.command.CommandSender; import java.util.Collection; @@ -19,7 +19,7 @@ public class TypeTaxable extends TypeAbstract { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static TypeTaxable i = new TypeTaxable(); + private static final TypeTaxable i = new TypeTaxable(); public static TypeTaxable get() { return i; @@ -37,9 +37,9 @@ public class TypeTaxable extends TypeAbstract { public TypeTaxable(Faction faction) { super(String.class); - if (faction == null) { - throw new NullPointerException("faction"); - } + if (faction == null) { + throw new NullPointerException("faction"); + } this.faction = faction; } @@ -62,7 +62,7 @@ public class TypeTaxable extends TypeAbstract { public String read(String arg, CommandSender sender) throws MassiveException { if (arg.toLowerCase().startsWith("rank-")) { String subArg = arg.substring("rank-".length()); - return new TypeRank(this.getFaction()).read(subArg, sender).getId(); + return TypeRank.get(this.getFaction(), null).read(subArg, sender).getId(); } if (arg.toLowerCase().startsWith("player-")) { @@ -71,7 +71,7 @@ public class TypeTaxable extends TypeAbstract { } - TypeRank typeRank = new TypeRank(this.getFaction()); + TypeRank typeRank = TypeRank.get(this.getFaction(), null); try { return typeRank.read(arg, sender).getId(); } catch (MassiveException ex) { @@ -90,9 +90,9 @@ public class TypeTaxable extends TypeAbstract { public Collection getTabList(CommandSender sender, String arg) { List ret = new MassiveList<>(); Faction faction = this.getFaction(); - if (faction == null) { - faction = MPlayer.get(sender).getFaction(); - } + if (faction == null) { + faction = MPlayer.get(sender).getFaction(); + } // Always add ranks, relations, other factions and other players ret.addAll(faction.getRanks().getAll().stream().map(Rank::getName).collect(Collectors.toList())); @@ -124,11 +124,11 @@ public class TypeTaxable extends TypeAbstract { @Override public boolean isValid(String arg, CommandSender sender) { // In the generic case accept all - if (this.getFaction() == null) { - return true; - } else { - return super.isValid(arg, sender); - } + if (this.getFaction() == null) { + return true; + } else { + return super.isValid(arg, sender); + } } } diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeVote.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeVote.java index 98e3c281..6a2271fa 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeVote.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeVote.java @@ -10,7 +10,7 @@ public class TypeVote extends TypeEntityInternalFaction { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static TypeVote i = new TypeVote(); + private static final TypeVote i = new TypeVote(); public static TypeVote get() { return i; diff --git a/src/main/java/net/knarcraft/factions/cmd/type/TypeWarp.java b/src/main/java/net/knarcraft/factions/cmd/type/TypeWarp.java index d03d93c5..9b2c5351 100644 --- a/src/main/java/net/knarcraft/factions/cmd/type/TypeWarp.java +++ b/src/main/java/net/knarcraft/factions/cmd/type/TypeWarp.java @@ -10,7 +10,7 @@ public class TypeWarp extends TypeEntityInternalFaction { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static TypeWarp i = new TypeWarp(); + private static final TypeWarp i = new TypeWarp(); public static TypeWarp get() { return i; diff --git a/src/main/java/net/knarcraft/factions/comparator/ComparatorFactionList.java b/src/main/java/net/knarcraft/factions/comparator/ComparatorFactionList.java index 3e753d67..2fb4c761 100644 --- a/src/main/java/net/knarcraft/factions/comparator/ComparatorFactionList.java +++ b/src/main/java/net/knarcraft/factions/comparator/ComparatorFactionList.java @@ -1,9 +1,9 @@ package net.knarcraft.factions.comparator; -import net.knarcraft.factions.entity.Faction; import com.massivecraft.massivecore.comparator.ComparatorAbstract; import com.massivecraft.massivecore.comparator.ComparatorComparable; import com.massivecraft.massivecore.util.IdUtil; +import net.knarcraft.factions.entity.Faction; import org.bukkit.command.CommandSender; import java.lang.ref.WeakReference; @@ -38,27 +38,27 @@ public class ComparatorFactionList extends ComparatorAbstract { @Override public int compareInner(Faction f1, Faction f2) { // None a.k.a. Wilderness - if (f1.isNone() && f2.isNone()) { - return 0; - } - if (f1.isNone()) { - return -1; - } - if (f2.isNone()) { - return 1; - } + if (f1.isNone() && f2.isNone()) { + return 0; + } + if (f1.isNone()) { + return -1; + } + if (f2.isNone()) { + return 1; + } // Players Online int ret = f2.getMPlayersWhereOnlineTo(this.getWatcher()).size() - f1.getMPlayersWhereOnlineTo(this.getWatcher()).size(); - if (ret != 0) { - return ret; - } + if (ret != 0) { + return ret; + } // Players Total ret = f2.getMPlayers().size() - f1.getMPlayers().size(); - if (ret != 0) { - return ret; - } + if (ret != 0) { + return ret; + } // Tie by Id return ComparatorComparable.get().compare(f1.getId(), f2.getId()); diff --git a/src/main/java/net/knarcraft/factions/comparator/ComparatorMPlayerInactivity.java b/src/main/java/net/knarcraft/factions/comparator/ComparatorMPlayerInactivity.java index 301fad23..600bf3bc 100644 --- a/src/main/java/net/knarcraft/factions/comparator/ComparatorMPlayerInactivity.java +++ b/src/main/java/net/knarcraft/factions/comparator/ComparatorMPlayerInactivity.java @@ -1,15 +1,15 @@ package net.knarcraft.factions.comparator; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.Named; import com.massivecraft.massivecore.comparator.ComparatorAbstract; +import net.knarcraft.factions.entity.MPlayer; public class ComparatorMPlayerInactivity extends ComparatorAbstract implements Named { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ComparatorMPlayerInactivity i = new ComparatorMPlayerInactivity(); + private static final ComparatorMPlayerInactivity i = new ComparatorMPlayerInactivity(); public static ComparatorMPlayerInactivity get() { return i; @@ -30,13 +30,13 @@ public class ComparatorMPlayerInactivity extends ComparatorAbstract imp boolean o1 = m1.isOnline(); boolean o2 = m2.isOnline(); - if (o1 && o2) { - return 0; - } else if (o1) { - return -1; - } else if (o2) { - return +1; - } + if (o1 && o2) { + return 0; + } else if (o1) { + return -1; + } else if (o2) { + return +1; + } // Inactivity Time long r1 = m1.getLastActivityMillis(); diff --git a/src/main/java/net/knarcraft/factions/comparator/ComparatorMPlayerPower.java b/src/main/java/net/knarcraft/factions/comparator/ComparatorMPlayerPower.java index d2673c6e..be55a73c 100644 --- a/src/main/java/net/knarcraft/factions/comparator/ComparatorMPlayerPower.java +++ b/src/main/java/net/knarcraft/factions/comparator/ComparatorMPlayerPower.java @@ -1,15 +1,15 @@ package net.knarcraft.factions.comparator; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.Named; import com.massivecraft.massivecore.comparator.ComparatorAbstract; +import net.knarcraft.factions.entity.MPlayer; public class ComparatorMPlayerPower extends ComparatorAbstract implements Named { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ComparatorMPlayerPower i = new ComparatorMPlayerPower(); + private static final ComparatorMPlayerPower i = new ComparatorMPlayerPower(); public static ComparatorMPlayerPower get() { return i; @@ -28,9 +28,9 @@ public class ComparatorMPlayerPower extends ComparatorAbstract implemen public int compareInner(MPlayer m1, MPlayer m2) { // Power int ret = m1.getPowerRounded() - m2.getPowerRounded(); - if (ret != 0) { - return ret; - } + if (ret != 0) { + return ret; + } // MaxPower return m1.getPowerMaxRounded() - m2.getPowerMaxRounded(); diff --git a/src/main/java/net/knarcraft/factions/comparator/ComparatorMPlayerRole.java b/src/main/java/net/knarcraft/factions/comparator/ComparatorMPlayerRole.java index b35812c6..6d7ba8b8 100644 --- a/src/main/java/net/knarcraft/factions/comparator/ComparatorMPlayerRole.java +++ b/src/main/java/net/knarcraft/factions/comparator/ComparatorMPlayerRole.java @@ -1,16 +1,16 @@ package net.knarcraft.factions.comparator; -import net.knarcraft.factions.entity.MPlayer; -import net.knarcraft.factions.entity.Rank; import com.massivecraft.massivecore.Named; import com.massivecraft.massivecore.comparator.ComparatorAbstract; +import net.knarcraft.factions.entity.MPlayer; +import net.knarcraft.factions.entity.Rank; public class ComparatorMPlayerRole extends ComparatorAbstract implements Named { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ComparatorMPlayerRole i = new ComparatorMPlayerRole(); + private static final ComparatorMPlayerRole i = new ComparatorMPlayerRole(); public static ComparatorMPlayerRole get() { return i; @@ -28,9 +28,9 @@ public class ComparatorMPlayerRole extends ComparatorAbstract implement @Override public int compareInner(MPlayer m1, MPlayer m2) { // Rank - if (m1.getFaction() != m2.getFaction()) { - throw new IllegalArgumentException("Noncomparable players"); - } + if (m1.getFaction() != m2.getFaction()) { + throw new IllegalArgumentException("Noncomparable players"); + } Rank r1 = m1.getRank(); Rank r2 = m2.getRank(); return r2.getPriority() - r1.getPriority(); diff --git a/src/main/java/net/knarcraft/factions/engine/EngineCanCombatHappen.java b/src/main/java/net/knarcraft/factions/engine/EngineCanCombatHappen.java index c24ac052..d53d11ed 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineCanCombatHappen.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineCanCombatHappen.java @@ -1,5 +1,8 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.util.MUtil; import net.knarcraft.factions.Rel; import net.knarcraft.factions.entity.BoardColl; import net.knarcraft.factions.entity.Faction; @@ -7,9 +10,6 @@ import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MFlag; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.event.EventFactionsPvpDisallowed; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.ps.PS; -import com.massivecraft.massivecore.util.MUtil; import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -32,7 +32,7 @@ public class EngineCanCombatHappen extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineCanCombatHappen i = new EngineCanCombatHappen(); + private static final EngineCanCombatHappen i = new EngineCanCombatHappen(); public static EngineCanCombatHappen get() { return i; @@ -44,9 +44,9 @@ public class EngineCanCombatHappen extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void canCombatDamageHappen(EntityDamageByEntityEvent event) { - if (this.canCombatDamageHappen(event, true)) { - return; - } + if (this.canCombatDamageHappen(event, true)) { + return; + } event.setCancelled(true); Entity damager = event.getDamager(); @@ -61,32 +61,30 @@ public class EngineCanCombatHappen extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void canCombatDamageHappen(EntityCombustByEntityEvent event) { EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE, 0D); - if (this.canCombatDamageHappen(sub, false)) { - return; - } + if (this.canCombatDamageHappen(sub, false)) { + return; + } event.setCancelled(true); } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void canCombatDamageHappen(PotionSplashEvent event) { // If a harmful potion is splashing ... - if (!MUtil.isHarmfulPotion(event.getPotion())) { - return; - } + if (!MUtil.isHarmfulPotion(event.getPotion())) { + return; + } ProjectileSource projectileSource = event.getPotion().getShooter(); - if (!(projectileSource instanceof Entity)) { - return; - } - - Entity thrower = (Entity) projectileSource; + if (!(projectileSource instanceof Entity thrower)) { + return; + } // ... scan through affected entities to make sure they're all valid targets. for (LivingEntity affectedEntity : event.getAffectedEntities()) { EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(thrower, affectedEntity, EntityDamageEvent.DamageCause.CUSTOM, 0D); - if (this.canCombatDamageHappen(sub, true)) { - continue; - } + if (this.canCombatDamageHappen(sub, true)) { + continue; + } // affected entity list doesn't accept modification (iter.remove() is a no-go), but this works event.setIntensity(affectedEntity, 0.0); @@ -96,16 +94,14 @@ public class EngineCanCombatHappen extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void canCombatDamageHappen(AreaEffectCloudApplyEvent event) { // If a harmful potion effect cloud is present ... - if (!MUtil.isHarmfulPotion(event.getEntity().getBasePotionData().getType().getEffectType())) { - return; - } + if (!MUtil.isHarmfulPotion(event.getEntity().getBasePotionData().getType().getEffectType())) { + return; + } ProjectileSource projectileSource = event.getEntity().getSource(); - if (!(projectileSource instanceof Entity)) { - return; - } - - Entity thrower = (Entity) projectileSource; + if (!(projectileSource instanceof Entity thrower)) { + return; + } // ... create a dummy list to avoid ConcurrentModificationException ... List affectedList = new ArrayList<>(); @@ -114,9 +110,9 @@ public class EngineCanCombatHappen extends Engine { for (LivingEntity affectedEntity : event.getAffectedEntities()) { EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(thrower, affectedEntity, EntityDamageEvent.DamageCause.CUSTOM, 0D); // Notification disabled due to the iterating nature of effect clouds. - if (EngineCanCombatHappen.get().canCombatDamageHappen(sub, false)) { - continue; - } + if (EngineCanCombatHappen.get().canCombatDamageHappen(sub, false)) { + continue; + } affectedList.add(affectedEntity); } @@ -137,9 +133,9 @@ public class EngineCanCombatHappen extends Engine { // If the defender is a player ... Entity edefender = event.getEntity(); - if (MUtil.isntPlayer(edefender)) { - return true; - } + if (MUtil.isntPlayer(edefender)) { + return true; + } Player defender = (Player) edefender; MPlayer mdefender = MPlayer.get(edefender); @@ -148,9 +144,9 @@ public class EngineCanCombatHappen extends Engine { // (we check null here since there may not be an attacker) // (lack of attacker situations can be caused by other bukkit plugins) - if (eattacker != null && eattacker.equals(edefender)) { - return true; - } + if (eattacker != null && eattacker.equals(edefender)) { + return true; + } // ... gather defender PS and faction information ... PS defenderPs = PS.valueOf(defender.getLocation()); @@ -160,13 +156,13 @@ public class EngineCanCombatHappen extends Engine { if (MUtil.isPlayer(eattacker)) { MPlayer mplayer = MPlayer.get(eattacker); - if (mplayer != null && mplayer.isOverriding()) { - return true; - } + if (mplayer != null && mplayer.isOverriding()) { + return true; + } } // ... PVP flag may cause a damage block ... - if (defenderPsFaction.getFlag(MFlag.getFlagPvp()) == false) { + if (!defenderPsFaction.getFlag(MFlag.getFlagPvp())) { if (eattacker == null) { // No attacker? // Let's behave as if it were a player @@ -184,16 +180,16 @@ public class EngineCanCombatHappen extends Engine { } // ... and if the attacker is a player ... - if (MUtil.isntPlayer(eattacker)) { - return true; - } + if (MUtil.isntPlayer(eattacker)) { + return true; + } Player attacker = (Player) eattacker; MPlayer uattacker = MPlayer.get(attacker); // ... does this player bypass all protection? ... - if (MConf.get().playersWhoBypassAllProtection.contains(attacker.getName())) { - return true; - } + if (MConf.get().playersWhoBypassAllProtection.contains(attacker.getName())) { + return true; + } // ... gather attacker PS and faction information ... PS attackerPs = PS.valueOf(attacker.getLocation()); @@ -202,27 +198,27 @@ public class EngineCanCombatHappen extends Engine { // ... PVP flag may cause a damage block ... // (just checking the defender as above isn't enough. What about the attacker? It could be in a no-pvp area) // NOTE: This check is probably not that important but we could keep it anyways. - if (attackerPsFaction.getFlag(MFlag.getFlagPvp()) == false) { + if (!attackerPsFaction.getFlag(MFlag.getFlagPvp())) { ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, DisallowCause.PEACEFUL_LAND, event); - if (!ret && notify) { - uattacker.msg("PVP is disabled in %s.", attackerPsFaction.describeTo(uattacker)); - } + if (!ret && notify) { + uattacker.msg("PVP is disabled in %s.", attackerPsFaction.describeTo(uattacker)); + } return ret; } // ... are PVP rules completely ignored in this world? ... - if (!MConf.get().worldsPvpRulesEnabled.contains(defenderPs.getWorld())) { - return true; - } + if (!MConf.get().worldsPvpRulesEnabled.contains(defenderPs.getWorld())) { + return true; + } Faction defendFaction = mdefender.getFaction(); Faction attackFaction = uattacker.getFaction(); if (attackFaction.isNone() && MConf.get().disablePVPForFactionlessPlayers) { ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, DisallowCause.FACTIONLESS, event); - if (!ret && notify) { - uattacker.msg("You can't hurt other players until you join a faction."); - } + if (!ret && notify) { + uattacker.msg("You can't hurt other players until you join a faction."); + } return ret; } else if (defendFaction.isNone()) { if (defenderPsFaction == attackFaction && MConf.get().enablePVPAgainstFactionlessInAttackersLand) { @@ -230,9 +226,9 @@ public class EngineCanCombatHappen extends Engine { return true; } else if (MConf.get().disablePVPForFactionlessPlayers) { ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, DisallowCause.FACTIONLESS, event); - if (!ret && notify) { - uattacker.msg("You can't hurt players who are not currently in a faction."); - } + if (!ret && notify) { + uattacker.msg("You can't hurt players who are not currently in a faction."); + } return ret; } else if (attackFaction.isNone() && MConf.get().enablePVPBetweenFactionlessPlayers) { // Allow factionless vs factionless @@ -243,11 +239,11 @@ public class EngineCanCombatHappen extends Engine { Rel relation = defendFaction.getRelationTo(attackFaction); // Check the relation - if (relation.isFriend() && defenderPsFaction.getFlag(MFlag.getFlagFriendlyire()) == false) { + if (relation.isFriend() && !defenderPsFaction.getFlag(MFlag.getFlagFriendlyire())) { ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, DisallowCause.FRIENDLYFIRE, event); - if (!ret && notify) { - uattacker.msg("You can't hurt %s.", relation.getDescPlayerMany()); - } + if (!ret && notify) { + uattacker.msg("You can't hurt %s.", relation.getDescPlayerMany()); + } return ret; } diff --git a/src/main/java/net/knarcraft/factions/engine/EngineChat.java b/src/main/java/net/knarcraft/factions/engine/EngineChat.java index 7ca6fbb7..382c4275 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineChat.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineChat.java @@ -1,5 +1,8 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.event.EventMassiveCorePlayerToRecipientChat; +import com.massivecraft.massivecore.util.MUtil; import net.knarcraft.factions.Factions; import net.knarcraft.factions.Rel; import net.knarcraft.factions.RelationParticipator; @@ -7,9 +10,6 @@ import net.knarcraft.factions.chat.ChatFormatter; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPlayer; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.event.EventMassiveCorePlayerToRecipientChat; -import com.massivecraft.massivecore.util.MUtil; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.Event; @@ -18,6 +18,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.plugin.EventExecutor; +import org.jetbrains.annotations.NotNull; import java.util.Iterator; import java.util.function.Predicate; @@ -27,7 +28,7 @@ public class EngineChat extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineChat i = new EngineChat(); + private static final EngineChat i = new EngineChat(); public static EngineChat get() { return i; @@ -64,9 +65,9 @@ public class EngineChat extends Engine { // SET FORMAT // -------------------------------------------- // - private class SetFormatEventExecutor implements EventExecutor { + private static class SetFormatEventExecutor implements EventExecutor { @Override - public void execute(Listener listener, Event event) throws EventException { + public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException { try { if (!(event instanceof AsyncPlayerChatEvent)) { return; @@ -86,9 +87,9 @@ public class EngineChat extends Engine { // PARSE TAGS // -------------------------------------------- // - private class ParseTagsEventExecutor implements EventExecutor { + private static class ParseTagsEventExecutor implements EventExecutor { @Override - public void execute(Listener listener, Event event) throws EventException { + public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException { try { if (!(event instanceof AsyncPlayerChatEvent)) { return; @@ -115,9 +116,9 @@ public class EngineChat extends Engine { // PARSE RELCOLOR // -------------------------------------------- // - private class ParseRelcolorEventExecutor implements EventExecutor { + private static class ParseRelcolorEventExecutor implements EventExecutor { @Override - public void execute(Listener listener, Event event) throws EventException { + public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException { try { if (!(event instanceof EventMassiveCorePlayerToRecipientChat)) { return; diff --git a/src/main/java/net/knarcraft/factions/engine/EngineChunkChange.java b/src/main/java/net/knarcraft/factions/engine/EngineChunkChange.java index 4be881fd..6cdf4df9 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineChunkChange.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineChunkChange.java @@ -1,5 +1,11 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.collections.MassiveList; +import com.massivecraft.massivecore.collections.MassiveSet; +import com.massivecraft.massivecore.mixin.MixinWorld; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.Rel; import net.knarcraft.factions.entity.BoardColl; import net.knarcraft.factions.entity.Faction; @@ -9,12 +15,6 @@ import net.knarcraft.factions.entity.MFlag; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.event.EventFactionsChunksChange; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.collections.MassiveList; -import com.massivecraft.massivecore.collections.MassiveSet; -import com.massivecraft.massivecore.mixin.MixinWorld; -import com.massivecraft.massivecore.ps.PS; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -30,7 +30,7 @@ public class EngineChunkChange extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineChunkChange i = new EngineChunkChange(); + private static final EngineChunkChange i = new EngineChunkChange(); public static EngineChunkChange get() { return i; @@ -60,9 +60,9 @@ public class EngineChunkChange extends Engine { final Set chunks = event.getChunks(); // Override Mode? Sure! - if (mplayer.isOverriding()) { - return; - } + if (mplayer.isOverriding()) { + return; + } // CALC: Is there at least one normal faction among the current ones? boolean currentFactionsContainsAtLeastOneNormal = false; @@ -156,9 +156,9 @@ public class EngineChunkChange extends Engine { // HOW: Next we check if the new faction has permission to claim nearby the nearby factions. MPerm claimnear = MPerm.getPermClaimnear(); for (Faction nearbyFaction : nearbyFactions) { - if (claimnear.has(mplayer, nearbyFaction, true)) { - continue; - } + if (claimnear.has(mplayer, nearbyFaction, true)) { + continue; + } event.setCancelled(true); return; } @@ -217,14 +217,14 @@ public class EngineChunkChange extends Engine { Set oldChunks = entry.getValue(); // ... that is an actual faction ... - if (oldFaction.isNone()) { - continue; - } + if (oldFaction.isNone()) { + continue; + } // ... for which the mplayer lacks permission ... - if (MPerm.getPermTerritory().has(mplayer, oldFaction, false)) { - continue; - } + if (MPerm.getPermTerritory().has(mplayer, oldFaction, false)) { + continue; + } // ... consider all reasons to forbid "overclaiming/warclaiming" ... diff --git a/src/main/java/net/knarcraft/factions/engine/EngineCleanInactivity.java b/src/main/java/net/knarcraft/factions/engine/EngineCleanInactivity.java index a80dc1ed..19538e55 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineCleanInactivity.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineCleanInactivity.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.event.EventMassiveCorePlayerCleanInactivityToleranceMillis; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.MPlayerColl; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.event.EventMassiveCorePlayerCleanInactivityToleranceMillis; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -17,7 +17,7 @@ public class EngineCleanInactivity extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineCleanInactivity i = new EngineCleanInactivity(); + private static final EngineCleanInactivity i = new EngineCleanInactivity(); public static EngineCleanInactivity get() { return i; @@ -29,9 +29,9 @@ public class EngineCleanInactivity extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void ageBonus(EventMassiveCorePlayerCleanInactivityToleranceMillis event) { - if (event.getColl() != MPlayerColl.get()) { - return; - } + if (event.getColl() != MPlayerColl.get()) { + return; + } applyPlayerAgeBonus(event); applyFactionAgeBonus(event); @@ -40,16 +40,16 @@ public class EngineCleanInactivity extends Engine { public void applyPlayerAgeBonus(EventMassiveCorePlayerCleanInactivityToleranceMillis event) { // Calculate First Played Long firstPlayed = event.getEntity().getFirstPlayed(); - Long age = 0L; + long age = 0L; if (firstPlayed != null) { age = System.currentTimeMillis() - firstPlayed; } // Calculate the Bonus! Long bonus = calculateBonus(age, MConf.get().cleanInactivityToleranceMillisPlayerAgeToBonus); - if (bonus == null) { - return; - } + if (bonus == null) { + return; + } // Apply event.getToleranceCauseMillis().put("Player Age Bonus", bonus); @@ -65,30 +65,30 @@ public class EngineCleanInactivity extends Engine { // Calculate the Bonus! Long bonus = calculateBonus(age, MConf.get().cleanInactivityToleranceMillisFactionAgeToBonus); - if (bonus == null) { - return; - } + if (bonus == null) { + return; + } // Apply event.getToleranceCauseMillis().put("Faction Age Bonus", bonus); } private Long calculateBonus(long age, Map ageToBonus) { - if (ageToBonus.isEmpty()) { - return null; - } + if (ageToBonus.isEmpty()) { + return null; + } - Long bonus = 0L; + long bonus = 0L; for (Entry entry : ageToBonus.entrySet()) { Long key = entry.getKey(); - if (key == null) { - continue; - } + if (key == null) { + continue; + } Long value = entry.getValue(); - if (value == null) { - continue; - } + if (value == null) { + continue; + } if (age >= key) { bonus = value; diff --git a/src/main/java/net/knarcraft/factions/engine/EngineDenyCommands.java b/src/main/java/net/knarcraft/factions/engine/EngineDenyCommands.java index 2d6d9a7e..ca47e20f 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineDenyCommands.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineDenyCommands.java @@ -1,15 +1,15 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.util.MUtil; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.Rel; import net.knarcraft.factions.entity.BoardColl; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MFlag; import net.knarcraft.factions.entity.MPlayer; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.ps.PS; -import com.massivecraft.massivecore.util.MUtil; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -22,7 +22,7 @@ public class EngineDenyCommands extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineDenyCommands i = new EngineDenyCommands(); + private static final EngineDenyCommands i = new EngineDenyCommands(); public static EngineDenyCommands get() { return i; @@ -36,15 +36,15 @@ public class EngineDenyCommands extends Engine { public void denyCommands(PlayerCommandPreprocessEvent event) { // If a player is trying to run a command ... Player player = event.getPlayer(); - if (MUtil.isntPlayer(player)) { - return; - } + if (MUtil.isntPlayer(player)) { + return; + } MPlayer mplayer = MPlayer.get(player); // ... and the player is not overriding ... - if (mplayer.isOverriding()) { - return; - } + if (mplayer.isOverriding()) { + return; + } // ... clean up the command ... String command = event.getMessage(); @@ -72,19 +72,19 @@ public class EngineDenyCommands extends Engine { if (MConf.get().denyCommandsDistance > -1 && !MConf.get().denyCommandsDistanceBypassIn.contains(factionAtRel)) { for (Player otherplayer : player.getWorld().getPlayers()) { MPlayer othermplayer = MPlayer.get(otherplayer); - if (othermplayer == mplayer) { - continue; - } + if (othermplayer == mplayer) { + continue; + } double distance = player.getLocation().distance(otherplayer.getLocation()); - if (MConf.get().denyCommandsDistance > distance) { - continue; - } + if (MConf.get().denyCommandsDistance > distance) { + continue; + } Rel playerRel = mplayer.getRelationTo(othermplayer); - if (!MConf.get().denyCommandsDistanceRelation.containsKey(playerRel)) { - continue; - } + if (!MConf.get().denyCommandsDistanceRelation.containsKey(playerRel)) { + continue; + } String desc = playerRel.getDescPlayerOne(); @@ -95,17 +95,17 @@ public class EngineDenyCommands extends Engine { } // ... if there is no relation here then there are no further checks ... - if (factionAtRel == null) { - return; - } + if (factionAtRel == null) { + return; + } List deniedCommands = MConf.get().denyCommandsTerritoryRelation.get(factionAtRel); - if (deniedCommands == null) { - return; - } - if (!MUtil.containsCommand(command, deniedCommands)) { - return; - } + if (deniedCommands == null) { + return; + } + if (!MUtil.containsCommand(command, deniedCommands)) { + return; + } mplayer.msg("You can't use \"/%s\" in %s territory.", command, Txt.getNicedEnum(factionAtRel)); event.setCancelled(true); diff --git a/src/main/java/net/knarcraft/factions/engine/EngineDenyTeleport.java b/src/main/java/net/knarcraft/factions/engine/EngineDenyTeleport.java index 8614ef06..5b24149c 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineDenyTeleport.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineDenyTeleport.java @@ -1,16 +1,16 @@ package net.knarcraft.factions.engine; -import net.knarcraft.factions.Rel; -import net.knarcraft.factions.entity.BoardColl; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.MConf; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.Couple; import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.mixin.MixinMessage; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.Rel; +import net.knarcraft.factions.entity.BoardColl; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.MConf; +import net.knarcraft.factions.entity.MPlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -25,7 +25,7 @@ public class EngineDenyTeleport extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineDenyTeleport i = new EngineDenyTeleport(); + private static final EngineDenyTeleport i = new EngineDenyTeleport(); public static EngineDenyTeleport get() { return i; @@ -45,9 +45,9 @@ public class EngineDenyTeleport extends Engine { @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void canTeleportHappen(PlayerTeleportEvent event) { Entry entry = shouldBeCancelled(event); - if (entry == null) { - return; - } + if (entry == null) { + return; + } event.setCancelled(true); @@ -56,18 +56,18 @@ public class EngineDenyTeleport extends Engine { String teleportDesc = Txt.getNicedEnum(cause); String denyDesc = ""; - if (deny == TerritoryType.ENEMY) { - denyDesc = "enemy"; - } - if (deny == TerritoryType.WILDERNESS) { - denyDesc = "wilderness"; - } - if (deny == TerritoryType.OWN) { - denyDesc = "your own"; - } - if (deny == TerritoryType.OTHER) { - denyDesc = "other faction's"; - } + if (deny == TerritoryType.ENEMY) { + denyDesc = "enemy"; + } + if (deny == TerritoryType.WILDERNESS) { + denyDesc = "wilderness"; + } + if (deny == TerritoryType.OWN) { + denyDesc = "your own"; + } + if (deny == TerritoryType.OTHER) { + denyDesc = "other faction's"; + } Player player = event.getPlayer(); MixinMessage.get().msgOne(player, "Teleportation with %s is not allowed in %s territory.", teleportDesc, denyDesc); @@ -75,9 +75,9 @@ public class EngineDenyTeleport extends Engine { private Entry shouldBeCancelled(PlayerTeleportEvent event) { Player player = event.getPlayer(); - if (MUtil.isntPlayer(player)) { - return null; - } + if (MUtil.isntPlayer(player)) { + return null; + } MPlayer mplayer = MPlayer.get(player); @@ -92,40 +92,39 @@ public class EngineDenyTeleport extends Engine { MConf mconf = MConf.get(); if (cause == TeleportCause.CHORUS_FRUIT) { - if (!mconf.allowChorusFruitInEnemyTerritory && types.contains(TerritoryType.ENEMY)) { - return Couple.valueOf(cause, TerritoryType.ENEMY); - } + if (!mconf.allowChorusFruitInEnemyTerritory && types.contains(TerritoryType.ENEMY)) { + return Couple.valueOf(cause, TerritoryType.ENEMY); + } - if (!mconf.allowChorusFruitInWildernessTerritory && types.contains(TerritoryType.WILDERNESS)) { - return Couple.valueOf(cause, TerritoryType.WILDERNESS); - } + if (!mconf.allowChorusFruitInWildernessTerritory && types.contains(TerritoryType.WILDERNESS)) { + return Couple.valueOf(cause, TerritoryType.WILDERNESS); + } - if (!mconf.allowChorusFruitInOwnTerritory && types.contains(TerritoryType.OWN)) { - return Couple.valueOf(cause, TerritoryType.OWN); - } + if (!mconf.allowChorusFruitInOwnTerritory && types.contains(TerritoryType.OWN)) { + return Couple.valueOf(cause, TerritoryType.OWN); + } - if (!mconf.allowChorusFruitInOtherTerritory && types.contains(TerritoryType.OTHER)) { - return Couple.valueOf(cause, TerritoryType.OTHER); - } + if (!mconf.allowChorusFruitInOtherTerritory && types.contains(TerritoryType.OTHER)) { + return Couple.valueOf(cause, TerritoryType.OTHER); + } } else if (cause == TeleportCause.ENDER_PEARL) { - if (!mconf.allowEnderPearlInEnemyTerritory && types.contains(TerritoryType.ENEMY)) { - return Couple.valueOf(cause, TerritoryType.ENEMY); - } + if (!mconf.allowEnderPearlInEnemyTerritory && types.contains(TerritoryType.ENEMY)) { + return Couple.valueOf(cause, TerritoryType.ENEMY); + } - if (!mconf.allowEnderPearlInWildernessTerritory && types.contains(TerritoryType.WILDERNESS)) { - return Couple.valueOf(cause, TerritoryType.WILDERNESS); - } + if (!mconf.allowEnderPearlInWildernessTerritory && types.contains(TerritoryType.WILDERNESS)) { + return Couple.valueOf(cause, TerritoryType.WILDERNESS); + } - if (!mconf.allowEnderPearlInOwnTerritory && types.contains(TerritoryType.OWN)) { - return Couple.valueOf(cause, TerritoryType.OWN); - } + if (!mconf.allowEnderPearlInOwnTerritory && types.contains(TerritoryType.OWN)) { + return Couple.valueOf(cause, TerritoryType.OWN); + } + + if (!mconf.allowEnderPearlInOtherTerritory && types.contains(TerritoryType.OTHER)) { + return Couple.valueOf(cause, TerritoryType.OTHER); + } + } // Don't cancel other kinds of teleports - if (!mconf.allowEnderPearlInOtherTerritory && types.contains(TerritoryType.OTHER)) { - return Couple.valueOf(cause, TerritoryType.OTHER); - } - } else { - // Don't cancel other kinds of teleports - } return null; } @@ -134,15 +133,15 @@ public class EngineDenyTeleport extends Engine { Faction territoryFaction = BoardColl.get().getFactionAt(territory); Rel relation = territoryFaction.getRelationTo(mplayer); - if (territoryFaction.isNone()) { - return TerritoryType.WILDERNESS; - } - if (relation == Rel.ENEMY) { - return TerritoryType.ENEMY; - } - if (relation == Rel.FACTION) { - return TerritoryType.OWN; - } + if (territoryFaction.isNone()) { + return TerritoryType.WILDERNESS; + } + if (relation == Rel.ENEMY) { + return TerritoryType.ENEMY; + } + if (relation == Rel.FACTION) { + return TerritoryType.OWN; + } return TerritoryType.OTHER; } diff --git a/src/main/java/net/knarcraft/factions/engine/EngineEcon.java b/src/main/java/net/knarcraft/factions/engine/EngineEcon.java index b064705a..a525f6d3 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineEcon.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineEcon.java @@ -1,5 +1,9 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.Factions; import net.knarcraft.factions.cmd.CmdFactions; import net.knarcraft.factions.entity.Faction; @@ -22,10 +26,6 @@ import net.knarcraft.factions.event.EventFactionsWarpAdd; import net.knarcraft.factions.event.EventFactionsWarpRemove; import net.knarcraft.factions.event.EventFactionsWarpTeleport; import net.knarcraft.factions.integration.Econ; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.money.Money; -import com.massivecraft.massivecore.ps.PS; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -39,7 +39,7 @@ public class EngineEcon extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineEcon i = new EngineEcon(); + private static final EngineEcon i = new EngineEcon(); public static EngineEcon get() { return i; diff --git a/src/main/java/net/knarcraft/factions/engine/EngineExploit.java b/src/main/java/net/knarcraft/factions/engine/EngineExploit.java index 857ecd70..55764719 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineExploit.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineExploit.java @@ -1,10 +1,10 @@ package net.knarcraft.factions.engine; -import net.knarcraft.factions.entity.MConf; import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.MUtil; +import net.knarcraft.factions.entity.MConf; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; @@ -26,7 +26,7 @@ public class EngineExploit extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineExploit i = new EngineExploit(); + private static final EngineExploit i = new EngineExploit(); public static EngineExploit get() { return i; @@ -38,9 +38,9 @@ public class EngineExploit extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void obsidianGenerators(BlockFromToEvent event) { - if (!MConf.get().handleExploitObsidianGenerators) { - return; - } + if (!MConf.get().handleExploitObsidianGenerators) { + return; + } // thanks to ObGenBlocker and WorldGuard for this method Block block = event.getToBlock(); @@ -57,12 +57,12 @@ public class EngineExploit extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void enderPearlClipping(PlayerTeleportEvent event) { - if (!MConf.get().handleExploitEnderPearlClipping) { - return; - } - if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) { - return; - } + if (!MConf.get().handleExploitEnderPearlClipping) { + return; + } + if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) { + return; + } // this exploit works when the target location is within 0.31 blocks or so of a door or glass block or similar... Location target = event.getTo(); @@ -104,31 +104,31 @@ public class EngineExploit extends Engine { private static final int NETHER_TRAP_RADIUS_CHECK = 5; private static final int NETHER_TRAP_RESET_RADIUS_SQUARED = 9; - private HashMap> portalTraps = new HashMap<>(); + private final HashMap> portalTraps = new HashMap<>(); @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void portalTrapRemoveAnimation(PlayerTeleportEvent event) { // If there is a teleport caused by a nether portal ... - if (!MConf.get().handleNetherPortalTrap || event.getCause() != TeleportCause.NETHER_PORTAL) { - return; - } + if (!MConf.get().handleNetherPortalTrap || event.getCause() != TeleportCause.NETHER_PORTAL) { + return; + } Player player = event.getPlayer(); Block from = event.getTo().getBlock(); // ... and the player can't build at the destination ... - if (EnginePermBuild.canPlayerBuildAt(player, PS.valueOf(from), false)) { - return; - } + if (EnginePermBuild.canPlayerBuildAt(player, PS.valueOf(from), false)) { + return; + } // ... reset the old portal blocks stored ... this.portalReset(player); // ... get all the portal blocks belonging to the new portal at the destination ... List portalTrap = getPortal(from); - if (portalTrap.isEmpty()) { - return; - } + if (portalTrap.isEmpty()) { + return; + } // ... and then store those blocks and send an update as if they were air. this.portalTraps.put(player.getUniqueId(), portalTrap); @@ -138,18 +138,18 @@ public class EngineExploit extends Engine { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void portalUpdate(PlayerMoveEvent event) { // If a player moves ... - if (!MConf.get().handleNetherPortalTrap || MUtil.isSameBlock(event)) { - return; - } + if (!MConf.get().handleNetherPortalTrap || MUtil.isSameBlock(event)) { + return; + } Player player = event.getPlayer(); UUID uuid = player.getUniqueId(); // ... and he recently used a portal ... List portalTrap = this.portalTraps.get(uuid); - if (portalTrap == null) { - return; - } + if (portalTrap == null) { + return; + } Location locationTo = event.getTo(); Location locationFrom = portalTrap.get(0).getLocation(); @@ -172,17 +172,17 @@ public class EngineExploit extends Engine { // If a player has already a portal registered to him ... List portalTrap = this.portalTraps.get(uuid); - if (portalTrap == null) { - return; - } + if (portalTrap == null) { + return; + } // ... remove them from the registry ... this.portalTraps.remove(uuid); // ... and send updates if the player and portal are in the same world. - if (!player.getWorld().equals(portalTrap.get(0).getWorld())) { - return; - } + if (!player.getWorld().equals(portalTrap.get(0).getWorld())) { + return; + } portalUpdateReset(player, portalTrap); } @@ -212,9 +212,9 @@ public class EngineExploit extends Engine { for (int x = -(NETHER_TRAP_RADIUS_CHECK); x <= NETHER_TRAP_RADIUS_CHECK; x++) { for (int y = -(NETHER_TRAP_RADIUS_CHECK); y <= NETHER_TRAP_RADIUS_CHECK; y++) { for (int z = -(NETHER_TRAP_RADIUS_CHECK); z <= NETHER_TRAP_RADIUS_CHECK; z++) { - if (from.getRelative(x, y, z).getType() == Material.NETHER_PORTAL) { - ret.add(from.getRelative(x, y, z)); - } + if (from.getRelative(x, y, z).getType() == Material.NETHER_PORTAL) { + ret.add(from.getRelative(x, y, z)); + } } } } diff --git a/src/main/java/net/knarcraft/factions/engine/EngineFlagEndergrief.java b/src/main/java/net/knarcraft/factions/engine/EngineFlagEndergrief.java index 9790df27..7a7a82c2 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineFlagEndergrief.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineFlagEndergrief.java @@ -1,10 +1,10 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.ps.PS; import net.knarcraft.factions.entity.BoardColl; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MFlag; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.ps.PS; import org.bukkit.entity.Enderman; import org.bukkit.entity.Entity; import org.bukkit.event.EventHandler; @@ -16,7 +16,7 @@ public class EngineFlagEndergrief extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineFlagEndergrief i = new EngineFlagEndergrief(); + private static final EngineFlagEndergrief i = new EngineFlagEndergrief(); public static EngineFlagEndergrief get() { return i; @@ -30,16 +30,16 @@ public class EngineFlagEndergrief extends Engine { public void blockEndergrief(EntityChangeBlockEvent event) { // If an enderman is changing a block ... Entity entity = event.getEntity(); - if (!(entity instanceof Enderman)) { - return; - } + if (!(entity instanceof Enderman)) { + return; + } // ... and the faction there has endergrief disabled ... PS ps = PS.valueOf(event.getBlock()); Faction faction = BoardColl.get().getFactionAt(ps); - if (faction.getFlag(MFlag.getFlagEndergrief())) { - return; - } + if (faction.getFlag(MFlag.getFlagEndergrief())) { + return; + } // ... stop the block alteration. event.setCancelled(true); diff --git a/src/main/java/net/knarcraft/factions/engine/EngineFlagExplosion.java b/src/main/java/net/knarcraft/factions/engine/EngineFlagExplosion.java index 60290755..a1706b77 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineFlagExplosion.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineFlagExplosion.java @@ -1,10 +1,10 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.ps.PS; import net.knarcraft.factions.entity.BoardColl; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.util.EnumerationUtil; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.ps.PS; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Entity; @@ -32,7 +32,7 @@ public class EngineFlagExplosion extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineFlagExplosion i = new EngineFlagExplosion(); + private static final EngineFlagExplosion i = new EngineFlagExplosion(); public static EngineFlagExplosion get() { return i; @@ -42,21 +42,21 @@ public class EngineFlagExplosion extends Engine { // FLAG: EXPLOSIONS // -------------------------------------------- // - protected Set DAMAGE_CAUSE_EXPLOSIONS = EnumSet.of(DamageCause.BLOCK_EXPLOSION, DamageCause.ENTITY_EXPLOSION); + protected final Set DAMAGE_CAUSE_EXPLOSIONS = EnumSet.of(DamageCause.BLOCK_EXPLOSION, DamageCause.ENTITY_EXPLOSION); @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockExplosion(HangingBreakEvent event) { // If a hanging entity was broken by an explosion ... - if (event.getCause() != RemoveCause.EXPLOSION) { - return; - } + if (event.getCause() != RemoveCause.EXPLOSION) { + return; + } Entity entity = event.getEntity(); // ... and the faction there has explosions disabled ... Faction faction = BoardColl.get().getFactionAt(PS.valueOf(entity.getLocation())); - if (faction.isExplosionsAllowed()) { - return; - } + if (faction.isExplosionsAllowed()) { + return; + } // ... then cancel. event.setCancelled(true); @@ -65,19 +65,19 @@ public class EngineFlagExplosion extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockExplosion(EntityDamageEvent event) { // If an explosion damages ... - if (!DAMAGE_CAUSE_EXPLOSIONS.contains(event.getCause())) { - return; - } + if (!DAMAGE_CAUSE_EXPLOSIONS.contains(event.getCause())) { + return; + } // ... an entity that is modified on damage ... - if (!EnumerationUtil.isEntityTypeEditOnDamage(event.getEntityType())) { - return; - } + if (!EnumerationUtil.isEntityTypeEditOnDamage(event.getEntityType())) { + return; + } // ... and the faction has explosions disabled ... - if (BoardColl.get().getFactionAt(PS.valueOf(event.getEntity())).isExplosionsAllowed()) { - return; - } + if (BoardColl.get().getFactionAt(PS.valueOf(event.getEntity())).isExplosionsAllowed()) { + return; + } // ... then cancel! event.setCancelled(true); @@ -86,10 +86,9 @@ public class EngineFlagExplosion extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockExplosion(EntityExplodeEvent event) { Location location = event.getLocation(); - Cancellable cancellable = event; Collection blocks = event.blockList(); - blockExplosion(location, cancellable, blocks); + blockExplosion(location, event, blocks); } // Note that this method is used by EngineV18 for the BlockExplodeEvent @@ -117,9 +116,9 @@ public class EngineFlagExplosion extends Engine { faction2allowed.put(faction, allowed); } - if (!allowed) { - iterator.remove(); - } + if (!allowed) { + iterator.remove(); + } } } @@ -127,17 +126,17 @@ public class EngineFlagExplosion extends Engine { public void blockExplosion(EntityChangeBlockEvent event) { // If a wither is changing a block ... Entity entity = event.getEntity(); - if (!(entity instanceof Wither)) { - return; - } + if (!(entity instanceof Wither)) { + return; + } // ... and the faction there has explosions disabled ... PS ps = PS.valueOf(event.getBlock()); Faction faction = BoardColl.get().getFactionAt(ps); - if (faction.isExplosionsAllowed()) { - return; - } + if (faction.isExplosionsAllowed()) { + return; + } // ... stop the block alteration. event.setCancelled(true); @@ -146,10 +145,9 @@ public class EngineFlagExplosion extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockExplosion(BlockExplodeEvent event) { Location location = event.getBlock().getLocation(); - Cancellable cancellable = event; Collection blocks = event.blockList(); - EngineFlagExplosion.get().blockExplosion(location, cancellable, blocks); + EngineFlagExplosion.get().blockExplosion(location, event, blocks); } } diff --git a/src/main/java/net/knarcraft/factions/engine/EngineFlagFireSpread.java b/src/main/java/net/knarcraft/factions/engine/EngineFlagFireSpread.java index 218c97bc..810d63f0 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineFlagFireSpread.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineFlagFireSpread.java @@ -1,10 +1,10 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.ps.PS; import net.knarcraft.factions.entity.BoardColl; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MFlag; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.ps.PS; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; @@ -20,7 +20,7 @@ public class EngineFlagFireSpread extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineFlagFireSpread i = new EngineFlagFireSpread(); + private static final EngineFlagFireSpread i = new EngineFlagFireSpread(); public static EngineFlagFireSpread get() { return i; @@ -35,9 +35,9 @@ public class EngineFlagFireSpread extends Engine { PS ps = PS.valueOf(block); Faction faction = BoardColl.get().getFactionAt(ps); - if (faction.getFlag(MFlag.getFlagFirespread())) { - return; - } + if (faction.getFlag(MFlag.getFlagFirespread())) { + return; + } // then cancel the event. cancellable.setCancelled(true); @@ -46,9 +46,9 @@ public class EngineFlagFireSpread extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockFireSpread(BlockIgniteEvent event) { // If fire is spreading ... - if (event.getCause() != IgniteCause.SPREAD && event.getCause() != IgniteCause.LAVA) { - return; - } + if (event.getCause() != IgniteCause.SPREAD && event.getCause() != IgniteCause.LAVA) { + return; + } // ... consider blocking it. blockFireSpread(event.getBlock(), event); @@ -58,9 +58,9 @@ public class EngineFlagFireSpread extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockFireSpread(BlockSpreadEvent event) { // If fire is spreading ... - if (event.getNewState().getType() != Material.FIRE) { - return; - } + if (event.getNewState().getType() != Material.FIRE) { + return; + } // ... consider blocking it. blockFireSpread(event.getBlock(), event); diff --git a/src/main/java/net/knarcraft/factions/engine/EngineFlagSpawn.java b/src/main/java/net/knarcraft/factions/engine/EngineFlagSpawn.java index 6b568fed..8b7cae24 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineFlagSpawn.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineFlagSpawn.java @@ -1,12 +1,12 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.collections.BackstringSet; +import com.massivecraft.massivecore.ps.PS; import net.knarcraft.factions.entity.BoardColl; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MFlag; import net.knarcraft.factions.util.EnumerationUtil; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.collections.BackstringSet; -import com.massivecraft.massivecore.ps.PS; import org.bukkit.Location; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; @@ -21,7 +21,7 @@ public class EngineFlagSpawn extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineFlagSpawn i = new EngineFlagSpawn(); + private static final EngineFlagSpawn i = new EngineFlagSpawn(); public static EngineFlagSpawn get() { return i; @@ -52,9 +52,9 @@ public class EngineFlagSpawn extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockMonstersAndAnimals(CreatureSpawnEvent event) { // If this is a natural spawn .. - if (!NATURAL_SPAWN_REASONS.contains(event.getSpawnReason())) { - return; - } + if (!NATURAL_SPAWN_REASONS.contains(event.getSpawnReason())) { + return; + } // ... get the spawn location ... Location location = event.getLocation(); @@ -62,17 +62,17 @@ public class EngineFlagSpawn extends Engine { // ... get the faction there ... Faction faction = BoardColl.get().getFactionAt(ps); - if (faction == null) { - return; - } + if (faction == null) { + return; + } // ... get the entity type ... EntityType type = event.getEntityType(); // ... and if this type can't spawn in the faction ... - if (canSpawn(faction, type)) { - return; - } + if (canSpawn(faction, type)) { + return; + } // ... then cancel. event.setCancelled(true); diff --git a/src/main/java/net/knarcraft/factions/engine/EngineFlagZombiegrief.java b/src/main/java/net/knarcraft/factions/engine/EngineFlagZombiegrief.java index 319fff21..599b73b7 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineFlagZombiegrief.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineFlagZombiegrief.java @@ -1,10 +1,10 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.ps.PS; import net.knarcraft.factions.entity.BoardColl; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MFlag; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.ps.PS; import org.bukkit.entity.Entity; import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; @@ -16,7 +16,7 @@ public class EngineFlagZombiegrief extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineFlagZombiegrief i = new EngineFlagZombiegrief(); + private static final EngineFlagZombiegrief i = new EngineFlagZombiegrief(); public static EngineFlagZombiegrief get() { return i; @@ -30,16 +30,16 @@ public class EngineFlagZombiegrief extends Engine { public void denyZombieGrief(EntityBreakDoorEvent event) { // If a zombie is breaking a door ... Entity entity = event.getEntity(); - if (!(entity instanceof Zombie)) { - return; - } + if (!(entity instanceof Zombie)) { + return; + } // ... and the faction there has zombiegrief disabled ... PS ps = PS.valueOf(event.getBlock()); Faction faction = BoardColl.get().getFactionAt(ps); - if (faction.getFlag(MFlag.getFlagZombiegrief())) { - return; - } + if (faction.getFlag(MFlag.getFlagZombiegrief())) { + return; + } // ... stop the door breakage. event.setCancelled(true); diff --git a/src/main/java/net/knarcraft/factions/engine/EngineFly.java b/src/main/java/net/knarcraft/factions/engine/EngineFly.java index a9662606..faadca07 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineFly.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineFly.java @@ -1,5 +1,11 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.event.EventMassiveCorePlayerUpdate; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.store.DriverFlatfile; +import com.massivecraft.massivecore.util.MUtil; import net.knarcraft.factions.Perm; import net.knarcraft.factions.cmd.CmdFactions; import net.knarcraft.factions.entity.BoardColl; @@ -10,12 +16,6 @@ import net.knarcraft.factions.entity.MFlagColl; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.event.EventFactionsFlagChange; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.event.EventMassiveCorePlayerUpdate; -import com.massivecraft.massivecore.ps.PS; -import com.massivecraft.massivecore.store.DriverFlatfile; -import com.massivecraft.massivecore.util.MUtil; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -30,7 +30,7 @@ public class EngineFly extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineFly i = new EngineFly(); + private static final EngineFly i = new EngineFly(); public static EngineFly get() { return i; @@ -44,31 +44,31 @@ public class EngineFly extends Engine { public void onMassiveCorePlayerUpdate(EventMassiveCorePlayerUpdate event) { // If we are updating a player ... Player player = event.getPlayer(); - if (MUtil.isntPlayer(player)) { - return; - } + if (MUtil.isntPlayer(player)) { + return; + } // ... and that player isn't in creative or spectator mode ... - if (EventMassiveCorePlayerUpdate.isFlyAllowed(player, false)) { - return; - } + if (EventMassiveCorePlayerUpdate.isFlyAllowed(player, false)) { + return; + } // ... and the player is alive ... - if (player.isDead()) { - return; - } + if (player.isDead()) { + return; + } MPlayer mplayer = MPlayer.get(player); // ... and the player enables flying ... - if (!mplayer.isFlying()) { - return; - } + if (!mplayer.isFlying()) { + return; + } // ... and the player can fly here... - if (!canFlyInTerritory(mplayer, PS.valueOf(player))) { - return; - } + if (!canFlyInTerritory(mplayer, PS.valueOf(player))) { + return; + } // ... set allowed ... event.setAllowed(true); @@ -80,27 +80,27 @@ public class EngineFly extends Engine { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void moveChunkDetect(PlayerMoveEvent event) { // If the player is moving from one chunk to another ... - if (MUtil.isSameChunk(event)) { - return; - } + if (MUtil.isSameChunk(event)) { + return; + } Player player = event.getPlayer(); - if (MUtil.isntPlayer(player)) { - return; - } + if (MUtil.isntPlayer(player)) { + return; + } // ... gather info on the player and the move ... MPlayer mplayer = MPlayer.get(player); PS chunkTo = PS.valueOf(event.getTo()).getChunk(true); // ... and they are currently flying ... - if (!mplayer.isFlying()) { - return; - } + if (!mplayer.isFlying()) { + return; + } // ... but can't fly at the new place ... - if (canFlyInTerritory(mplayer, chunkTo)) { - return; - } + if (canFlyInTerritory(mplayer, chunkTo)) { + return; + } // ... then perhaps they should not be mplayer.setFlying(false); @@ -109,12 +109,12 @@ public class EngineFly extends Engine { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void flagUpdate(EventFactionsFlagChange event) { - if (event.getFlag() != MFlag.getFlagFly()) { - return; - } - if (event.isNewValue() == true) { - return; - } + if (event.getFlag() != MFlag.getFlagFly()) { + return; + } + if (event.isNewValue()) { + return; + } // Disable for all players when disabled event.getFaction().getOnlinePlayers().forEach(EngineFly::deactivateForPlayer); @@ -123,24 +123,23 @@ public class EngineFly extends Engine { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void territoryShield(EntityDamageByEntityEvent event) { // If flying is diabled on PVP ... - if (!MConf.get().flyDisableOnPvp) { - return; - } + if (!MConf.get().flyDisableOnPvp) { + return; + } // ... and the defender is a player ... Entity entity = event.getEntity(); - if (MUtil.isntPlayer(entity)) { - return; - } + if (MUtil.isntPlayer(entity)) { + return; + } Player defender = (Player) entity; MPlayer mdefender = MPlayer.get(defender); // ... and the attacker is a player ... Entity eattacker = MUtil.getLiableDamager(event); - if (!(eattacker instanceof Player)) { - return; - } - Player attacker = (Player) eattacker; + if (!(eattacker instanceof Player attacker)) { + return; + } MPlayer mattacker = MPlayer.get(attacker); // ... disable flying for both @@ -206,12 +205,12 @@ public class EngineFly extends Engine { if (isAdmin) { boolean overriding = mplayer.isOverriding(); ex.addMsg("You can change the flag if you are overriding."); - if (overriding) { - ex.addMsg("You are already overriding."); - } else { - ex.addMsg("You can enable override with:"); - ex.addMessage(CmdFactions.get().cmdFactionsOverride.getTemplate(false, true, mplayer.getSender())); - } + if (overriding) { + ex.addMsg("You are already overriding."); + } else { + ex.addMsg("You can enable override with:"); + ex.addMessage(CmdFactions.get().cmdFactionsOverride.getTemplate(false, true, mplayer.getSender())); + } if (!isDefault) { ex.addMsg("You can also ask someone with access to the configuration files to make flying enabled by default."); diff --git a/src/main/java/net/knarcraft/factions/engine/EngineLastActivity.java b/src/main/java/net/knarcraft/factions/engine/EngineLastActivity.java index 926e8ab3..1069337b 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineLastActivity.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineLastActivity.java @@ -1,10 +1,10 @@ package net.knarcraft.factions.engine; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.event.EventMassiveCorePlayerLeave; import com.massivecraft.massivecore.util.MUtil; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.entity.MPlayer; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.event.EventHandler; @@ -16,7 +16,7 @@ public class EngineLastActivity extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineLastActivity i = new EngineLastActivity(); + private static final EngineLastActivity i = new EngineLastActivity(); public static EngineLastActivity get() { return i; @@ -27,21 +27,21 @@ public class EngineLastActivity extends Engine { // -------------------------------------------- // public static void updateLastActivity(CommandSender sender) { - if (sender == null) { - throw new RuntimeException("sender"); - } - if (MUtil.isntSender(sender)) { - return; - } + if (sender == null) { + throw new RuntimeException("sender"); + } + if (MUtil.isntSender(sender)) { + return; + } MPlayer mplayer = MPlayer.get(sender); mplayer.setLastActivityMillis(); } public static void updateLastActivitySoon(final CommandSender sender) { - if (sender == null) { - throw new RuntimeException("sender"); - } + if (sender == null) { + throw new RuntimeException("sender"); + } Bukkit.getScheduler().scheduleSyncDelayedTask(Factions.get(), () -> updateLastActivity(sender)); } diff --git a/src/main/java/net/knarcraft/factions/engine/EngineMotd.java b/src/main/java/net/knarcraft/factions/engine/EngineMotd.java index 22ada40d..353afd1d 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineMotd.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineMotd.java @@ -1,13 +1,13 @@ package net.knarcraft.factions.engine; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.MConf; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.mixin.MixinActual; import com.massivecraft.massivecore.mixin.MixinMessage; import com.massivecraft.massivecore.util.MUtil; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.MConf; +import net.knarcraft.factions.entity.MPlayer; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -21,7 +21,7 @@ public class EngineMotd extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineMotd i = new EngineMotd(); + private static final EngineMotd i = new EngineMotd(); public static EngineMotd get() { return i; diff --git a/src/main/java/net/knarcraft/factions/engine/EngineMoveChunk.java b/src/main/java/net/knarcraft/factions/engine/EngineMoveChunk.java index 73cde117..4b0042cc 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineMoveChunk.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineMoveChunk.java @@ -1,5 +1,10 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.mixin.MixinTitle; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.util.MUtil; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.AccessStatus; import net.knarcraft.factions.TerritoryAccess; import net.knarcraft.factions.entity.BoardColl; @@ -7,11 +12,6 @@ import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.util.AsciiMap; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.mixin.MixinTitle; -import com.massivecraft.massivecore.ps.PS; -import com.massivecraft.massivecore.util.MUtil; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -24,7 +24,7 @@ public class EngineMoveChunk extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineMoveChunk i = new EngineMoveChunk(); + private static final EngineMoveChunk i = new EngineMoveChunk(); public static EngineMoveChunk get() { return i; @@ -37,13 +37,13 @@ public class EngineMoveChunk extends Engine { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void moveChunkDetect(PlayerMoveEvent event) { // If the player is moving from one chunk to another ... - if (MUtil.isSameChunk(event)) { - return; - } + if (MUtil.isSameChunk(event)) { + return; + } Player player = event.getPlayer(); - if (MUtil.isntPlayer(player)) { - return; - } + if (MUtil.isntPlayer(player)) { + return; + } // ... gather info on the player and the move ... MPlayer mplayer = MPlayer.get(player); @@ -67,9 +67,9 @@ public class EngineMoveChunk extends Engine { } private static void sendAutoMapUpdate(MPlayer mplayer, PS ps) { - if (!mplayer.isMapAutoUpdating()) { - return; - } + if (!mplayer.isMapAutoUpdating()) { + return; + } AsciiMap map = new AsciiMap(mplayer, ps, false); mplayer.message(map.render()); } @@ -78,9 +78,9 @@ public class EngineMoveChunk extends Engine { Faction factionFrom = BoardColl.get().getFactionAt(psFrom); Faction factionTo = BoardColl.get().getFactionAt(psTo); - if (factionFrom == factionTo) { - return; - } + if (factionFrom == factionTo) { + return; + } if (mplayer.isTerritoryInfoTitles()) { String titleMain = parseTerritoryInfo(MConf.get().territoryInfoTitlesMain, mplayer, factionTo); @@ -96,12 +96,12 @@ public class EngineMoveChunk extends Engine { } private static String parseTerritoryInfo(String string, MPlayer mplayer, Faction faction) { - if (string == null) { - throw new NullPointerException("string"); - } - if (faction == null) { - throw new NullPointerException("faction"); - } + if (string == null) { + throw new NullPointerException("string"); + } + if (faction == null) { + throw new NullPointerException("faction"); + } string = Txt.parse(string); string = string.replace("{name}", faction.getName()); @@ -112,9 +112,9 @@ public class EngineMoveChunk extends Engine { } private static void sendTerritoryAccessMessage(MPlayer mplayer, PS psFrom, PS psTo) { - if (!MConf.get().territoryAccessShowMessage) { - return; - } + if (!MConf.get().territoryAccessShowMessage) { + return; + } // Get TerritoryAccess for from & to chunks TerritoryAccess accessFrom = BoardColl.get().getTerritoryAccessAt(psFrom); @@ -123,9 +123,9 @@ public class EngineMoveChunk extends Engine { // See if the status has changed AccessStatus statusFrom = accessFrom.getTerritoryAccess(mplayer); AccessStatus statusTo = accessTo.getTerritoryAccess(mplayer); - if (statusFrom == statusTo) { - return; - } + if (statusFrom == statusTo) { + return; + } // Inform mplayer.message(statusTo.getStatusMessage()); @@ -138,9 +138,9 @@ public class EngineMoveChunk extends Engine { private static void tryAutoClaim(MPlayer mplayer, PS chunkTo) { // If the player is auto claiming ... Faction autoClaimFaction = mplayer.getAutoClaimFaction(); - if (autoClaimFaction == null) { - return; - } + if (autoClaimFaction == null) { + return; + } // ... try claim. mplayer.tryClaim(autoClaimFaction, Collections.singletonList(chunkTo)); diff --git a/src/main/java/net/knarcraft/factions/engine/EnginePermBuild.java b/src/main/java/net/knarcraft/factions/engine/EnginePermBuild.java index fcfdc866..6e2be820 100644 --- a/src/main/java/net/knarcraft/factions/engine/EnginePermBuild.java +++ b/src/main/java/net/knarcraft/factions/engine/EnginePermBuild.java @@ -1,5 +1,8 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.util.MUtil; import net.knarcraft.factions.Factions; import net.knarcraft.factions.TerritoryAccess; import net.knarcraft.factions.entity.Board; @@ -10,9 +13,6 @@ import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.util.EnumerationUtil; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.ps.PS; -import com.massivecraft.massivecore.util.MUtil; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -51,7 +51,7 @@ public class EnginePermBuild extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EnginePermBuild i = new EnginePermBuild(); + private static final EnginePermBuild i = new EnginePermBuild(); public static EnginePermBuild get() { return i; @@ -62,39 +62,39 @@ public class EnginePermBuild extends Engine { // -------------------------------------------- // public static Boolean isProtected(ProtectCase protectCase, boolean verboose, MPlayer mplayer, PS ps, Object object) { - if (mplayer == null) { - return null; - } - if (protectCase == null) { - return null; - } + if (mplayer == null) { + return null; + } + if (protectCase == null) { + return null; + } String name = mplayer.getName(); - if (MConf.get().playersWhoBypassAllProtection.contains(name)) { - return false; - } - if (mplayer.isOverriding()) { - return false; - } + if (MConf.get().playersWhoBypassAllProtection.contains(name)) { + return false; + } + if (mplayer.isOverriding()) { + return false; + } MPerm perm = protectCase.getPerm(object); - if (perm == null) { - return null; - } - if (protectCase != ProtectCase.BUILD) { - return !perm.has(mplayer, ps, verboose); - } + if (perm == null) { + return null; + } + if (protectCase != ProtectCase.BUILD) { + return !perm.has(mplayer, ps, verboose); + } if (!perm.has(mplayer, ps, false) && MPerm.getPermPainbuild().has(mplayer, ps, false)) { - if (!verboose) { - return false; - } + if (!verboose) { + return false; + } Faction hostFaction = BoardColl.get().getFactionAt(ps); mplayer.msg("It is painful to build in the territory of %s.", hostFaction.describeTo(mplayer)); Player player = mplayer.getPlayer(); - if (player != null) { - player.damage(MConf.get().actionDeniedPainAmount); - } + if (player != null) { + player.damage(MConf.get().actionDeniedPainAmount); + } } return !perm.has(mplayer, ps, verboose); @@ -102,20 +102,20 @@ public class EnginePermBuild extends Engine { public static Boolean protect(ProtectCase protectCase, boolean verboose, Player player, PS ps, Object object, Cancellable cancellable) { Boolean ret = isProtected(protectCase, verboose, MPlayer.get(player), ps, object); - if (Boolean.TRUE.equals(ret) && cancellable != null) { - cancellable.setCancelled(true); - } + if (Boolean.TRUE.equals(ret) && cancellable != null) { + cancellable.setCancelled(true); + } return ret; } public static Boolean build(Entity entity, Block block, Event event) { - if (!(event instanceof Cancellable)) { - return true; - } - if (MUtil.isntPlayer(entity)) { - return false; - } + if (!(event instanceof Cancellable)) { + return true; + } + if (MUtil.isntPlayer(entity)) { + return false; + } Player player = (Player) entity; boolean verboose = !isFake(event); return protect(ProtectCase.BUILD, verboose, player, PS.valueOf(block), block, (Cancellable) event); @@ -139,9 +139,9 @@ public class EnginePermBuild extends Engine { public static boolean canPlayerBuildAt(Object senderObject, PS ps, boolean verboose) { MPlayer mplayer = MPlayer.get(senderObject); - if (mplayer == null) { - return false; - } + if (mplayer == null) { + return false; + } Boolean ret = isProtected(ProtectCase.BUILD, verboose, mplayer, ps, null); return !Boolean.TRUE.equals(ret); @@ -180,9 +180,9 @@ public class EnginePermBuild extends Engine { public void build(EntityChangeBlockEvent event) { // Handling lilypads being broken by boats Entity entity = event.getEntity(); - if (entity.getType() != EntityType.BOAT || entity.getPassengers().size() <= 0) { - return; - } + if (entity.getType() != EntityType.BOAT || entity.getPassengers().size() <= 0) { + return; + } Entity player = entity.getPassengers().stream().filter(MUtil::isPlayer).findAny().orElse(entity); build(player, event.getBlock(), event); @@ -196,26 +196,26 @@ public class EnginePermBuild extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void useBlockItem(PlayerInteractEvent event) { // If the player right clicks (or is physical with) a block ... - if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) { - return; - } + if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) { + return; + } Block block = event.getClickedBlock(); Player player = event.getPlayer(); - if (block == null) { - return; - } + if (block == null) { + return; + } // ... and we are either allowed to use this block ... Boolean ret = useBlock(player, block, true, event); - if (Boolean.TRUE.equals(ret)) { - return; - } + if (Boolean.TRUE.equals(ret)) { + return; + } // ... or are allowed to right click with the item, this event is safe to perform. - if (event.getAction() != Action.RIGHT_CLICK_BLOCK) { - return; - } + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) { + return; + } useItem(player, block, event.getMaterial(), event); } @@ -241,9 +241,9 @@ public class EnginePermBuild extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void useEntity(PlayerInteractEntityEvent event) { // Ignore Off Hand - if (isOffHand(event)) { - return; - } + if (isOffHand(event)) { + return; + } useEntity(event.getPlayer(), event.getRightClicked(), true, event); } @@ -254,22 +254,22 @@ public class EnginePermBuild extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void handleArmorStand(PlayerInteractAtEntityEvent event) { // Ignore Off Hand - if (isOffHand(event)) { - return; - } + if (isOffHand(event)) { + return; + } // Gather Info final Player player = event.getPlayer(); - if (MUtil.isntPlayer(player)) { - return; - } + if (MUtil.isntPlayer(player)) { + return; + } final Entity entity = event.getRightClicked(); final boolean verboose = true; // Only care for armor stands. - if (entity.getType() != EntityType.ARMOR_STAND) { - return; - } + if (entity.getType() != EntityType.ARMOR_STAND) { + return; + } // If we can't use, block it EnginePermBuild.useEntity(player, entity, verboose, event); @@ -283,16 +283,16 @@ public class EnginePermBuild extends Engine { public void buildEntity(EntityDamageByEntityEvent event) { // If a player ... Entity damager = MUtil.getLiableDamager(event); - if (MUtil.isntPlayer(damager)) { - return; - } + if (MUtil.isntPlayer(damager)) { + return; + } Player player = (Player) damager; // ... damages an entity which is edited on damage ... Entity entity = event.getEntity(); - if (entity == null || !EnumerationUtil.isEntityTypeEditOnDamage(entity.getType())) { - return; - } + if (entity == null || !EnumerationUtil.isEntityTypeEditOnDamage(entity.getType())) { + return; + } // ... and the player can't build there, cancel the event build(player, entity.getLocation().getBlock(), event); @@ -302,23 +302,22 @@ public class EnginePermBuild extends Engine { public void combustEntity(EntityCombustByEntityEvent event) { // If a burning projectile ... - if (!(event.getCombuster() instanceof Projectile)) { - return; - } - Projectile entityProjectile = (Projectile) event.getCombuster(); + if (!(event.getCombuster() instanceof Projectile entityProjectile)) { + return; + } // ... fired by a player ... ProjectileSource projectileSource = entityProjectile.getShooter(); - if (MUtil.isntPlayer(projectileSource)) { - return; - } + if (MUtil.isntPlayer(projectileSource)) { + return; + } Player player = (Player) projectileSource; // ... and hits an entity which is edited on damage (and thus likely to burn) ... Entity entityTarget = event.getEntity(); - if (entityTarget == null || !EnumerationUtil.isEntityTypeEditOnDamage(entityTarget.getType())) { - return; - } + if (entityTarget == null || !EnumerationUtil.isEntityTypeEditOnDamage(entityTarget.getType())) { + return; + } // ... and the player can't build there, cancel the event Block block = entityTarget.getLocation().getBlock(); @@ -339,9 +338,9 @@ public class EnginePermBuild extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockBuild(BlockPistonExtendEvent event) { // Is checking deactivated by MConf? - if (!MConf.get().handlePistonProtectionThroughDenyBuild) { - return; - } + if (!MConf.get().handlePistonProtectionThroughDenyBuild) { + return; + } Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock())); @@ -354,14 +353,14 @@ public class EnginePermBuild extends Engine { // Members of a faction might not have build rights in their own territory, but pistons should still work regardless Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(targetBlock)); - if (targetFaction == pistonFaction) { - continue; - } + if (targetFaction == pistonFaction) { + continue; + } // Perm check - if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) { - continue; - } + if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) { + continue; + } event.setCancelled(true); return; @@ -371,9 +370,9 @@ public class EnginePermBuild extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockBuild(BlockPistonRetractEvent event) { // Is checking deactivated by MConf? - if (!MConf.get().handlePistonProtectionThroughDenyBuild) { - return; - } + if (!MConf.get().handlePistonProtectionThroughDenyBuild) { + return; + } Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock())); @@ -382,20 +381,20 @@ public class EnginePermBuild extends Engine { // Check for all retracted blocks for (Block block : blocks) { // Is the retracted block air/water/lava? Don't worry about it - if (block.isEmpty() || block.isLiquid()) { - return; - } + if (block.isEmpty() || block.isLiquid()) { + return; + } // Members of a faction might not have build rights in their own territory, but pistons should still work regardless Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(block)); - if (targetFaction == pistonFaction) { - continue; - } + if (targetFaction == pistonFaction) { + continue; + } // Perm check - if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) { - continue; - } + if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) { + continue; + } event.setCancelled(true); return; @@ -410,27 +409,27 @@ public class EnginePermBuild extends Engine { @EventHandler(priority = EventPriority.NORMAL) public void buildFire(PlayerInteractEvent event) { // If it is a left click on block and the clicked block is not null... - if (event.getAction() != Action.LEFT_CLICK_BLOCK || event.getClickedBlock() == null) { - return; - } + if (event.getAction() != Action.LEFT_CLICK_BLOCK || event.getClickedBlock() == null) { + return; + } // ... and the potential block is not null either ... Block potentialBlock = event.getClickedBlock().getRelative(BlockFace.UP, 1); - if (potentialBlock == null) { - return; - } + if (potentialBlock == null) { + return; + } Material blockType = potentialBlock.getType(); // ... and we're only going to check for fire ... (checking everything else would be bad performance wise) - if (blockType != Material.FIRE) { - return; - } + if (blockType != Material.FIRE) { + return; + } // ... check if they can't build, cancel the event ... - if (!Boolean.FALSE.equals(build(event.getPlayer(), potentialBlock, event))) { - return; - } + if (!Boolean.FALSE.equals(build(event.getPlayer(), potentialBlock, event))) { + return; + } // ... and compensate for client side prediction event.getPlayer().sendBlockChange(potentialBlock.getLocation(), blockType, potentialBlock.getState().getRawData()); @@ -442,9 +441,9 @@ public class EnginePermBuild extends Engine { @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void buildMove(BlockFromToEvent event) { - if (!MConf.get().protectionLiquidFlowEnabled) { - return; - } + if (!MConf.get().protectionLiquidFlowEnabled) { + return; + } // Prepare fields Block fromBlock = event.getBlock(); @@ -455,21 +454,21 @@ public class EnginePermBuild extends Engine { int chunkToZ = (fromBlock.getZ() + face.getModZ()) >> 4; // If a liquid (or dragon egg) moves from one chunk to another ... - if (chunkToX == chunkFromX && chunkToZ == chunkFromZ) { - return; - } + if (chunkToX == chunkFromX && chunkToZ == chunkFromZ) { + return; + } // ... get the correct board for this block ... Board board = BoardColl.get().getFixed(fromBlock.getWorld().getName().toLowerCase(), false); - if (board == null) { - return; - } + if (board == null) { + return; + } // ... get the access map ... Map map = board.getMapRaw(); - if (map.isEmpty()) { - return; - } + if (map.isEmpty()) { + return; + } // ... get the faction ids from and to ... PS fromPs = PS.valueOf(chunkFromX, chunkFromZ); @@ -482,22 +481,22 @@ public class EnginePermBuild extends Engine { String toId = toTa != null ? toTa.getHostFactionId() : Factions.ID_NONE; // ... and the chunks belong to different factions ... - if (toId.equals(fromId)) { - return; - } + if (toId.equals(fromId)) { + return; + } // ... and the faction "from" can not build at "to" ... Faction fromFac = FactionColl.get().getFixed(fromId); - if (fromFac == null) { - fromFac = FactionColl.get().getNone(); - } + if (fromFac == null) { + fromFac = FactionColl.get().getNone(); + } Faction toFac = FactionColl.get().getFixed(toId); - if (toFac == null) { - toFac = FactionColl.get().getNone(); - } - if (MPerm.getPermBuild().has(fromFac, toFac)) { - return; - } + if (toFac == null) { + toFac = FactionColl.get().getNone(); + } + if (MPerm.getPermBuild().has(fromFac, toFac)) { + return; + } // ... cancel the event! event.setCancelled(true); diff --git a/src/main/java/net/knarcraft/factions/engine/EnginePlayerData.java b/src/main/java/net/knarcraft/factions/engine/EnginePlayerData.java index c25d646a..bc1dff14 100644 --- a/src/main/java/net/knarcraft/factions/engine/EnginePlayerData.java +++ b/src/main/java/net/knarcraft/factions/engine/EnginePlayerData.java @@ -1,9 +1,9 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.MPlayerColl; -import com.massivecraft.massivecore.Engine; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -14,7 +14,7 @@ public class EnginePlayerData extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EnginePlayerData i = new EnginePlayerData(); + private static final EnginePlayerData i = new EnginePlayerData(); public static EnginePlayerData get() { return i; @@ -31,20 +31,20 @@ public class EnginePlayerData extends Engine { // ... and if the if player was banned (not just kicked) ... //if (!event.getReason().equals("Banned by admin.")) return; - if (!player.isBanned()) { - return; - } + if (!player.isBanned()) { + return; + } // ... and we remove player data when banned ... - if (!MConf.get().removePlayerWhenBanned) { - return; - } + if (!MConf.get().removePlayerWhenBanned) { + return; + } // ... get rid of their stored info. MPlayer mplayer = MPlayerColl.get().get(player, false); - if (mplayer == null) { - return; - } + if (mplayer == null) { + return; + } if (mplayer.getRank().isLeader()) { mplayer.getFaction().promoteNewLeader(); diff --git a/src/main/java/net/knarcraft/factions/engine/EnginePower.java b/src/main/java/net/knarcraft/factions/engine/EnginePower.java index 128435ca..fd9e8312 100644 --- a/src/main/java/net/knarcraft/factions/engine/EnginePower.java +++ b/src/main/java/net/knarcraft/factions/engine/EnginePower.java @@ -1,5 +1,9 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.util.MUtil; +import com.massivecraft.massivecore.util.PlayerUtil; import net.knarcraft.factions.entity.BoardColl; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; @@ -7,10 +11,6 @@ import net.knarcraft.factions.entity.MFlag; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.event.EventFactionsPowerChange; import net.knarcraft.factions.event.EventFactionsPowerChange.PowerChangeReason; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.ps.PS; -import com.massivecraft.massivecore.util.MUtil; -import com.massivecraft.massivecore.util.PlayerUtil; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -21,7 +21,7 @@ public class EnginePower extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EnginePower i = new EnginePower(); + private static final EnginePower i = new EnginePower(); public static EnginePower get() { return i; @@ -35,15 +35,15 @@ public class EnginePower extends Engine { public void powerLossOnDeath(PlayerDeathEvent event) { // If a player dies ... Player player = event.getEntity(); - if (MUtil.isntPlayer(player)) { - return; - } + if (MUtil.isntPlayer(player)) { + return; + } // ... and this is the first death event this tick ... // (yeah other plugins can case death event to fire twice the same tick) - if (PlayerUtil.isDuplicateDeathEvent(event)) { - return; - } + if (PlayerUtil.isDuplicateDeathEvent(event)) { + return; + } MPlayer mplayer = MPlayer.get(player); @@ -65,9 +65,9 @@ public class EnginePower extends Engine { EventFactionsPowerChange powerChangeEvent = new EventFactionsPowerChange(null, mplayer, PowerChangeReason.DEATH, newPower); powerChangeEvent.run(); - if (powerChangeEvent.isCancelled()) { - return; - } + if (powerChangeEvent.isCancelled()) { + return; + } newPower = powerChangeEvent.getNewPower(); mplayer.setPower(newPower); diff --git a/src/main/java/net/knarcraft/factions/engine/EngineSeeChunk.java b/src/main/java/net/knarcraft/factions/engine/EngineSeeChunk.java index dbe6850a..96f8d454 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineSeeChunk.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineSeeChunk.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.engine; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.event.EventMassiveCorePlayerLeave; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.PeriodUtil; +import net.knarcraft.factions.entity.MPlayer; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Particle; @@ -24,7 +24,7 @@ public class EngineSeeChunk extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineSeeChunk i = new EngineSeeChunk(); + private static final EngineSeeChunk i = new EngineSeeChunk(); public static EngineSeeChunk get() { return i; @@ -39,9 +39,9 @@ public class EngineSeeChunk extends Engine { // -------------------------------------------- // public static void leaveAndWorldChangeRemoval(Player player) { - if (MUtil.isntPlayer(player)) { - return; - } + if (MUtil.isntPlayer(player)) { + return; + } final MPlayer mplayer = MPlayer.get(player); mplayer.setSeeingChunk(false); @@ -68,9 +68,9 @@ public class EngineSeeChunk extends Engine { // Do we have a new period? final long now = System.currentTimeMillis(); final long length = 500; - if (!PeriodUtil.isNewPeriod(this, length, now)) { - return; - } + if (!PeriodUtil.isNewPeriod(this, length, now)) { + return; + } // Get the period number final long period = PeriodUtil.getPeriod(length, now); @@ -89,15 +89,15 @@ public class EngineSeeChunk extends Engine { // For each player for (Player player : Bukkit.getOnlinePlayers()) { // Hide for dead players since the death screen looks better without. - if (player.isDead()) { - continue; - } + if (player.isDead()) { + continue; + } // The player must obviously have the feature activated. MPlayer mplayer = MPlayer.get(player); - if (!mplayer.isSeeingChunk()) { - continue; - } + if (!mplayer.isSeeingChunk()) { + continue; + } // Calculate locations and play the effect there. List locations = getLocations(player, steps, step); @@ -110,18 +110,18 @@ public class EngineSeeChunk extends Engine { public static List getLocations(Player player, int steps, int step) { // Clean Args - if (player == null) { - throw new NullPointerException("player"); - } - if (steps < 1) { - throw new InvalidParameterException("steps must be larger than 0"); - } - if (step < 0) { - throw new InvalidParameterException("step must at least be 0"); - } - if (step >= steps) { - throw new InvalidParameterException("step must be less than steps"); - } + if (player == null) { + throw new NullPointerException("player"); + } + if (steps < 1) { + throw new InvalidParameterException("steps must be larger than 0"); + } + if (step < 0) { + throw new InvalidParameterException("step must at least be 0"); + } + if (step >= steps) { + throw new InvalidParameterException("step must be less than steps"); + } // Create Ret List ret = new ArrayList<>(); @@ -137,14 +137,14 @@ public class EngineSeeChunk extends Engine { final int zmax = zmin + 15; int keepEvery = 5; - if (keepEvery <= 0) { - keepEvery = Integer.MAX_VALUE; - } + if (keepEvery <= 0) { + keepEvery = Integer.MAX_VALUE; + } int skipEvery = 0; - if (skipEvery <= 0) { - skipEvery = Integer.MAX_VALUE; - } + if (skipEvery <= 0) { + skipEvery = Integer.MAX_VALUE; + } int x = xmin; int z = zmin; @@ -154,36 +154,36 @@ public class EngineSeeChunk extends Engine { while (x + 1 <= xmax) { x++; i++; - if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) { - ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5)); - } + if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) { + ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5)); + } } // Add #2 while (z + 1 <= zmax) { z++; i++; - if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) { - ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5)); - } + if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) { + ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5)); + } } // Add #3 while (x - 1 >= xmin) { x--; i++; - if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) { - ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5)); - } + if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) { + ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5)); + } } // Add #4 while (z - 1 >= zmin) { z--; i++; - if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) { - ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5)); - } + if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) { + ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5)); + } } // Return Ret diff --git a/src/main/java/net/knarcraft/factions/engine/EngineShow.java b/src/main/java/net/knarcraft/factions/engine/EngineShow.java index 52f58d00..8febc920 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineShow.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineShow.java @@ -1,5 +1,11 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.PriorityLines; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.util.TimeDiffUtil; +import com.massivecraft.massivecore.util.TimeUnit; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.comparator.ComparatorMPlayerRole; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; @@ -8,12 +14,6 @@ import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.event.EventFactionsChunkChangeType; import net.knarcraft.factions.event.EventFactionsFactionShowAsync; import net.knarcraft.factions.integration.Econ; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.PriorityLines; -import com.massivecraft.massivecore.money.Money; -import com.massivecraft.massivecore.util.TimeDiffUtil; -import com.massivecraft.massivecore.util.TimeUnit; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.command.CommandSender; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -56,7 +56,7 @@ public class EngineShow extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineShow i = new EngineShow(); + private static final EngineShow i = new EngineShow(); public static EngineShow get() { return i; diff --git a/src/main/java/net/knarcraft/factions/engine/EngineTeleportHomeOnDeath.java b/src/main/java/net/knarcraft/factions/engine/EngineTeleportHomeOnDeath.java index 123de061..f97af891 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineTeleportHomeOnDeath.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineTeleportHomeOnDeath.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.engine; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.util.MUtil; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.Warp; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.util.MUtil; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -19,7 +19,7 @@ public class EngineTeleportHomeOnDeath extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineTeleportHomeOnDeath i = new EngineTeleportHomeOnDeath(); + private static final EngineTeleportHomeOnDeath i = new EngineTeleportHomeOnDeath(); public static EngineTeleportHomeOnDeath get() { return i; @@ -32,33 +32,33 @@ public class EngineTeleportHomeOnDeath extends Engine { public void teleportToHomeOnDeath(PlayerRespawnEvent event, EventPriority priority) { // If a player is respawning ... final Player player = event.getPlayer(); - if (MUtil.isntPlayer(player)) { - return; - } + if (MUtil.isntPlayer(player)) { + return; + } final MPlayer mplayer = MPlayer.get(player); // ... homes are enabled, active and at this priority ... - if (!MConf.get().warpsEnabled) { - return; - } - if (!MConf.get().warpsTeleportToOnDeathActive) { - return; - } - if (MConf.get().warpsTeleportToOnDeathPriority != priority) { - return; - } + if (!MConf.get().warpsEnabled) { + return; + } + if (!MConf.get().warpsTeleportToOnDeathActive) { + return; + } + if (MConf.get().warpsTeleportToOnDeathPriority != priority) { + return; + } // ... and the player has a faction ... final Faction faction = mplayer.getFaction(); - if (faction.isNone()) { - return; - } + if (faction.isNone()) { + return; + } // ... and the faction has a home ... - List warps = faction.getWarps().getAll((java.util.function.Predicate) (warp -> warp.getName().equalsIgnoreCase(MConf.get().warpsTeleportToOnDeathName))); - if (warps.isEmpty()) { - return; - } + List warps = faction.getWarps().getAll(warp -> warp.getName().equalsIgnoreCase(MConf.get().warpsTeleportToOnDeathName)); + if (warps.isEmpty()) { + return; + } Warp warp = warps.get(0); diff --git a/src/main/java/net/knarcraft/factions/engine/EngineTerritoryShield.java b/src/main/java/net/knarcraft/factions/engine/EngineTerritoryShield.java index 2aaf8db1..8551dc7d 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineTerritoryShield.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineTerritoryShield.java @@ -1,9 +1,9 @@ package net.knarcraft.factions.engine; -import net.knarcraft.factions.entity.MConf; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.util.MUtil; +import net.knarcraft.factions.entity.MConf; +import net.knarcraft.factions.entity.MPlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -17,7 +17,7 @@ public class EngineTerritoryShield extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineTerritoryShield i = new EngineTerritoryShield(); + private static final EngineTerritoryShield i = new EngineTerritoryShield(); public static EngineTerritoryShield get() { return i; @@ -31,32 +31,32 @@ public class EngineTerritoryShield extends Engine { public void territoryShield(EntityDamageByEntityEvent event) { // If the entity is a player ... Entity entity = event.getEntity(); - if (MUtil.isntPlayer(entity)) { - return; - } + if (MUtil.isntPlayer(entity)) { + return; + } Player player = (Player) entity; MPlayer mplayer = MPlayer.get(player); // ... and the attacker is a player ... Entity attacker = MUtil.getLiableDamager(event); - if (!(attacker instanceof Player)) { - return; - } + if (!(attacker instanceof Player)) { + return; + } // ... and that player has a faction ... - if (!mplayer.hasFaction()) { - return; - } + if (!mplayer.hasFaction()) { + return; + } // ... and that player is in their own territory ... - if (!mplayer.isInOwnTerritory()) { - return; - } + if (!mplayer.isInOwnTerritory()) { + return; + } // ... and a territoryShieldFactor is configured ... - if (MConf.get().territoryShieldFactor <= 0) { - return; - } + if (MConf.get().territoryShieldFactor <= 0) { + return; + } // ... then scale the damage ... double factor = 1D - MConf.get().territoryShieldFactor; diff --git a/src/main/java/net/knarcraft/factions/engine/EngineVisualizations.java b/src/main/java/net/knarcraft/factions/engine/EngineVisualizations.java index b5f709c7..db9f6159 100644 --- a/src/main/java/net/knarcraft/factions/engine/EngineVisualizations.java +++ b/src/main/java/net/knarcraft/factions/engine/EngineVisualizations.java @@ -1,8 +1,8 @@ package net.knarcraft.factions.engine; -import net.knarcraft.factions.util.VisualizeUtil; import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.util.MUtil; +import net.knarcraft.factions.util.VisualizeUtil; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerMoveEvent; @@ -12,7 +12,7 @@ public class EngineVisualizations extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineVisualizations i = new EngineVisualizations(); + private static final EngineVisualizations i = new EngineVisualizations(); public static EngineVisualizations get() { return i; @@ -24,9 +24,9 @@ public class EngineVisualizations extends Engine { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerMoveClearVisualizations(PlayerMoveEvent event) { - if (MUtil.isSameBlock(event)) { - return; - } + if (MUtil.isSameBlock(event)) { + return; + } VisualizeUtil.clear(event.getPlayer()); } diff --git a/src/main/java/net/knarcraft/factions/engine/ProtectCase.java b/src/main/java/net/knarcraft/factions/engine/ProtectCase.java index 9a5d6fd2..7104d054 100644 --- a/src/main/java/net/knarcraft/factions/engine/ProtectCase.java +++ b/src/main/java/net/knarcraft/factions/engine/ProtectCase.java @@ -38,10 +38,9 @@ public enum ProtectCase { return MPerm.getPermBuild(); case USE_ENTITY: - if (!(object instanceof Entity)) { + if (!(object instanceof Entity entity)) { return null; } - Entity entity = (Entity) object; EntityType type = entity.getType(); if (EnumerationUtil.isEntityTypeContainer(type)) { return MPerm.getPermContainer(); @@ -51,10 +50,9 @@ public enum ProtectCase { } case USE_BLOCK: - if (!(object instanceof Material)) { + if (!(object instanceof Material material)) { return null; } - Material material = (Material) object; if (EnumerationUtil.isMaterialEditOnInteract(material)) { return MPerm.getPermBuild(); } diff --git a/src/main/java/net/knarcraft/factions/entity/Board.java b/src/main/java/net/knarcraft/factions/entity/Board.java index 9a724146..d2029245 100644 --- a/src/main/java/net/knarcraft/factions/entity/Board.java +++ b/src/main/java/net/knarcraft/factions/entity/Board.java @@ -1,10 +1,10 @@ package net.knarcraft.factions.entity; import com.google.gson.reflect.TypeToken; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.TerritoryAccess; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.store.Entity; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.TerritoryAccess; import java.lang.reflect.Type; import java.util.Collections; @@ -40,13 +40,10 @@ public class Board extends Entity implements BoardInterface { @Override public boolean isDefault() { - if (this.map == null) { - return true; - } - if (this.map.isEmpty()) { - return true; - } - return false; + if (this.map == null) { + return true; + } + return this.map.isEmpty(); } // -------------------------------------------- // @@ -83,15 +80,15 @@ public class Board extends Entity implements BoardInterface { @Override public TerritoryAccess getTerritoryAccessAt(PS ps) { - if (ps == null) { - throw new NullPointerException("ps"); - } + if (ps == null) { + throw new NullPointerException("ps"); + } ps = ps.getChunkCoords(true); TerritoryAccess ret = this.map.get(ps); - if (ret == null || ret.getHostFaction() == null) { - ret = TerritoryAccess.valueOf(Factions.ID_NONE); - } + if (ret == null || ret.getHostFaction() == null) { + ret = TerritoryAccess.valueOf(Factions.ID_NONE); + } return ret; } @@ -161,9 +158,9 @@ public class Board extends Entity implements BoardInterface { @Override public Map> getFactionToChunks(boolean withWorld) { Function, PS> mapper = Entry::getKey; - if (withWorld) { - mapper = mapper.andThen(ps -> ps.withWorld(this.getId())); - } + if (withWorld) { + mapper = mapper.andThen(ps -> ps.withWorld(this.getId())); + } return map.entrySet().stream().collect(Collectors.groupingBy( entry -> entry.getValue().getHostFaction(), // This specifies how to get the key @@ -180,18 +177,18 @@ public class Board extends Entity implements BoardInterface { @Override public int getCount(Faction faction) { - if (faction == null) { - throw new NullPointerException("faction"); - } + if (faction == null) { + throw new NullPointerException("faction"); + } return this.getCount(faction.getId()); } @Override public int getCount(String factionId) { - if (factionId == null) { - throw new NullPointerException("factionId"); - } + if (factionId == null) { + throw new NullPointerException("factionId"); + } return (int) this.map.values().stream() .map(TerritoryAccess::getHostFactionId) @@ -224,36 +221,32 @@ public class Board extends Entity implements BoardInterface { // NEARBY DETECTION - // Is this coord NOT completely surrounded by coords claimed by the same faction? - // Simpler: Is there any nearby coord with a faction other than the faction here? + // Is this coordinate NOT completely surrounded by coordinates claimed by the same faction? + // Simpler: Is there any nearby coordinates with a faction other than the faction here? @Override public boolean isBorderPs(PS ps) { ps = ps.getChunk(true); - PS nearby = null; + PS nearby; Faction faction = this.getFactionAt(ps); nearby = ps.withChunkX(ps.getChunkX() + 1); - if (faction != this.getFactionAt(nearby)) { - return true; - } + if (faction != this.getFactionAt(nearby)) { + return true; + } nearby = ps.withChunkX(ps.getChunkX() - 1); - if (faction != this.getFactionAt(nearby)) { - return true; - } + if (faction != this.getFactionAt(nearby)) { + return true; + } nearby = ps.withChunkZ(ps.getChunkZ() + 1); - if (faction != this.getFactionAt(nearby)) { - return true; - } + if (faction != this.getFactionAt(nearby)) { + return true; + } nearby = ps.withChunkZ(ps.getChunkZ() - 1); - if (faction != this.getFactionAt(nearby)) { - return true; - } - - return false; + return faction != this.getFactionAt(nearby); } @Override @@ -261,34 +254,30 @@ public class Board extends Entity implements BoardInterface { return pss.stream().anyMatch(this::isBorderPs); } - // Is this coord connected to any coord claimed by the specified faction? + // Is this coordinate connected to any coordinates claimed by the specified faction? @Override public boolean isConnectedPs(PS ps, Faction faction) { ps = ps.getChunk(true); - PS nearby = null; + PS nearby; nearby = ps.withChunkX(ps.getChunkX() + 1); - if (faction == this.getFactionAt(nearby)) { - return true; - } + if (faction == this.getFactionAt(nearby)) { + return true; + } nearby = ps.withChunkX(ps.getChunkX() - 1); - if (faction == this.getFactionAt(nearby)) { - return true; - } + if (faction == this.getFactionAt(nearby)) { + return true; + } nearby = ps.withChunkZ(ps.getChunkZ() + 1); - if (faction == this.getFactionAt(nearby)) { - return true; - } + if (faction == this.getFactionAt(nearby)) { + return true; + } nearby = ps.withChunkZ(ps.getChunkZ() - 1); - if (faction == this.getFactionAt(nearby)) { - return true; - } - - return false; + return faction == this.getFactionAt(nearby); } @Override diff --git a/src/main/java/net/knarcraft/factions/entity/BoardColl.java b/src/main/java/net/knarcraft/factions/entity/BoardColl.java index 699389a3..32540a43 100644 --- a/src/main/java/net/knarcraft/factions/entity/BoardColl.java +++ b/src/main/java/net/knarcraft/factions/entity/BoardColl.java @@ -1,6 +1,5 @@ package net.knarcraft.factions.entity; -import net.knarcraft.factions.TerritoryAccess; import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.collections.MassiveMap; import com.massivecraft.massivecore.collections.MassiveSet; @@ -8,6 +7,7 @@ import com.massivecraft.massivecore.entity.MassiveCoreMConf; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.store.Coll; import com.massivecraft.massivecore.util.MUtil; +import net.knarcraft.factions.TerritoryAccess; import java.util.Collection; import java.util.List; @@ -22,7 +22,7 @@ public class BoardColl extends Coll implements BoardInterface { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static BoardColl i = new BoardColl(); + private static final BoardColl i = new BoardColl(); public static BoardColl get() { return i; @@ -48,15 +48,15 @@ public class BoardColl extends Coll implements BoardInterface { @Override public String fixId(Object oid) { - if (oid == null) { - return null; - } - if (oid instanceof String) { - return (String) oid; - } - if (oid instanceof Board) { - return ((Board) oid).getId(); - } + if (oid == null) { + return null; + } + if (oid instanceof String) { + return (String) oid; + } + if (oid instanceof Board) { + return ((Board) oid).getId(); + } boolean debug = MassiveCoreMConf.get().debugEnabled; String ret = MUtil.extract(String.class, "worldName", oid); @@ -72,25 +72,25 @@ public class BoardColl extends Coll implements BoardInterface { @Override public TerritoryAccess getTerritoryAccessAt(PS ps) { - if (ps == null) { - throw new NullPointerException("ps"); - } + if (ps == null) { + throw new NullPointerException("ps"); + } Board board = this.get(ps.getWorld()); - if (board == null) { - return null; - } + if (board == null) { + return null; + } return board.getTerritoryAccessAt(ps); } @Override public Faction getFactionAt(PS ps) { - if (ps == null) { - throw new NullPointerException("ps"); - } + if (ps == null) { + throw new NullPointerException("ps"); + } Board board = this.get(ps.getWorld()); - if (board == null) { - return null; - } + if (board == null) { + return null; + } return board.getFactionAt(ps); } @@ -98,25 +98,25 @@ public class BoardColl extends Coll implements BoardInterface { @Override public void setTerritoryAccessAt(PS ps, TerritoryAccess territoryAccess) { - if (ps == null) { - throw new NullPointerException("ps"); - } + if (ps == null) { + throw new NullPointerException("ps"); + } Board board = this.get(ps.getWorld()); - if (board == null) { - return; - } + if (board == null) { + return; + } board.setTerritoryAccessAt(ps, territoryAccess); } @Override public void setFactionAt(PS ps, Faction faction) { - if (ps == null) { - throw new NullPointerException("ps"); - } + if (ps == null) { + throw new NullPointerException("ps"); + } Board board = this.get(ps.getWorld()); - if (board == null) { - return; - } + if (board == null) { + return; + } board.setFactionAt(ps, faction); } @@ -124,13 +124,13 @@ public class BoardColl extends Coll implements BoardInterface { @Override public void removeAt(PS ps) { - if (ps == null) { - throw new NullPointerException("ps"); - } + if (ps == null) { + throw new NullPointerException("ps"); + } Board board = this.get(ps.getWorld()); - if (board == null) { - return; - } + if (board == null) { + return; + } board.removeAt(ps); } @@ -190,9 +190,9 @@ public class BoardColl extends Coll implements BoardInterface { } // Enforce create - if (ret == null) { - ret = new MassiveMap<>(); - } + if (ret == null) { + ret = new MassiveMap<>(); + } // Return return ret; @@ -250,13 +250,13 @@ public class BoardColl extends Coll implements BoardInterface { @Override public boolean isBorderPs(PS ps) { - if (ps == null) { - throw new NullPointerException("ps"); - } + if (ps == null) { + throw new NullPointerException("ps"); + } Board board = this.get(ps.getWorld()); - if (board == null) { - return false; - } + if (board == null) { + return false; + } return board.isBorderPs(ps); } @@ -267,22 +267,22 @@ public class BoardColl extends Coll implements BoardInterface { @Override public boolean isConnectedPs(PS ps, Faction faction) { - if (ps == null) { - throw new NullPointerException("ps"); - } + if (ps == null) { + throw new NullPointerException("ps"); + } Board board = this.get(ps.getWorld()); - if (board == null) { - return false; - } + if (board == null) { + return false; + } return board.isConnectedPs(ps, faction); } @Override public boolean isAnyConnectedPs(Set pss, Faction faction) { for (PS ps : pss) { - if (this.isConnectedPs(ps, faction)) { - return true; - } + if (this.isConnectedPs(ps, faction)) { + return true; + } } return false; } @@ -296,9 +296,9 @@ public class BoardColl extends Coll implements BoardInterface { } public Set getClaimedWorlds(String factionId) { - if (factionId == null) { - throw new NullPointerException("factionId"); - } + if (factionId == null) { + throw new NullPointerException("factionId"); + } return this.getAll().stream() .filter(board -> board.hasClaimed(factionId)) .map(Board::getId) @@ -314,29 +314,29 @@ public class BoardColl extends Coll implements BoardInterface { // Distance 1 returns 3x3 = 9 chunks. public static Set getNearbyChunks(PS psChunk, int distance) { // Fix Args - if (psChunk == null) { - throw new NullPointerException("psChunk"); - } + if (psChunk == null) { + throw new NullPointerException("psChunk"); + } psChunk = psChunk.getChunk(true); // Create Set ret = new MassiveSet<>(); - if (distance < 0) { - return ret; - } + if (distance < 0) { + return ret; + } // Fill int chunkX = psChunk.getChunkX(); - int xmin = chunkX - distance; - int xmax = chunkX + distance; + int xMin = chunkX - distance; + int xMax = chunkX + distance; int chunkZ = psChunk.getChunkZ(); - int zmin = chunkZ - distance; - int zmax = chunkZ + distance; + int zMin = chunkZ - distance; + int zMax = chunkZ + distance; - for (int x = xmin; x <= xmax; x++) { + for (int x = xMin; x <= xMax; x++) { PS psChunkX = psChunk.withChunkX(x); - for (int z = zmin; z <= zmax; z++) { + for (int z = zMin; z <= zMax; z++) { ret.add(psChunkX.withChunkZ(z)); } } @@ -347,16 +347,16 @@ public class BoardColl extends Coll implements BoardInterface { public static Set getNearbyChunks(Collection chunks, int distance) { // Fix Args - if (chunks == null) { - throw new NullPointerException("chunks"); - } + if (chunks == null) { + throw new NullPointerException("chunks"); + } // Create Set ret = new MassiveSet<>(); - if (distance < 0) { - return ret; - } + if (distance < 0) { + return ret; + } // Fill for (PS chunk : chunks) { @@ -369,9 +369,9 @@ public class BoardColl extends Coll implements BoardInterface { public static Set getDistinctFactions(Collection chunks) { // Fix Args - if (chunks == null) { - throw new NullPointerException("chunks"); - } + if (chunks == null) { + throw new NullPointerException("chunks"); + } // Create Set ret = new MassiveSet<>(); @@ -379,9 +379,9 @@ public class BoardColl extends Coll implements BoardInterface { // Fill for (PS chunk : chunks) { Faction faction = get().getFactionAt(chunk); - if (faction == null) { - continue; - } + if (faction == null) { + continue; + } ret.add(faction); } @@ -398,9 +398,9 @@ public class BoardColl extends Coll implements BoardInterface { for (PS chunk : chunks) { chunk = chunk.getChunk(true); Faction faction = get().getFactionAt(chunk); - if (faction == null) { - faction = none; - } + if (faction == null) { + faction = none; + } ret.put(chunk, faction); } @@ -414,9 +414,9 @@ public class BoardColl extends Coll implements BoardInterface { outer: for (PS ps : pss) { - if (discovered.contains(ps)) { - continue outer; - } + if (discovered.contains(ps)) { + continue outer; + } List forest = new MassiveList<>(); forests.add(forest); @@ -426,9 +426,9 @@ public class BoardColl extends Coll implements BoardInterface { inner: while (!stack.empty()) { PS elm = stack.pop(); - if (discovered.contains(elm)) { - continue inner; - } + if (discovered.contains(elm)) { + continue inner; + } System.out.println(elm); discovered.add(elm); forest.add(elm); @@ -444,9 +444,9 @@ public class BoardColl extends Coll implements BoardInterface { } private static void addIfInSource(PS ps, Stack stack, Collection source) { - if (source.contains(ps)) { - stack.push(ps); - } + if (source.contains(ps)) { + stack.push(ps); + } } } diff --git a/src/main/java/net/knarcraft/factions/entity/BoardInterface.java b/src/main/java/net/knarcraft/factions/entity/BoardInterface.java index ec7a7e43..03946721 100644 --- a/src/main/java/net/knarcraft/factions/entity/BoardInterface.java +++ b/src/main/java/net/knarcraft/factions/entity/BoardInterface.java @@ -1,7 +1,7 @@ package net.knarcraft.factions.entity; -import net.knarcraft.factions.TerritoryAccess; import com.massivecraft.massivecore.ps.PS; +import net.knarcraft.factions.TerritoryAccess; import java.util.Map; import java.util.Set; diff --git a/src/main/java/net/knarcraft/factions/entity/Faction.java b/src/main/java/net/knarcraft/factions/entity/Faction.java index 9434e29f..f955923a 100644 --- a/src/main/java/net/knarcraft/factions/entity/Faction.java +++ b/src/main/java/net/knarcraft/factions/entity/Faction.java @@ -1,16 +1,6 @@ package net.knarcraft.factions.entity; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.FactionsIndex; -import net.knarcraft.factions.FactionsParticipator; -import net.knarcraft.factions.Rel; -import net.knarcraft.factions.RelationParticipator; -import net.knarcraft.factions.entity.MPerm.MPermable; -import net.knarcraft.factions.predicate.PredicateCommandSenderFaction; -import net.knarcraft.factions.predicate.PredicateMPlayerRank; -import net.knarcraft.factions.util.MiscUtil; -import net.knarcraft.factions.util.RelationUtil; import com.massivecraft.massivecore.Couple; import com.massivecraft.massivecore.Identified; import com.massivecraft.massivecore.collections.MassiveList; @@ -28,6 +18,16 @@ import com.massivecraft.massivecore.store.SenderColl; import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.FactionsIndex; +import net.knarcraft.factions.FactionsParticipator; +import net.knarcraft.factions.Rel; +import net.knarcraft.factions.RelationParticipator; +import net.knarcraft.factions.entity.MPerm.MPermable; +import net.knarcraft.factions.predicate.PredicateCommandSenderFaction; +import net.knarcraft.factions.predicate.PredicateMPlayerRank; +import net.knarcraft.factions.util.MiscUtil; +import net.knarcraft.factions.util.RelationUtil; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -87,9 +87,9 @@ public class Faction extends Entity implements FactionsParticipator, MP @Override public void preDetach(String id) { - if (!this.isLive()) { - return; - } + if (!this.isLive()) { + return; + } // NOTE: Existence check is required for compatibility with some plugins. // If they have money ... @@ -131,7 +131,7 @@ public class Faction extends Entity implements FactionsParticipator, MP private long createdAtMillis = System.currentTimeMillis(); // Factions can set a few significant locations (warps) - private EntityInternalMap warps = new EntityInternalMap<>(this, Warp.class); + private final EntityInternalMap warps = new EntityInternalMap<>(this, Warp.class); // Factions usually do not have a powerboost. It defaults to 0. // The powerBoost is a custom increase/decrease to default and maximum power. @@ -144,13 +144,13 @@ public class Faction extends Entity implements FactionsParticipator, MP // This is the ids of the invited players. // They are actually "senderIds" since you can invite "@console" to your faction. - private EntityInternalMap invitations = new EntityInternalMap<>(this, Invitation.class); + private final EntityInternalMap invitations = new EntityInternalMap<>(this, Invitation.class); // This is where all the ranks are, they are faction specific - private EntityInternalMap ranks = this.createRankMap(); + private final EntityInternalMap ranks = this.createRankMap(); // This is the votes currently open in the faction - private EntityInternalMap votes = new EntityInternalMap<>(this, Vote.class); + private final EntityInternalMap votes = new EntityInternalMap<>(this, Vote.class); // The keys in this map are factionIds. // Null means no special relation whishes. @@ -164,7 +164,7 @@ public class Faction extends Entity implements FactionsParticipator, MP // What is the base tax on members of the faction? // Specific taxes on ranks or players. - public static transient String IDENTIFIER_TAX_BASE = "base"; + public static final transient String IDENTIFIER_TAX_BASE = "base"; private Map tax = new MassiveMap<>(); @@ -195,15 +195,14 @@ public class Faction extends Entity implements FactionsParticipator, MP public void setName(String name) { // Clean input - String target = name; // Detect Nochange - if (MUtil.equals(this.name, target)) { - return; - } + if (MUtil.equals(this.name, name)) { + return; + } // Apply - this.name = target; + this.name = name; // Mark as changed this.changed(); @@ -220,9 +219,9 @@ public class Faction extends Entity implements FactionsParticipator, MP } public String getName(RelationParticipator observer) { - if (observer == null) { - return getName(); - } + if (observer == null) { + return getName(); + } return this.getName(this.getColorTo(observer).toString()); } @@ -245,9 +244,9 @@ public class Faction extends Entity implements FactionsParticipator, MP String target = clean(description); // Detect Nochange - if (MUtil.equals(this.description, target)) { - return; - } + if (MUtil.equals(this.description, target)) { + return; + } // Apply this.description = target; @@ -260,9 +259,9 @@ public class Faction extends Entity implements FactionsParticipator, MP public String getDescriptionDesc() { String motd = this.getDescription(); - if (motd == null) { - motd = NODESCRIPTION; - } + if (motd == null) { + motd = NODESCRIPTION; + } return motd; } @@ -285,9 +284,9 @@ public class Faction extends Entity implements FactionsParticipator, MP String target = clean(motd); // Detect Nochange - if (MUtil.equals(this.motd, target)) { - return; - } + if (MUtil.equals(this.motd, target)) { + return; + } // Apply this.motd = target; @@ -303,9 +302,9 @@ public class Faction extends Entity implements FactionsParticipator, MP } private static String getMotdDesc(String motd) { - if (motd == null) { - motd = NOMOTD; - } + if (motd == null) { + motd = NOMOTD; + } return motd; } @@ -339,9 +338,9 @@ public class Faction extends Entity implements FactionsParticipator, MP public void setCreatedAtMillis(long createdAtMillis) { // Detect Nochange - if (MUtil.equals(this.createdAtMillis, createdAtMillis)) { - return; - } + if (MUtil.equals(this.createdAtMillis, createdAtMillis)) { + return; + } // Apply this.createdAtMillis = createdAtMillis; @@ -367,28 +366,28 @@ public class Faction extends Entity implements FactionsParticipator, MP } public Warp getWarp(Object oid) { - if (oid == null) { - throw new NullPointerException("oid"); - } + if (oid == null) { + throw new NullPointerException("oid"); + } Warp warp = this.getWarps().get(oid); - if (warp == null) { - return null; - } + if (warp == null) { + return null; + } - if (!warp.verifyIsValid()) { - return null; - } + if (!warp.verifyIsValid()) { + return null; + } return warp; } public PS getWarpPS(Object oid) { - if (oid == null) { - throw new NullPointerException("oid"); - } + if (oid == null) { + throw new NullPointerException("oid"); + } Warp warp = this.getWarp(oid); - if (warp == null) { - return null; - } + if (warp == null) { + return null; + } return warp.getLocation(); } @@ -408,9 +407,9 @@ public class Faction extends Entity implements FactionsParticipator, MP @Override public double getPowerBoost() { Double ret = this.powerBoost; - if (ret == null) { - ret = 0D; - } + if (ret == null) { + ret = 0D; + } return ret; } @@ -419,14 +418,14 @@ public class Faction extends Entity implements FactionsParticipator, MP // Clean input Double target = powerBoost; - if (target == null || target == 0) { - target = null; - } + if (target == null || target == 0) { + target = null; + } // Detect Nochange - if (MUtil.equals(this.powerBoost, target)) { - return; - } + if (MUtil.equals(this.powerBoost, target)) { + return; + } // Apply this.powerBoost = target; @@ -440,29 +439,29 @@ public class Faction extends Entity implements FactionsParticipator, MP // -------------------------------------------- // public double getMoney() { - if (!MConf.get().econEnabled) { - throw new UnsupportedOperationException("econ not enabled"); - } - if (!MConf.get().bankEnabled) { - throw new UnsupportedOperationException("bank not enabled"); - } - if (!MConf.get().useNewMoneySystem) { - throw new UnsupportedOperationException("this server does not use the new econ system"); - } + if (!MConf.get().econEnabled) { + throw new UnsupportedOperationException("econ not enabled"); + } + if (!MConf.get().bankEnabled) { + throw new UnsupportedOperationException("bank not enabled"); + } + if (!MConf.get().useNewMoneySystem) { + throw new UnsupportedOperationException("this server does not use the new econ system"); + } return this.convertGet(this.money, 0D); } public void setMoney(Double money) { - if (!MConf.get().econEnabled) { - throw new UnsupportedOperationException("econ not enabled"); - } - if (!MConf.get().bankEnabled) { - throw new UnsupportedOperationException("bank not enabled"); - } - if (!MConf.get().useNewMoneySystem) { - throw new UnsupportedOperationException("this server does not use the new econ system"); - } + if (!MConf.get().econEnabled) { + throw new UnsupportedOperationException("econ not enabled"); + } + if (!MConf.get().bankEnabled) { + throw new UnsupportedOperationException("bank not enabled"); + } + if (!MConf.get().useNewMoneySystem) { + throw new UnsupportedOperationException("this server does not use the new econ system"); + } this.money = this.convertSet(money, this.money, 0D); } @@ -517,9 +516,9 @@ public class Faction extends Entity implements FactionsParticipator, MP } public Rank getRank(String rankId) { - if (rankId == null) { - throw new NullPointerException("rankId"); - } + if (rankId == null) { + throw new NullPointerException("rankId"); + } return this.getRanks().getFixed(rankId); } @@ -536,9 +535,9 @@ public class Faction extends Entity implements FactionsParticipator, MP public Rank getLeaderRank() { Rank ret = null; for (Rank rank : this.getRanks().getAll()) { - if (ret != null && ret.isMoreThan(rank)) { - continue; - } + if (ret != null && ret.isMoreThan(rank)) { + continue; + } ret = rank; } @@ -548,9 +547,9 @@ public class Faction extends Entity implements FactionsParticipator, MP public Rank getLowestRank() { Rank ret = null; for (Rank rank : this.getRanks().getAll()) { - if (ret != null && ret.isLessThan(rank)) { - continue; - } + if (ret != null && ret.isLessThan(rank)) { + continue; + } ret = rank; } @@ -568,16 +567,16 @@ public class Faction extends Entity implements FactionsParticipator, MP } public void addVote(Vote vote) { - if (vote == null) { - throw new NullPointerException("vote"); - } + if (vote == null) { + throw new NullPointerException("vote"); + } this.getVotes().attach(vote); } public Optional getVoteByName(String name) { - if (name == null) { - throw new NullPointerException("name"); - } + if (name == null) { + throw new NullPointerException("name"); + } return this.getVotes().getAll().stream().filter(vote -> vote.getName().equalsIgnoreCase(name)).findFirst(); } @@ -596,9 +595,9 @@ public class Faction extends Entity implements FactionsParticipator, MP MassiveMapDef target = new MassiveMapDef<>(relationWishes); // Detect Nochange - if (MUtil.equals(this.relationWishes, target)) { - return; - } + if (MUtil.equals(this.relationWishes, target)) { + return; + } // Apply this.relationWishes = target; @@ -611,9 +610,9 @@ public class Faction extends Entity implements FactionsParticipator, MP public Rel getRelationWish(String factionId) { Rel ret = this.getRelationWishes().get(factionId); - if (ret == null) { - ret = Rel.NEUTRAL; - } + if (ret == null) { + ret = Rel.NEUTRAL; + } return ret; } @@ -664,9 +663,9 @@ public class Faction extends Entity implements FactionsParticipator, MP // ... resolve object and skip unknowns ... MFlag mflag = MFlag.get(id); - if (mflag == null) { - continue; - } + if (mflag == null) { + continue; + } ret.put(mflag, entry.getValue()); } @@ -687,23 +686,23 @@ public class Faction extends Entity implements FactionsParticipator, MP MassiveMapDef target = new MassiveMapDef<>(); for (Map.Entry entry : flagIds.entrySet()) { String key = entry.getKey(); - if (key == null) { - continue; - } + if (key == null) { + continue; + } key = key.toLowerCase(); // Lowercased Keys Version 2.6.0 --> 2.7.0 Boolean value = entry.getValue(); - if (value == null) { - continue; - } + if (value == null) { + continue; + } target.put(key, value); } // Detect Nochange - if (MUtil.equals(this.flags, target)) { - return; - } + if (MUtil.equals(this.flags, target)) { + return; + } // Apply this.flags = new MassiveMapDef<>(target); @@ -715,67 +714,67 @@ public class Faction extends Entity implements FactionsParticipator, MP // FINER public boolean getFlag(String flagId) { - if (flagId == null) { - throw new NullPointerException("flagId"); - } + if (flagId == null) { + throw new NullPointerException("flagId"); + } Boolean ret = this.flags.get(flagId); - if (ret != null) { - return ret; - } + if (ret != null) { + return ret; + } MFlag flag = MFlag.get(flagId); - if (flag == null) { - throw new NullPointerException("flag"); - } + if (flag == null) { + throw new NullPointerException("flag"); + } return flag.isStandard(); } public boolean getFlag(MFlag flag) { - if (flag == null) { - throw new NullPointerException("flag"); - } + if (flag == null) { + throw new NullPointerException("flag"); + } String flagId = flag.getId(); - if (flagId == null) { - throw new NullPointerException("flagId"); - } + if (flagId == null) { + throw new NullPointerException("flagId"); + } Boolean ret = this.flags.get(flagId); - if (ret != null) { - return ret; - } + if (ret != null) { + return ret; + } return flag.isStandard(); } public Boolean setFlag(String flagId, boolean value) { - if (flagId == null) { - throw new NullPointerException("flagId"); - } + if (flagId == null) { + throw new NullPointerException("flagId"); + } Boolean ret = this.flags.put(flagId, value); - if (ret == null || ret != value) { - this.changed(); - } + if (ret == null || ret != value) { + this.changed(); + } return ret; } public Boolean setFlag(MFlag flag, boolean value) { - if (flag == null) { - throw new NullPointerException("flag"); - } + if (flag == null) { + throw new NullPointerException("flag"); + } String flagId = flag.getId(); - if (flagId == null) { - throw new NullPointerException("flagId"); - } + if (flagId == null) { + throw new NullPointerException("flagId"); + } Boolean ret = this.flags.put(flagId, value); - if (ret == null || ret != value) { - this.changed(); - } + if (ret == null || ret != value) { + this.changed(); + } return ret; } @@ -819,20 +818,16 @@ public class Faction extends Entity implements FactionsParticipator, MP // IS PERMITTED public boolean isPlayerPermitted(MPlayer mplayer, String permId) { - if (isPermitted(mplayer.getId(), permId)) { - return true; - } - if (isPermitted(mplayer.getFaction().getId(), permId)) { - return true; - } - if (isPermitted(mplayer.getRank().getId(), permId)) { - return true; - } - if (isPermitted(RelationUtil.getRelationOfThatToMe(mplayer, this).toString(), permId)) { - return true; - } - - return false; + if (isPermitted(mplayer.getId(), permId)) { + return true; + } + if (isPermitted(mplayer.getFaction().getId(), permId)) { + return true; + } + if (isPermitted(mplayer.getRank().getId(), permId)) { + return true; + } + return isPermitted(RelationUtil.getRelationOfThatToMe(mplayer, this).toString(), permId); } public boolean isPlayerPermitted(MPlayer mplayer, MPerm mperm) { @@ -840,14 +835,10 @@ public class Faction extends Entity implements FactionsParticipator, MP } public boolean isFactionPermitted(Faction faction, String permId) { - if (isPermitted(faction.getId(), permId)) { - return true; - } - if (isPermitted(RelationUtil.getRelationOfThatToMe(faction, this).toString(), permId)) { - return true; - } - - return false; + if (isPermitted(faction.getId(), permId)) { + return true; + } + return isPermitted(RelationUtil.getRelationOfThatToMe(faction, this).toString(), permId); } public boolean isFactionPermitted(Faction faction, MPerm mperm) { @@ -855,17 +846,17 @@ public class Faction extends Entity implements FactionsParticipator, MP } public Set getPermitted(String permId) { - if (permId == null) { - throw new NullPointerException("permId"); - } + if (permId == null) { + throw new NullPointerException("permId"); + } Set permables = this.perms.get(permId); if (permables == null) { // No perms was found, but likely this is just a new MPerm. // So if this does not exist in the database, throw an error. - if (!doesPermExist(permId)) { - throw new NullPointerException(permId + " caused null"); - } + if (!doesPermExist(permId)) { + throw new NullPointerException(permId + " caused null"); + } permables = new MassiveSet<>(); this.perms.put(permId, permables); @@ -887,21 +878,21 @@ public class Faction extends Entity implements FactionsParticipator, MP } public boolean isPermitted(String permableId, String permId) { - if (permableId == null) { - throw new NullPointerException("permableId"); - } - if (permId == null) { - throw new NullPointerException("permId"); - } + if (permableId == null) { + throw new NullPointerException("permableId"); + } + if (permId == null) { + throw new NullPointerException("permId"); + } // TODO: Isn't this section redundant and just a copy of that from getPermitted? Set permables = this.perms.get(permId); if (permables == null) { // No perms was found, but likely this is just a new MPerm. // So if this does not exist in the database, throw an error. - if (!doesPermExist(permId)) { - throw new NullPointerException(permId + " caused null"); - } + if (!doesPermExist(permId)) { + throw new NullPointerException(permId + " caused null"); + } // Otherwise handle it return false; @@ -919,9 +910,9 @@ public class Faction extends Entity implements FactionsParticipator, MP if (perms == null) { // No perms was found, but likely this is just a new MPerm. // So if this does not exist in the database, throw an error. - if (!doesPermExist(permId)) { - throw new NullPointerException(permId + " caused null"); - } + if (!doesPermExist(permId)) { + throw new NullPointerException(permId + " caused null"); + } // Otherwise handle it Set permables = new MassiveSet<>(); @@ -934,9 +925,9 @@ public class Faction extends Entity implements FactionsParticipator, MP } else { changed = this.getPerms().get(permId).remove(mpermable.getId()) | changed; } - if (changed) { - this.changed(); - } + if (changed) { + this.changed(); + } return changed; } @@ -969,16 +960,16 @@ public class Faction extends Entity implements FactionsParticipator, MP // FINER GET public Double getTaxFor(String id) { - if (id == null) { - throw new NullPointerException("id"); - } + if (id == null) { + throw new NullPointerException("id"); + } return this.tax.get(id); } public Double getTaxFor(Identified identified) { - if (identified == null) { - throw new NullPointerException("identified"); - } + if (identified == null) { + throw new NullPointerException("identified"); + } return this.getTaxFor(identified.getId()); } @@ -987,30 +978,30 @@ public class Faction extends Entity implements FactionsParticipator, MP } public Optional> getTaxAndReasonForPlayer(MPlayer mplayer) { - if (mplayer == null) { - throw new NullPointerException("mplayer"); - } + if (mplayer == null) { + throw new NullPointerException("mplayer"); + } - if (mplayer.getFaction() != this) { - throw new IllegalArgumentException("Player " + mplayer.getId() + " not in " + this.getId()); - } + if (mplayer.getFaction() != this) { + throw new IllegalArgumentException("Player " + mplayer.getId() + " not in " + this.getId()); + } Double ret = null; ret = this.getTaxFor(mplayer); - if (ret != null) { - return Optional.of(new Couple<>(mplayer.getId(), ret)); - } + if (ret != null) { + return Optional.of(new Couple<>(mplayer.getId(), ret)); + } ret = this.getTaxFor(mplayer.getRank()); - if (ret != null) { - return Optional.of(new Couple<>(mplayer.getRank().getId(), ret)); - } + if (ret != null) { + return Optional.of(new Couple<>(mplayer.getRank().getId(), ret)); + } ret = this.getTaxFor(IDENTIFIER_TAX_BASE); - if (ret != null) { - return Optional.of(new Couple<>(IDENTIFIER_TAX_BASE, ret)); - } + if (ret != null) { + return Optional.of(new Couple<>(IDENTIFIER_TAX_BASE, ret)); + } return Optional.empty(); } @@ -1061,9 +1052,9 @@ public class Faction extends Entity implements FactionsParticipator, MP @Override public String getDisplayName(Object senderObject) { MPlayer mplayer = MPlayer.get(senderObject); - if (mplayer == null) { - return this.getName(); - } + if (mplayer == null) { + return this.getName(); + } return this.describeTo(mplayer); } @@ -1074,9 +1065,9 @@ public class Faction extends Entity implements FactionsParticipator, MP // TODO: Implement a has enough feature. public double getPower() { - if (this.getFlag(MFlag.getFlagInfpower())) { - return 999999; - } + if (this.getFlag(MFlag.getFlagInfpower())) { + return 999999; + } double ret = 0; for (MPlayer mplayer : this.getMPlayers()) { @@ -1090,9 +1081,9 @@ public class Faction extends Entity implements FactionsParticipator, MP } public double getPowerMax() { - if (this.getFlag(MFlag.getFlagInfpower())) { - return 999999; - } + if (this.getFlag(MFlag.getFlagInfpower())) { + return 999999; + } double ret = 0; for (MPlayer mplayer : this.getMPlayers()) { @@ -1170,9 +1161,9 @@ public class Faction extends Entity implements FactionsParticipator, MP public MPlayer getLeader() { List ret = this.getMPlayersWhereRank(this.getLeaderRank()); - if (ret.size() == 0) { - return null; - } + if (ret.size() == 0) { + return null; + } return ret.get(0); } @@ -1186,14 +1177,14 @@ public class Faction extends Entity implements FactionsParticipator, MP // Fill Ret for (CommandSender sender : IdUtil.getLocalSenders()) { - if (MUtil.isntSender(sender)) { - continue; - } + if (MUtil.isntSender(sender)) { + continue; + } MPlayer mplayer = MPlayer.get(sender); - if (mplayer.getFaction() != this) { - continue; - } + if (mplayer.getFaction() != this) { + continue; + } ret.add(sender); } @@ -1208,14 +1199,14 @@ public class Faction extends Entity implements FactionsParticipator, MP // Fill Ret for (Player player : Bukkit.getOnlinePlayers()) { - if (MUtil.isntPlayer(player)) { - continue; - } + if (MUtil.isntPlayer(player)) { + continue; + } MPlayer mplayer = MPlayer.get(player); - if (mplayer.getFaction() != this) { - continue; - } + if (mplayer.getFaction() != this) { + continue; + } ret.add(player); } @@ -1226,12 +1217,12 @@ public class Faction extends Entity implements FactionsParticipator, MP // used when current leader is about to be removed from the faction; promotes new leader, or disbands faction if no other members left public void promoteNewLeader() { - if (!this.isNormal()) { - return; - } - if (this.getFlag(MFlag.getFlagPermanent()) && MConf.get().permanentFactionsDisableLeaderPromotion) { - return; - } + if (!this.isNormal()) { + return; + } + if (this.getFlag(MFlag.getFlagPermanent()) && MConf.get().permanentFactionsDisableLeaderPromotion) { + return; + } MPlayer oldLeader = this.getLeader(); Rank leaderRank = oldLeader.getRank(); @@ -1239,14 +1230,14 @@ public class Faction extends Entity implements FactionsParticipator, MP List replacements = Collections.emptyList(); for (Rank rank = leaderRank; rank != null; rank = rank.getRankBelow()) { //Skip first - if (rank == leaderRank) { - continue; - } + if (rank == leaderRank) { + continue; + } replacements = this.getMPlayersWhereRank(rank); - if (!replacements.isEmpty()) { - break; - } + if (!replacements.isEmpty()) { + break; + } } // if we found a replacement @@ -1305,12 +1296,12 @@ public class Faction extends Entity implements FactionsParticipator, MP boolean explosions = this.getFlag(MFlag.getFlagExplosions()); boolean offlineexplosions = this.getFlag(MFlag.getFlagOfflineexplosions()); - if (explosions && offlineexplosions) { - return true; - } - if (!explosions && !offlineexplosions) { - return false; - } + if (explosions && offlineexplosions) { + return true; + } + if (!explosions && !offlineexplosions) { + return false; + } boolean online = this.isFactionConsideredOnline(); @@ -1357,14 +1348,14 @@ public class Faction extends Entity implements FactionsParticipator, MP // FIXME this probably needs to be moved elsewhere public static String clean(String message) { String target = message; - if (target == null) { - return null; - } + if (target == null) { + return null; + } target = target.trim(); - if (target.isEmpty()) { - target = null; - } + if (target.isEmpty()) { + target = null; + } return target; } diff --git a/src/main/java/net/knarcraft/factions/entity/FactionColl.java b/src/main/java/net/knarcraft/factions/entity/FactionColl.java index 2d36cb68..a5dffc40 100644 --- a/src/main/java/net/knarcraft/factions/entity/FactionColl.java +++ b/src/main/java/net/knarcraft/factions/entity/FactionColl.java @@ -1,11 +1,11 @@ package net.knarcraft.factions.entity; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.Rel; -import net.knarcraft.factions.util.MiscUtil; import com.massivecraft.massivecore.collections.MassiveMap; import com.massivecraft.massivecore.store.Coll; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.Rel; +import net.knarcraft.factions.util.MiscUtil; import java.util.ArrayList; import java.util.Collections; @@ -18,7 +18,7 @@ public class FactionColl extends Coll { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static FactionColl i = new FactionColl(); + private static final FactionColl i = new FactionColl(); public static FactionColl get() { return i; @@ -41,9 +41,9 @@ public class FactionColl extends Coll { public void setActive(boolean active) { super.setActive(active); - if (!active) { - return; - } + if (!active) { + return; + } this.createSpecialFactions(); @@ -63,9 +63,9 @@ public class FactionColl extends Coll { public Faction getNone() { String id = Factions.ID_NONE; Faction faction = this.get(id); - if (faction != null) { - return faction; - } + if (faction != null) { + return faction; + } faction = this.create(id); @@ -100,9 +100,9 @@ public class FactionColl extends Coll { public Faction getSafezone() { String id = Factions.ID_SAFEZONE; Faction faction = this.get(id); - if (faction != null) { - return faction; - } + if (faction != null) { + return faction; + } faction = this.create(id); @@ -135,9 +135,9 @@ public class FactionColl extends Coll { public Faction getWarzone() { String id = Factions.ID_WARZONE; Faction faction = this.get(id); - if (faction != null) { - return faction; - } + if (faction != null) { + return faction; + } faction = this.create(id); @@ -197,29 +197,29 @@ public class FactionColl extends Coll { // Fill for (Faction fac : FactionColl.get().getAll()) { - if (fac.getFlag(flagPeaceful)) { - continue; - } + if (fac.getFlag(flagPeaceful)) { + continue; + } Rel rel = fac.getRelationTo(faction); List names = ret.get(rel); - if (names == null) { - continue; - } + if (names == null) { + continue; + } String name = fac.describeTo(faction, true); names.add(name); } // Replace TRUCE if peaceful - if (!peaceful) { - return ret; - } + if (!peaceful) { + return ret; + } List names = ret.get(Rel.TRUCE); - if (names == null) { - return ret; - } + if (names == null) { + return ret; + } ret.put(Rel.TRUCE, Collections.singletonList(MConf.get().colorTruce.toString() + Txt.parse("*EVERYONE*"))); diff --git a/src/main/java/net/knarcraft/factions/entity/MConf.java b/src/main/java/net/knarcraft/factions/entity/MConf.java index de470722..de42895a 100644 --- a/src/main/java/net/knarcraft/factions/entity/MConf.java +++ b/src/main/java/net/knarcraft/factions/entity/MConf.java @@ -1,11 +1,5 @@ package net.knarcraft.factions.entity; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.Rel; -import net.knarcraft.factions.engine.EngineChat; -import net.knarcraft.factions.event.EventFactionsChunkChangeType; -import net.knarcraft.factions.integration.dynmap.DynmapStyle; -import net.knarcraft.factions.integration.dynmap.IntegrationDynmap; import com.massivecraft.massivecore.collections.BackstringSet; import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.collections.WorldExceptionSet; @@ -17,6 +11,12 @@ import com.massivecraft.massivecore.command.type.TypeMillisDiff; import com.massivecraft.massivecore.store.Entity; import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.TimeUnit; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.Rel; +import net.knarcraft.factions.engine.EngineChat; +import net.knarcraft.factions.event.EventFactionsChunkChangeType; +import net.knarcraft.factions.integration.dynmap.DynmapStyle; +import net.knarcraft.factions.integration.dynmap.IntegrationDynmap; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.EntityType; @@ -69,7 +69,7 @@ public class MConf extends Entity { // -------------------------------------------- // // Don't you want "f" as the base command alias? Simply change it here. - public List aliasesF = MUtil.list("f"); + public final List aliasesF = MUtil.list("f"); // -------------------------------------------- // // WORLDS FEATURE ENABLED @@ -78,11 +78,11 @@ public class MConf extends Entity { // Use this blacklist/whitelist system to toggle features on a per world basis. // Do you only want claiming enabled on the one map called "Hurr"? // In such case set standard to false and add "Hurr" as an exeption to worldsClaimingEnabled. - public WorldExceptionSet worldsClaimingEnabled = new WorldExceptionSet(); - public WorldExceptionSet worldsPowerLossEnabled = new WorldExceptionSet(); - public WorldExceptionSet worldsPowerGainEnabled = new WorldExceptionSet(); + public final WorldExceptionSet worldsClaimingEnabled = new WorldExceptionSet(); + public final WorldExceptionSet worldsPowerLossEnabled = new WorldExceptionSet(); + public final WorldExceptionSet worldsPowerGainEnabled = new WorldExceptionSet(); - public WorldExceptionSet worldsPvpRulesEnabled = new WorldExceptionSet(); + public final WorldExceptionSet worldsPvpRulesEnabled = new WorldExceptionSet(); // -------------------------------------------- // // DERPY OVERRIDES @@ -91,30 +91,30 @@ public class MConf extends Entity { // Add player names here who should bypass all protections. // Should /not/ be used for admins. There is "/f adminmode" for that. // This is for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections. - public Set playersWhoBypassAllProtection = new MassiveSet<>(); + public final Set playersWhoBypassAllProtection = new MassiveSet<>(); // -------------------------------------------- // // REMOVE DATA // -------------------------------------------- // // Should players be kicked from their faction and their data erased when banned? - public boolean removePlayerWhenBanned = true; + public final boolean removePlayerWhenBanned = true; // After how many milliseconds should players be automatically kicked from their faction? // The Default @EditorType(TypeMillisDiff.class) - public long cleanInactivityToleranceMillis = 10 * TimeUnit.MILLIS_PER_DAY; // 10 days + public final long cleanInactivityToleranceMillis = 10 * TimeUnit.MILLIS_PER_DAY; // 10 days // Player Age Bonus @EditorTypeInner({TypeMillisDiff.class, TypeMillisDiff.class}) - public Map cleanInactivityToleranceMillisPlayerAgeToBonus = MUtil.map( + public final Map cleanInactivityToleranceMillisPlayerAgeToBonus = MUtil.map( 2 * TimeUnit.MILLIS_PER_WEEK, 10 * TimeUnit.MILLIS_PER_DAY // +10 days after 2 weeks ); // Faction Age Bonus @EditorTypeInner({TypeMillisDiff.class, TypeMillisDiff.class}) - public Map cleanInactivityToleranceMillisFactionAgeToBonus = MUtil.map( + public final Map cleanInactivityToleranceMillisFactionAgeToBonus = MUtil.map( 4 * TimeUnit.MILLIS_PER_WEEK, 10 * TimeUnit.MILLIS_PER_DAY, // +10 days after 4 weeks 2 * TimeUnit.MILLIS_PER_WEEK, 5 * TimeUnit.MILLIS_PER_DAY // +5 days after 2 weeks ); @@ -125,10 +125,10 @@ public class MConf extends Entity { // Which faction should new players be followers of? // "none" means Wilderness. Remember to specify the id, like "3defeec7-b3b1-48d9-82bb-2a8903df24e3" and not the name. - public String defaultPlayerFactionId = Factions.ID_NONE; + public final String defaultPlayerFactionId = Factions.ID_NONE; // What power should the player start with? - public double defaultPlayerPower = 0.0; + public final double defaultPlayerPower = 0.0; // -------------------------------------------- // // MOTD @@ -137,34 +137,34 @@ public class MConf extends Entity { // During which event priority should the faction message of the day be displayed? // Choose between: LOWEST, LOW, NORMAL, HIGH, HIGHEST and MONITOR. // This setting only matters if "motdDelayTicks" is set to -1 - public EventPriority motdPriority = EventPriority.NORMAL; + public final EventPriority motdPriority = EventPriority.NORMAL; // How many ticks should we delay the faction message of the day with? // -1 means we don't delay at all. We display it at once. // 0 means it's deferred to the upcoming server tick. // 5 means we delay it yet another 5 ticks. - public int motdDelayTicks = -1; + public final int motdDelayTicks = -1; // -------------------------------------------- // // POWER // -------------------------------------------- // // What is the maximum player power? - public double powerMax = 10.0; + public final double powerMax = 10.0; // What is the minimum player power? // NOTE: Negative minimum values is possible. - public double powerMin = 0.0; + public final double powerMin = 0.0; // How much power should be regained per hour online on the server? - public double powerPerHour = 2.0; + public final double powerPerHour = 2.0; // How much power should be lost on death? - public double powerPerDeath = -2.0; + public final double powerPerDeath = -2.0; // Can players with negative power leave their faction? // NOTE: This only makes sense to set to false if your "powerMin" setting is negative. - public boolean canLeaveWithNegativePower = true; + public final boolean canLeaveWithNegativePower = true; // -------------------------------------------- // // CORE @@ -172,25 +172,25 @@ public class MConf extends Entity { // Is there a maximum amount of members per faction? // 0 means there is not. If you set it to 100 then there can at most be 100 members per faction. - public int factionMemberLimit = 0; + public final int factionMemberLimit = 0; // Is there a maximum faction power cap? // 0 means there is not. Set it to a positive value in case you wan't to use this feature. - public double factionPowerMax = 0.0; + public final double factionPowerMax = 0.0; // Limit the length of faction names here. - public int factionNameLengthMin = 3; - public int factionNameLengthMax = 16; + public final int factionNameLengthMin = 3; + public final int factionNameLengthMax = 16; // -------------------------------------------- // // SET LIMITS // -------------------------------------------- // // When using radius setting of faction territory, what is the maximum radius allowed? - public int setRadiusMax = 30; + public final int setRadiusMax = 30; // When using fill setting of faction territory, what is the maximum chunk count allowed? - public int setFillMax = 1000; + public final int setFillMax = 1000; // -------------------------------------------- // // CLAIMS @@ -199,53 +199,53 @@ public class MConf extends Entity { // Must claims be connected to each other? // If you set this to false you will allow factions to claim more than one base per world map. // That would makes outposts possible but also potentially ugly weird claims messing up your Dynmap and ingame experiance. - public boolean claimsMustBeConnected = true; + public final boolean claimsMustBeConnected = true; // Must claims be connected to each other enforced strictly? // If this is enabled there is also done a check on // unclaim which makes sure you can't make two different bases by unclaiming land. - public boolean claimsMustBeConnectedStrict = false; + public final boolean claimsMustBeConnectedStrict = false; // Would you like to allow unconnected claims when conquering land from another faction? // Setting this to true would allow taking over someone elses base even if claims normally have to be connected. // Note that even without this you can pillage/unclaim another factions territory in war. // You just won't be able to take the land as your own. - public boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = false; + public final boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = false; // Is claiming from other factions even allowed? // Set this to false to disable territorial warfare altogether. - public boolean claimingFromOthersAllowed = true; + public final boolean claimingFromOthersAllowed = true; // Is it required for factions to have an inflated land/power ratio in order to have their land conquered by another faction? // Set this to false to allow factions to invade each other without requiring them to have an inflated land/power ratio.. - public boolean claimingFromOthersMustBeInflated = true; + public final boolean claimingFromOthersMustBeInflated = true; // Is a minimum distance (measured in chunks) to other factions required? // 0 means the feature is disabled. // Set the feature to 10 and there must be 10 chunks of wilderness between factions. // Factions may optionally allow their allies to bypass this limit by configuring their faction permissions ingame themselves. - public int claimMinimumChunksDistanceToOthers = 0; + public final int claimMinimumChunksDistanceToOthers = 0; // Do you need a minimum amount of faction members to claim land? // 1 means just the faction leader alone is enough. - public int claimsRequireMinFactionMembers = 1; + public final int claimsRequireMinFactionMembers = 1; // Is there a maximum limit to chunks claimed? // 0 means there isn't. - public int claimedLandsMax = 0; + public final int claimedLandsMax = 0; // The max amount of worlds in which a player can have claims in. - public int claimedWorldsMax = -1; + public final int claimedWorldsMax = -1; // -------------------------------------------- // // PROTECTION // -------------------------------------------- // - public boolean protectionLiquidFlowEnabled = true; + public final boolean protectionLiquidFlowEnabled = true; // Protects the faction land from piston extending/retracting // through the denying of MPerm build - public boolean handlePistonProtectionThroughDenyBuild = true; + public final boolean handlePistonProtectionThroughDenyBuild = true; // -------------------------------------------- // // WARPS @@ -253,51 +253,51 @@ public class MConf extends Entity { // Is the warps feature enabled? // If you set this to false players can't set warps or teleport to a warp. - public boolean warpsEnabled = true; + public final boolean warpsEnabled = true; // How many warps can they have? - public int warpsMax = 1; + public final int warpsMax = 1; // Must warps be located inside the faction's territory? // It's usually a wise idea keeping this true. // Otherwise players can set their warps inside enemy territory. - public boolean warpsMustBeInClaimedTerritory = true; + public final boolean warpsMustBeInClaimedTerritory = true; // And what faction warp should be used when a player types /f home - public String warpsHomeName = "home"; + public final String warpsHomeName = "home"; // These options can be used to limit rights to warp under different circumstances. - public boolean warpsTeleportAllowedFromEnemyTerritory = true; - public boolean warpsTeleportAllowedFromDifferentWorld = true; - public double warpsTeleportAllowedEnemyDistance = 32.0; - public boolean warpsTeleportIgnoreEnemiesIfInOwnTerritory = true; + public final boolean warpsTeleportAllowedFromEnemyTerritory = true; + public final boolean warpsTeleportAllowedFromDifferentWorld = true; + public final double warpsTeleportAllowedEnemyDistance = 32.0; + public final boolean warpsTeleportIgnoreEnemiesIfInOwnTerritory = true; // Should players teleport to faction warp on death? // Set this to true to override the default respawn location. - public boolean warpsTeleportToOnDeathActive = false; + public final boolean warpsTeleportToOnDeathActive = false; // And what faction warp should it be? It must have a specific name. - public String warpsTeleportToOnDeathName = "home"; + public final String warpsTeleportToOnDeathName = "home"; // This value can be used to tweak compatibility with other plugins altering the respawn location. // Choose between: LOWEST, LOW, NORMAL, HIGH, HIGHEST and MONITOR. - public EventPriority warpsTeleportToOnDeathPriority = EventPriority.NORMAL; + public final EventPriority warpsTeleportToOnDeathPriority = EventPriority.NORMAL; // -------------------------------------------- // // TERRITORY INFO // -------------------------------------------- // - public boolean territoryInfoTitlesDefault = true; + public final boolean territoryInfoTitlesDefault = true; - public String territoryInfoTitlesMain = "{relcolor}{name}"; - public String territoryInfoTitlesSub = "{desc}"; - public int territoryInfoTitlesTicksIn = 5; - public int territoryInfoTitlesTicksStay = 60; - public int territoryInfoTitleTicksOut = 5; + public final String territoryInfoTitlesMain = "{relcolor}{name}"; + public final String territoryInfoTitlesSub = "{desc}"; + public final int territoryInfoTitlesTicksIn = 5; + public final int territoryInfoTitlesTicksStay = 60; + public final int territoryInfoTitleTicksOut = 5; - public String territoryInfoChat = " ~ {relcolor}{name} {desc}"; + public final String territoryInfoChat = " ~ {relcolor}{name} {desc}"; - public boolean territoryAccessShowMessage = true; + public final boolean territoryAccessShowMessage = true; // -------------------------------------------- // // ASSORTED @@ -305,37 +305,37 @@ public class MConf extends Entity { // Set this to true if want to block the promotion of new leaders for permanent factions. // I don't really understand the user case for this option. - public boolean permanentFactionsDisableLeaderPromotion = false; + public final boolean permanentFactionsDisableLeaderPromotion = false; // How much health damage should a player take upon placing or breaking a block in a "pain build" territory? // 2.0 means one heart. - public double actionDeniedPainAmount = 2.0D; + public final double actionDeniedPainAmount = 2.0D; // If you set this option to true then factionless players cant partake in PVP. // It works in both directions. Meaning you must join a faction to hurt players and get hurt by players. - public boolean disablePVPForFactionlessPlayers = false; + public final boolean disablePVPForFactionlessPlayers = false; // If you set this option to true then factionless players cant damage each other. // So two factionless can't PvP, but they can PvP with others if that is allowed. - public boolean enablePVPBetweenFactionlessPlayers = true; + public final boolean enablePVPBetweenFactionlessPlayers = true; // Set this option to true to create an exception to the rule above. // Players inside their own faction territory can then hurt facitonless players. // This way you may "evict" factionless trolls messing around in your home base. - public boolean enablePVPAgainstFactionlessInAttackersLand = false; + public final boolean enablePVPAgainstFactionlessInAttackersLand = false; // Inside your own faction territory you take less damage. // 0.1 means that you take 10% less damage at home. - public double territoryShieldFactor = 0.1D; + public final double territoryShieldFactor = 0.1D; // Make faction disbanding a confirmation thing - public boolean requireConfirmationForFactionDisbanding = true; + public final boolean requireConfirmationForFactionDisbanding = true; // At what speed can players fly with /f fly? - public float flySpeed = 0.1f; + public final float flySpeed = 0.1f; // Will flying be disabled on pvp - public boolean flyDisableOnPvp = false; + public final boolean flyDisableOnPvp = false; // -------------------------------------------- // // DENY COMMANDS @@ -343,11 +343,11 @@ public class MConf extends Entity { // A list of commands to block for members of permanent factions. // I don't really understand the user case for this option. - public List denyCommandsPermanentFactionMember = new ArrayList<>(); + public final List denyCommandsPermanentFactionMember = new ArrayList<>(); // Lists of commands to deny depending on your relation to the current faction territory. // You may for example not type /home (might be the plugin Essentials) in the territory of your enemies. - public Map> denyCommandsTerritoryRelation = MUtil.map( + public final Map> denyCommandsTerritoryRelation = MUtil.map( Rel.ENEMY, MUtil.list( // Essentials commands "home", @@ -409,10 +409,10 @@ public class MConf extends Entity { ); // The distance for denying the following commands. Set to -1 to disable. - public double denyCommandsDistance = -1; + public final double denyCommandsDistance = -1; // Lists of commands to deny depending on your relation to a nearby enemy in the above distance. - public Map> denyCommandsDistanceRelation = MUtil.map( + public final Map> denyCommandsDistanceRelation = MUtil.map( Rel.ENEMY, MUtil.list( "home" ), @@ -423,7 +423,7 @@ public class MConf extends Entity { ); // Allow bypassing the above setting when in these territories. - public List denyCommandsDistanceBypassIn = MUtil.list( + public final List denyCommandsDistanceBypassIn = MUtil.list( Rel.FACTION, Rel.ALLY ); @@ -435,23 +435,23 @@ public class MConf extends Entity { // Should Factions set the chat format? // This should be kept at false if you use an external chat format plugin. // If you are planning on running a more lightweight server you can set this to true. - public boolean chatSetFormat = true; + public final boolean chatSetFormat = true; // At which event priority should the chat format be set in such case? // Choose between: LOWEST, LOW, NORMAL, HIGH and HIGHEST. - public EventPriority chatSetFormatAt = EventPriority.LOWEST; + public final EventPriority chatSetFormatAt = EventPriority.LOWEST; // What format should be set? - public String chatSetFormatTo = "<{factions_relcolor}§l{factions_roleprefix}§r{factions_relcolor}{factions_name|rp}§f%1$s> %2$s"; + public final String chatSetFormatTo = "<{factions_relcolor}§l{factions_roleprefix}§r{factions_relcolor}{factions_name|rp}§f%1$s> %2$s"; // Should the chat tags such as {factions_name} be parsed? // NOTE: You can set this to true even with chatSetFormat = false. // But in such case you must set the chat format using an external chat format plugin. - public boolean chatParseTags = true; + public final boolean chatParseTags = true; // At which event priority should the faction chat tags be parsed in such case? // Choose between: LOWEST, LOW, NORMAL, HIGH, HIGHEST. - public EventPriority chatParseTagsAt = EventPriority.LOW; + public final EventPriority chatParseTagsAt = EventPriority.LOW; // -------------------------------------------- // // COLORS @@ -460,46 +460,46 @@ public class MConf extends Entity { // Here you can alter the colors tied to certain faction relations and settings. // You probably don't want to edit these to much. // Doing so might confuse players that are used to Factions. - public ChatColor colorMember = ChatColor.GREEN; - public ChatColor colorAlly = ChatColor.DARK_PURPLE; - public ChatColor colorTruce = ChatColor.LIGHT_PURPLE; - public ChatColor colorNeutral = ChatColor.WHITE; - public ChatColor colorEnemy = ChatColor.RED; + public final ChatColor colorMember = ChatColor.GREEN; + public final ChatColor colorAlly = ChatColor.DARK_PURPLE; + public final ChatColor colorTruce = ChatColor.LIGHT_PURPLE; + public final ChatColor colorNeutral = ChatColor.WHITE; + public final ChatColor colorEnemy = ChatColor.RED; // This one is for example applied to SafeZone since that faction has the pvp flag set to false. - public ChatColor colorNoPVP = ChatColor.GOLD; + public final ChatColor colorNoPVP = ChatColor.GOLD; // This one is for example applied to WarZone since that faction has the friendly fire flag set to true. - public ChatColor colorFriendlyFire = ChatColor.DARK_RED; + public final ChatColor colorFriendlyFire = ChatColor.DARK_RED; // -------------------------------------------- // // EXPLOITS // -------------------------------------------- // - public boolean handleExploitObsidianGenerators = true; - public boolean handleExploitEnderPearlClipping = true; - public boolean handleNetherPortalTrap = true; + public final boolean handleExploitObsidianGenerators = true; + public final boolean handleExploitEnderPearlClipping = true; + public final boolean handleNetherPortalTrap = true; // -------------------------------------------- // // UNSTUCK // -------------------------------------------- // - public int unstuckSeconds = 30; - public int unstuckChunkRadius = 10; + public final int unstuckSeconds = 30; + public final int unstuckChunkRadius = 10; // -------------------------------------------- // // ENDER PEARL AND CHORUS FRUIT // -------------------------------------------- // - public boolean allowEnderPearlInEnemyTerritory = true; - public boolean allowEnderPearlInWildernessTerritory = true; - public boolean allowEnderPearlInOwnTerritory = true; - public boolean allowEnderPearlInOtherTerritory = true; + public final boolean allowEnderPearlInEnemyTerritory = true; + public final boolean allowEnderPearlInWildernessTerritory = true; + public final boolean allowEnderPearlInOwnTerritory = true; + public final boolean allowEnderPearlInOtherTerritory = true; - public boolean allowChorusFruitInEnemyTerritory = true; - public boolean allowChorusFruitInWildernessTerritory = true; - public boolean allowChorusFruitInOwnTerritory = true; - public boolean allowChorusFruitInOtherTerritory = true; + public final boolean allowChorusFruitInEnemyTerritory = true; + public final boolean allowChorusFruitInWildernessTerritory = true; + public final boolean allowChorusFruitInOwnTerritory = true; + public final boolean allowChorusFruitInOtherTerritory = true; // -------------------------------------------- // // LOGGING @@ -507,31 +507,31 @@ public class MConf extends Entity { // Here you can disable logging of certain events to the server console. - public boolean logFactionCreate = true; - public boolean logFactionDisband = true; - public boolean logFactionJoin = true; - public boolean logFactionKick = true; - public boolean logFactionLeave = true; - public boolean logLandClaims = true; - public boolean logMoneyTransactions = true; + public final boolean logFactionCreate = true; + public final boolean logFactionDisband = true; + public final boolean logFactionJoin = true; + public final boolean logFactionKick = true; + public final boolean logFactionLeave = true; + public final boolean logLandClaims = true; + public final boolean logMoneyTransactions = true; // -------------------------------------------- // // TAX // -------------------------------------------- // // Should the tax system be enabled? - public boolean taxEnabled = false; + public final boolean taxEnabled = false; // How much can you tax a player? - public double taxPlayerMinimum = -10; - public double taxPlayerMaximum = 10; + public final double taxPlayerMinimum = -10; + public final double taxPlayerMaximum = 10; // How much should Factions be taxed? //public double taxUpkeepBase = 0; //public double taxUpkeepPerChunk = 1; // When is a player inactive? - public int taxInactiveDays = 3; + public final int taxInactiveDays = 3; // When the last run time was (in unix time) // 0 means never @@ -539,17 +539,17 @@ public class MConf extends Entity { // Tax run when? // 0 means at midnight UTC it can be offset by a certain millis - public long taxTaskInvocationOffsetMillis = 0; + public final long taxTaskInvocationOffsetMillis = 0; // How often should the task be run? - public long taxTaskPeriodMillis = TimeUnit.MILLIS_PER_DAY; + public final long taxTaskPeriodMillis = TimeUnit.MILLIS_PER_DAY; // -------------------------------------------- // // RANKS // -------------------------------------------- // @EditorVisible(false) - public List defaultRanks = MUtil.list( + public final List defaultRanks = MUtil.list( new Rank("Leader", 400, "**"), new Rank("Officer", 300, "*"), new Rank("Member", 200, "+"), @@ -560,7 +560,7 @@ public class MConf extends Entity { // PERMISSIONS // -------------------------------------------- // - public Map> perm2default = MUtil.map( + public final Map> perm2default = MUtil.map( MPerm.ID_BUILD, MUtil.set("LEADER", "OFFICER", "MEMBER"), MPerm.ID_PAINBUILD, MUtil.set(), MPerm.ID_DOOR, MUtil.set("LEADER", "OFFICER", "MEMBER", "RECRUIT", "ALLY"), @@ -601,49 +601,49 @@ public class MConf extends Entity { // In fact all of these sets can be empty on regular Spigot servers without any risk. // Interacting with these materials when they are already placed in the terrain results in an edit. - public BackstringSet materialsEditOnInteract = new BackstringSet<>(Material.class); + public final BackstringSet materialsEditOnInteract = new BackstringSet<>(Material.class); // Interacting with the the terrain holding this item in hand results in an edit. // There's no need to add all block materials here. Only special items other than blocks. - public BackstringSet materialsEditTools = new BackstringSet<>(Material.class); + public final BackstringSet materialsEditTools = new BackstringSet<>(Material.class); // Interacting with these materials placed in the terrain results in door toggling. - public BackstringSet materialsDoor = new BackstringSet<>(Material.class); + public final BackstringSet materialsDoor = new BackstringSet<>(Material.class); // Interacting with these materials placed in the terrain results in opening a container. - public BackstringSet materialsContainer = new BackstringSet<>(Material.class); + public final BackstringSet materialsContainer = new BackstringSet<>(Material.class); // Interacting with these entities results in an edit. - public BackstringSet entityTypesEditOnInteract = new BackstringSet<>(EntityType.class); + public final BackstringSet entityTypesEditOnInteract = new BackstringSet<>(EntityType.class); // Damaging these entities results in an edit. - public BackstringSet entityTypesEditOnDamage = new BackstringSet<>(EntityType.class); + public final BackstringSet entityTypesEditOnDamage = new BackstringSet<>(EntityType.class); // Interacting with these entities results in opening a container. - public BackstringSet entityTypesContainer = new BackstringSet<>(EntityType.class); + public final BackstringSet entityTypesContainer = new BackstringSet<>(EntityType.class); // The complete list of entities considered to be monsters. - public BackstringSet entityTypesMonsters = new BackstringSet<>(EntityType.class); + public final BackstringSet entityTypesMonsters = new BackstringSet<>(EntityType.class); // List of entities considered to be animals. - public BackstringSet entityTypesAnimals = new BackstringSet<>(EntityType.class); + public final BackstringSet entityTypesAnimals = new BackstringSet<>(EntityType.class); // -------------------------------------------- // // INTEGRATION: LWC // -------------------------------------------- // // Do you need faction build rights in the territory to create an LWC protection there? - public boolean lwcMustHaveBuildRightsToCreate = true; + public final boolean lwcMustHaveBuildRightsToCreate = true; // The config option above does not handle situations where a player creates an LWC protection in Faction territory and then leaves the faction. // The player would then have an LWC protection in a territory where they can not build. // Set this config option to true to enable an automatic removal feature. // LWC protections that couldn't be created will be removed on an attempt to open them by any player. - public boolean lwcRemoveIfNoBuildRights = false; + public final boolean lwcRemoveIfNoBuildRights = false; // WARN: Experimental and semi buggy. // If you change this to true: alien LWC protections will be removed upon using /f set. - public Map lwcRemoveOnChange = MUtil.map( + public final Map lwcRemoveOnChange = MUtil.map( EventFactionsChunkChangeType.BUY, false, // when claiming from wilderness EventFactionsChunkChangeType.SELL, false, // when selling back to wilderness EventFactionsChunkChangeType.CONQUER, false, // when claiming from another player faction @@ -655,19 +655,19 @@ public class MConf extends Entity { // -------------------------------------------- // // Global WorldGuard Integration Switch - public boolean worldguardCheckEnabled = false; + public final boolean worldguardCheckEnabled = false; // Enable the WorldGuard check per-world // Specify which worlds the WorldGuard Check can be used in - public WorldExceptionSet worldguardCheckWorldsEnabled = new WorldExceptionSet(); + public final WorldExceptionSet worldguardCheckWorldsEnabled = new WorldExceptionSet(); // -------------------------------------------- // // INTEGRATION: VentureChat // -------------------------------------------- // - public String ventureChatFactionChannelName = "faction"; - public String ventureChatAllyChannelName = "ally"; - public boolean ventureChatAllowFactionchatBetweenFactionless = false; + public final String ventureChatFactionChannelName = "faction"; + public final String ventureChatAllyChannelName = "ally"; + public final boolean ventureChatAllowFactionchatBetweenFactionless = false; // -------------------------------------------- // // INTEGRATION: ECONOMY @@ -675,14 +675,14 @@ public class MConf extends Entity { // Should economy features be enabled? // This requires that you have the external plugin called "Vault" installed. - public boolean econEnabled = true; + public final boolean econEnabled = true; // When paying a cost you may specify an account that should receive the money here. // Per default "" the money is just destroyed. - public String econUniverseAccount = ""; + public final String econUniverseAccount = ""; // What is the price per chunk when using /f set? - public Map econChunkCost = MUtil.map( + public final Map econChunkCost = MUtil.map( EventFactionsChunkChangeType.BUY, 1.0, // when claiming from wilderness EventFactionsChunkChangeType.SELL, 0.0, // when selling back to wilderness EventFactionsChunkChangeType.CONQUER, 0.0, // when claiming from another player faction @@ -690,23 +690,23 @@ public class MConf extends Entity { ); // What is the price to create a faction? - public double econCostCreate = 100.0; + public final double econCostCreate = 100.0; // And so on and so forth ... you get the idea. - public double econCostWarpAdd = 0.0; - public double econCostWarpRemove = 0.0; - public double econCostJoin = 0.0; - public double econCostLeave = 0.0; - public double econCostKick = 0.0; - public double econCostInvite = 0.0; - public double econCostDeinvite = 0.0; - public double econCostWarpGo = 0.0; - public double econCostName = 0.0; - public double econCostDescription = 0.0; - public double econCostTitle = 0.0; - public double econCostFlag = 0.0; + public final double econCostWarpAdd = 0.0; + public final double econCostWarpRemove = 0.0; + public final double econCostJoin = 0.0; + public final double econCostLeave = 0.0; + public final double econCostKick = 0.0; + public final double econCostInvite = 0.0; + public final double econCostDeinvite = 0.0; + public final double econCostWarpGo = 0.0; + public final double econCostName = 0.0; + public final double econCostDescription = 0.0; + public final double econCostTitle = 0.0; + public final double econCostFlag = 0.0; - public Map econRelCost = MUtil.map( + public final Map econRelCost = MUtil.map( Rel.ENEMY, 0.0, Rel.ALLY, 0.0, Rel.TRUCE, 0.0, @@ -715,11 +715,11 @@ public class MConf extends Entity { // Should the faction bank system be enabled? // This enables the command /f money. - public boolean bankEnabled = true; + public final boolean bankEnabled = true; // That costs should the faciton bank take care of? // If you set this to false the player executing the command will pay instead. - public boolean bankFactionPaysCosts = true; + public final boolean bankFactionPaysCosts = true; public boolean useNewMoneySystem = false; @@ -728,42 +728,43 @@ public class MConf extends Entity { // -------------------------------------------- // // Should the dynmap intagration be used? - public boolean dynmapEnabled = true; + public final boolean dynmapEnabled = true; // Should the dynmap updates be logged to console output? - public boolean dynmapLogTimeSpent = false; + public final boolean dynmapLogTimeSpent = false; // Name of the Factions layer - public String dynmapLayerName = "Factions"; + public final String dynmapLayerName = "Factions"; // Should the layer be visible per default - public boolean dynmapLayerHiddenByDefault = false; + public final boolean dynmapLayerHiddenByDefault = false; // Ordering priority in layer menu (low goes before high - default is 0) - public int dynmapLayerPriority = 2; + public final int dynmapLayerPriority = 2; // (optional) set minimum zoom level before layer is visible (0 = defalt, always visible) - public int dynmapLayerMinimumZoom = 0; + public final int dynmapLayerMinimumZoom = 0; // Format for popup - substitute values for macros //public String dynmapInfowindowFormat = "

%regionname%
Flags
%flags%
"; - public String dynmapFactionDescription = - "
\n" + - "%name%
\n" + - "%description%
\n" + - "
\n" + - "Leader: %players.leader%
\n" + - "Members: %players%
\n" + - "
\n" + - "Age: %age%
\n" + - "Bank: %money%
\n" + - "
\n" + - "Flags:
\n" + - "%flags.table3%\n" + - "
"; + public final String dynmapFactionDescription = + """ +
+ %name%
+ %description%
+
+ Leader: %players.leader%
+ Members: %players%
+
+ Age: %age%
+ Bank: %money%
+
+ Flags:
+ %flags.table3% +
"""; // Enable the %money% macro. Only do this if you know your economy manager is thread safe. - public boolean dynmapShowMoneyInDescription = false; + public final boolean dynmapShowMoneyInDescription = false; // Allow players in faction to see one another on Dynmap (only relevant if Dynmap has 'player-info-protected' enabled) //public boolean dynmapVisibilityByFaction = true; @@ -772,15 +773,15 @@ public class MConf extends Entity { // If empty all regions are shown. // Specify Faction either by name or UUID. // To show all regions on a given world, add 'world:' to the list. - public Set dynmapVisibleFactions = new MassiveSet<>(); + public final Set dynmapVisibleFactions = new MassiveSet<>(); // Optional setting to hide specific Factions. // Specify Faction either by name or UUID. // To hide all regions on a given world, add 'world:' to the list. - public Set dynmapHiddenFactions = new MassiveSet<>(); + public final Set dynmapHiddenFactions = new MassiveSet<>(); @EditorVisible(false) - public DynmapStyle dynmapDefaultStyle = new DynmapStyle( + public final DynmapStyle dynmapDefaultStyle = new DynmapStyle( IntegrationDynmap.DYNMAP_STYLE_LINE_COLOR, IntegrationDynmap.DYNMAP_STYLE_LINE_OPACITY, IntegrationDynmap.DYNMAP_STYLE_LINE_WEIGHT, @@ -793,7 +794,7 @@ public class MConf extends Entity { // Optional per Faction style overrides. Any defined replace those in dynmapDefaultStyle. // Specify Faction either by name or UUID. @EditorVisible(false) - public Map dynmapFactionStyles = MUtil.map( + public final Map dynmapFactionStyles = MUtil.map( "SafeZone", new DynmapStyle().withLineColor("#FF00FF").withFillColor("#FF00FF").withBoost(false), "WarZone", new DynmapStyle().withLineColor("#FF0000").withFillColor("#FF0000").withBoost(false) ); diff --git a/src/main/java/net/knarcraft/factions/entity/MConfColl.java b/src/main/java/net/knarcraft/factions/entity/MConfColl.java index 7aed5590..faeebec0 100644 --- a/src/main/java/net/knarcraft/factions/entity/MConfColl.java +++ b/src/main/java/net/knarcraft/factions/entity/MConfColl.java @@ -8,7 +8,7 @@ public class MConfColl extends Coll { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MConfColl i = new MConfColl(); + private static final MConfColl i = new MConfColl(); public static MConfColl get() { return i; @@ -30,9 +30,9 @@ public class MConfColl extends Coll { @Override public void setActive(boolean active) { super.setActive(active); - if (!active) { - return; - } + if (!active) { + return; + } MConf.i = this.get(MassiveCore.INSTANCE, true); } diff --git a/src/main/java/net/knarcraft/factions/entity/MFlag.java b/src/main/java/net/knarcraft/factions/entity/MFlag.java index c437a2b0..f6b08d6e 100644 --- a/src/main/java/net/knarcraft/factions/entity/MFlag.java +++ b/src/main/java/net/knarcraft/factions/entity/MFlag.java @@ -1,6 +1,5 @@ package net.knarcraft.factions.entity; -import net.knarcraft.factions.event.EventFactionsCreateFlags; import com.massivecraft.massivecore.Named; import com.massivecraft.massivecore.Prioritized; import com.massivecraft.massivecore.Registerable; @@ -9,6 +8,7 @@ import com.massivecraft.massivecore.comparator.ComparatorSmart; import com.massivecraft.massivecore.predicate.PredicateIsRegistered; import com.massivecraft.massivecore.store.Entity; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.event.EventFactionsCreateFlags; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -363,12 +363,12 @@ public class MFlag extends Entity implements Prioritized, Registerable, N // -------------------------------------------- // public boolean isInteresting(boolean value) { - if (!this.isVisible()) { - return false; - } - if (this.isEditable()) { - return true; - } + if (!this.isVisible()) { + return false; + } + if (this.isEditable()) { + return true; + } return this.isStandard() != value; } @@ -377,15 +377,15 @@ public class MFlag extends Entity implements Prioritized, Registerable, N List ret = new MassiveList<>(); // Fill - if (withValue) { - ret.add(getStateValue(value, monospaceValue)); - } - if (withName) { - ret.add(this.getStateName()); - } - if (withDesc) { - ret.add(this.getStateDescription(value, specificDesc)); - } + if (withValue) { + ret.add(getStateValue(value, monospaceValue)); + } + if (withName) { + ret.add(this.getStateName()); + } + if (withDesc) { + ret.add(this.getStateDescription(value, specificDesc)); + } // Return return Txt.implode(ret, " "); @@ -404,12 +404,12 @@ public class MFlag extends Entity implements Prioritized, Registerable, N private ChatColor getStateColor() { // Is special? - if (!this.isVisible()) { - return ChatColor.GRAY; - } - if (this.isEditable()) { - return ChatColor.LIGHT_PURPLE; - } + if (!this.isVisible()) { + return ChatColor.GRAY; + } + if (this.isEditable()) { + return ChatColor.LIGHT_PURPLE; + } // Return normal return ChatColor.AQUA; @@ -420,9 +420,9 @@ public class MFlag extends Entity implements Prioritized, Registerable, N String desc = this.getDesc(); // Is specific? - if (specific) { - desc = value ? this.getDescYes() : this.getDescNo(); - } + if (specific) { + desc = value ? this.getDescYes() : this.getDescNo(); + } // Return return Txt.parse("%s", desc); diff --git a/src/main/java/net/knarcraft/factions/entity/MFlagColl.java b/src/main/java/net/knarcraft/factions/entity/MFlagColl.java index 933f300d..80837f90 100644 --- a/src/main/java/net/knarcraft/factions/entity/MFlagColl.java +++ b/src/main/java/net/knarcraft/factions/entity/MFlagColl.java @@ -10,7 +10,7 @@ public class MFlagColl extends Coll { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MFlagColl i = new MFlagColl(); + private static final MFlagColl i = new MFlagColl(); public static MFlagColl get() { return i; @@ -36,9 +36,9 @@ public class MFlagColl extends Coll { @Override public void setActive(boolean active) { super.setActive(active); - if (!active) { - return; - } + if (!active) { + return; + } MFlag.setupStandardFlags(); } @@ -52,9 +52,9 @@ public class MFlagColl extends Coll { // Fill for (MFlag mflag : this.getAll()) { - if (mflag.isRegistered() != registered) { - continue; - } + if (mflag.isRegistered() != registered) { + continue; + } ret.add(mflag); } diff --git a/src/main/java/net/knarcraft/factions/entity/MPerm.java b/src/main/java/net/knarcraft/factions/entity/MPerm.java index da7a7df8..ef8248c5 100644 --- a/src/main/java/net/knarcraft/factions/entity/MPerm.java +++ b/src/main/java/net/knarcraft/factions/entity/MPerm.java @@ -1,11 +1,5 @@ package net.knarcraft.factions.entity; -import net.knarcraft.factions.AccessStatus; -import net.knarcraft.factions.Perm; -import net.knarcraft.factions.Rel; -import net.knarcraft.factions.TerritoryAccess; -import net.knarcraft.factions.cmd.CmdFactions; -import net.knarcraft.factions.event.EventFactionsCreatePerms; import com.massivecraft.massivecore.Identified; import com.massivecraft.massivecore.Named; import com.massivecraft.massivecore.Prioritized; @@ -17,6 +11,12 @@ import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.store.Entity; import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.AccessStatus; +import net.knarcraft.factions.Perm; +import net.knarcraft.factions.Rel; +import net.knarcraft.factions.TerritoryAccess; +import net.knarcraft.factions.cmd.CmdFactions; +import net.knarcraft.factions.event.EventFactionsCreatePerms; import org.bukkit.entity.Player; import java.util.ArrayList; @@ -438,12 +438,12 @@ public class MPerm extends Entity implements Prioritized, Registerable, N public String createDeniedMessage(MPlayer mplayer, Faction hostFaction) { // Null Check - if (mplayer == null) { - throw new NullPointerException("mplayer"); - } - if (hostFaction == null) { - throw new NullPointerException("hostFaction"); - } + if (mplayer == null) { + throw new NullPointerException("mplayer"); + } + if (hostFaction == null) { + throw new NullPointerException("hostFaction"); + } String ret = Txt.parse("%s does not allow you to %s.", hostFaction.describeTo(mplayer, true), this.getDesc()); @@ -484,54 +484,54 @@ public class MPerm extends Entity implements Prioritized, Registerable, N public boolean has(Faction faction, Faction hostFaction) { // Null Check - if (faction == null) { - throw new NullPointerException("faction"); - } - if (hostFaction == null) { - throw new NullPointerException("hostFaction"); - } + if (faction == null) { + throw new NullPointerException("faction"); + } + if (hostFaction == null) { + throw new NullPointerException("hostFaction"); + } return hostFaction.isFactionPermitted(faction, this); } public boolean has(MPlayer mplayer, Faction hostFaction, boolean verboose) { // Null Check - if (mplayer == null) { - throw new NullPointerException("mplayer"); - } - if (hostFaction == null) { - throw new NullPointerException("hostFaction"); - } + if (mplayer == null) { + throw new NullPointerException("mplayer"); + } + if (hostFaction == null) { + throw new NullPointerException("hostFaction"); + } - if (mplayer.isOverriding()) { - return true; - } + if (mplayer.isOverriding()) { + return true; + } Rel rel = mplayer.getRelationTo(hostFaction); MPermable permable = rel == Rel.FACTION ? mplayer.getRank() : rel; - if (hostFaction.isPlayerPermitted(mplayer, this)) { - return true; - } + if (hostFaction.isPlayerPermitted(mplayer, this)) { + return true; + } - if (verboose) { - mplayer.message(this.createDeniedMessage(mplayer, hostFaction)); - } + if (verboose) { + mplayer.message(this.createDeniedMessage(mplayer, hostFaction)); + } return false; } public boolean has(MPlayer mplayer, PS ps, boolean verboose) { // Null Check - if (mplayer == null) { - throw new NullPointerException("mplayer"); - } - if (ps == null) { - throw new NullPointerException("ps"); - } + if (mplayer == null) { + throw new NullPointerException("mplayer"); + } + if (ps == null) { + throw new NullPointerException("ps"); + } - if (mplayer.isOverriding()) { - return true; - } + if (mplayer.isOverriding()) { + return true; + } TerritoryAccess ta = BoardColl.get().getTerritoryAccessAt(ps); Faction hostFaction = ta.getHostFaction(); @@ -555,9 +555,9 @@ public class MPerm extends Entity implements Prioritized, Registerable, N // -------------------------------------------- // public static List getPermables(Faction faction) { - if (faction == null) { - throw new NullPointerException("faction"); - } + if (faction == null) { + throw new NullPointerException("faction"); + } List list = new MassiveList<>(); @@ -597,40 +597,40 @@ public class MPerm extends Entity implements Prioritized, Registerable, N public static Optional idToMPermableOptional(String id) { MPlayer mplayer = MPlayerColl.get().get(id, false); - if (mplayer != null) { - return Optional.of(mplayer); - } + if (mplayer != null) { + return Optional.of(mplayer); + } // Workaround for registered senders // Players ussually have a power, which makes sure they are in the coll - if (IdUtil.getRegistryIdToSender().containsKey(id)) { - return Optional.of(MPlayerColl.get().get(id, true)); - } + if (IdUtil.getRegistryIdToSender().containsKey(id)) { + return Optional.of(MPlayerColl.get().get(id, true)); + } Faction faction = Faction.get(id); - if (faction != null) { - return Optional.of(faction); - } + if (faction != null) { + return Optional.of(faction); + } for (Faction f : FactionColl.get().getAll()) { Rank rank = f.getRank(id); - if (rank != null) { - return Optional.of(rank); - } + if (rank != null) { + return Optional.of(rank); + } } - if (Rel.ALLY.name().equalsIgnoreCase(id)) { - return Optional.of(Rel.ALLY); - } - if (Rel.TRUCE.name().equalsIgnoreCase(id)) { - return Optional.of(Rel.TRUCE); - } - if (Rel.NEUTRAL.name().equalsIgnoreCase(id)) { - return Optional.of(Rel.NEUTRAL); - } - if (Rel.ENEMY.name().equalsIgnoreCase(id)) { - return Optional.of(Rel.ENEMY); - } + if (Rel.ALLY.name().equalsIgnoreCase(id)) { + return Optional.of(Rel.ALLY); + } + if (Rel.TRUCE.name().equalsIgnoreCase(id)) { + return Optional.of(Rel.TRUCE); + } + if (Rel.NEUTRAL.name().equalsIgnoreCase(id)) { + return Optional.of(Rel.NEUTRAL); + } + if (Rel.ENEMY.name().equalsIgnoreCase(id)) { + return Optional.of(Rel.ENEMY); + } return Optional.empty(); } diff --git a/src/main/java/net/knarcraft/factions/entity/MPermColl.java b/src/main/java/net/knarcraft/factions/entity/MPermColl.java index 3bdb8f76..1f4243d4 100644 --- a/src/main/java/net/knarcraft/factions/entity/MPermColl.java +++ b/src/main/java/net/knarcraft/factions/entity/MPermColl.java @@ -13,7 +13,7 @@ public class MPermColl extends Coll { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MPermColl i = new MPermColl(); + private static final MPermColl i = new MPermColl(); public static MPermColl get() { return i; @@ -39,9 +39,9 @@ public class MPermColl extends Coll { @Override public void setActive(boolean active) { super.setActive(active); - if (!active) { - return; - } + if (!active) { + return; + } MPerm.setupStandardPerms(); } @@ -88,9 +88,9 @@ public class MPermColl extends Coll { // Fill for (MPerm mperm : this.getAll()) { - if (mperm.isRegistered() != registered) { - continue; - } + if (mperm.isRegistered() != registered) { + continue; + } ret.add(mperm); } diff --git a/src/main/java/net/knarcraft/factions/entity/MPlayer.java b/src/main/java/net/knarcraft/factions/entity/MPlayer.java index 380ddda5..12411fc9 100644 --- a/src/main/java/net/knarcraft/factions/entity/MPlayer.java +++ b/src/main/java/net/knarcraft/factions/entity/MPlayer.java @@ -1,5 +1,13 @@ package net.knarcraft.factions.entity; +import com.massivecraft.massivecore.mixin.MixinSenderPs; +import com.massivecraft.massivecore.mixin.MixinTitle; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.ps.PSFormatHumanSpace; +import com.massivecraft.massivecore.store.SenderEntity; +import com.massivecraft.massivecore.util.IdUtil; +import com.massivecraft.massivecore.util.MUtil; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.Factions; import net.knarcraft.factions.FactionsIndex; import net.knarcraft.factions.FactionsParticipator; @@ -14,14 +22,6 @@ import net.knarcraft.factions.event.EventFactionsMembershipChange.MembershipChan import net.knarcraft.factions.mixin.PowerMixin; import net.knarcraft.factions.util.AsciiMap; import net.knarcraft.factions.util.RelationUtil; -import com.massivecraft.massivecore.mixin.MixinSenderPs; -import com.massivecraft.massivecore.mixin.MixinTitle; -import com.massivecraft.massivecore.ps.PS; -import com.massivecraft.massivecore.ps.PSFormatHumanSpace; -import com.massivecraft.massivecore.store.SenderEntity; -import com.massivecraft.massivecore.util.IdUtil; -import com.massivecraft.massivecore.util.MUtil; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -80,26 +80,22 @@ public class MPlayer extends SenderEntity implements FactionsParticipat @Override public boolean isDefault() { // Last activity millis is data we use for clearing out cleanable players. So it does not in itself make the player data worth keeping. - if (this.hasFaction()) { - return false; - } + if (this.hasFaction()) { + return false; + } // Role means nothing without a faction. // Title means nothing without a faction. - if (this.hasPowerBoost()) { - return false; - } - if (this.getPowerRounded() != (int) Math.round(MConf.get().defaultPlayerPower)) { - return false; - } + if (this.hasPowerBoost()) { + return false; + } + if (this.getPowerRounded() != (int) Math.round(MConf.get().defaultPlayerPower)) { + return false; + } // if (this.isMapAutoUpdating()) return false; // Just having an auto updating map is not in itself reason enough for database storage. - if (this.isOverriding()) { - return false; - } - if (this.isTerritoryInfoTitles() != MConf.get().territoryInfoTitlesDefault) { - return false; - } - - return true; + if (this.isOverriding()) { + return false; + } + return this.isTerritoryInfoTitles() == MConf.get().territoryInfoTitlesDefault; } // -------------------------------------------- // @@ -194,16 +190,16 @@ public class MPlayer extends SenderEntity implements FactionsParticipat private transient WeakReference autoClaimFaction = new WeakReference<>(null); public Faction getAutoClaimFaction() { - if (this.isFactionOrphan()) { - return null; - } + if (this.isFactionOrphan()) { + return null; + } Faction ret = this.autoClaimFaction.get(); - if (ret == null) { - return null; - } - if (ret.detached()) { - return null; - } + if (ret == null) { + return null; + } + if (ret.detached()) { + return null; + } return ret; } @@ -299,15 +295,14 @@ public class MPlayer extends SenderEntity implements FactionsParticipat String beforeId = this.factionId; // After - String afterId = factionId; // NoChange - if (MUtil.equals(beforeId, afterId)) { - return; - } + if (MUtil.equals(beforeId, factionId)) { + return; + } // Apply - this.factionId = afterId; + this.factionId = factionId; // Index FactionsIndex.get().update(this); @@ -325,13 +320,13 @@ public class MPlayer extends SenderEntity implements FactionsParticipat // -------------------------------------------- // public Rank getRank() { - if (this.isFactionOrphan()) { - return FactionColl.get().getNone().getLowestRank(); - } + if (this.isFactionOrphan()) { + return FactionColl.get().getNone().getLowestRank(); + } - if (this.rankId == null) { - return this.getFaction().getLowestRank(); - } + if (this.rankId == null) { + return this.getFaction().getLowestRank(); + } return this.getFaction().getRank(this.rankId); } @@ -340,9 +335,9 @@ public class MPlayer extends SenderEntity implements FactionsParticipat String rankId = rank == null ? null : rank.getId(); // Detect Nochange - if (MUtil.equals(this.rankId, rankId)) { - return; - } + if (MUtil.equals(this.rankId, rankId)) { + return; + } // Apply this.rankId = rankId; @@ -362,13 +357,13 @@ public class MPlayer extends SenderEntity implements FactionsParticipat } public String getTitle() { - if (this.isFactionOrphan()) { - return NOTITLE; - } + if (this.isFactionOrphan()) { + return NOTITLE; + } - if (this.hasTitle()) { - return this.title; - } + if (this.hasTitle()) { + return this.title; + } return NOTITLE; } @@ -378,9 +373,9 @@ public class MPlayer extends SenderEntity implements FactionsParticipat String target = Faction.clean(title); // Detect Nochange - if (MUtil.equals(this.title, target)) { - return; - } + if (MUtil.equals(this.title, target)) { + return; + } // Apply this.title = target; @@ -396,9 +391,9 @@ public class MPlayer extends SenderEntity implements FactionsParticipat @Override public double getPowerBoost() { Double ret = this.powerBoost; - if (ret == null) { - ret = 0D; - } + if (ret == null) { + ret = 0D; + } return ret; } @@ -406,14 +401,14 @@ public class MPlayer extends SenderEntity implements FactionsParticipat public void setPowerBoost(Double powerBoost) { // Clean input Double target = powerBoost; - if (target == null || target == 0) { - target = null; - } + if (target == null || target == 0) { + target = null; + } // Detect Nochange - if (MUtil.equals(this.powerBoost, target)) { - return; - } + if (MUtil.equals(this.powerBoost, target)) { + return; + } // Apply this.powerBoost = target; @@ -482,24 +477,23 @@ public class MPlayer extends SenderEntity implements FactionsParticipat public double getPower() { Double ret = this.power; - if (ret == null) { - ret = MConf.get().defaultPlayerPower; - } + if (ret == null) { + ret = MConf.get().defaultPlayerPower; + } ret = this.getLimitedPower(ret); return ret; } public void setPower(Double power) { // Clean input - Double target = power; // Detect Nochange - if (MUtil.equals(this.power, target)) { - return; - } + if (MUtil.equals(this.power, power)) { + return; + } // Apply - this.power = target; + this.power = power; // Mark as changed this.changed(); @@ -516,26 +510,23 @@ public class MPlayer extends SenderEntity implements FactionsParticipat // -------------------------------------------- // public boolean isMapAutoUpdating() { - if (this.mapAutoUpdating == null) { - return false; - } - if (this.mapAutoUpdating == false) { - return false; - } - return true; + if (this.mapAutoUpdating == null) { + return false; + } + return this.mapAutoUpdating; } public void setMapAutoUpdating(Boolean mapAutoUpdating) { // Clean input Boolean target = mapAutoUpdating; - if (MUtil.equals(target, false)) { - target = null; - } + if (MUtil.equals(target, false)) { + target = null; + } // Detect Nochange - if (MUtil.equals(this.mapAutoUpdating, target)) { - return; - } + if (MUtil.equals(this.mapAutoUpdating, target)) { + return; + } // Apply this.mapAutoUpdating = target; @@ -549,12 +540,12 @@ public class MPlayer extends SenderEntity implements FactionsParticipat // -------------------------------------------- // public boolean isOverriding() { - if (this.overriding == null) { - return false; - } - if (this.overriding == false) { - return false; - } + if (this.overriding == null) { + return false; + } + if (!this.overriding) { + return false; + } if (!this.hasPermission(Perm.OVERRIDE, true)) { this.setOverriding(false); @@ -567,14 +558,14 @@ public class MPlayer extends SenderEntity implements FactionsParticipat public void setOverriding(Boolean overriding) { // Clean input Boolean target = overriding; - if (MUtil.equals(target, false)) { - target = null; - } + if (MUtil.equals(target, false)) { + target = null; + } // Detect Nochange - if (MUtil.equals(this.overriding, target)) { - return; - } + if (MUtil.equals(this.overriding, target)) { + return; + } // Apply this.overriding = target; @@ -588,26 +579,26 @@ public class MPlayer extends SenderEntity implements FactionsParticipat // -------------------------------------------- // public boolean isTerritoryInfoTitles() { - if (!MixinTitle.get().isAvailable()) { - return false; - } - if (this.territoryInfoTitles == null) { - return MConf.get().territoryInfoTitlesDefault; - } + if (!MixinTitle.get().isAvailable()) { + return false; + } + if (this.territoryInfoTitles == null) { + return MConf.get().territoryInfoTitlesDefault; + } return this.territoryInfoTitles; } public void setTerritoryInfoTitles(Boolean territoryInfoTitles) { // Clean input Boolean target = territoryInfoTitles; - if (MUtil.equals(target, MConf.get().territoryInfoTitlesDefault)) { - target = null; - } + if (MUtil.equals(target, MConf.get().territoryInfoTitlesDefault)) { + target = null; + } // Detect Nochange - if (MUtil.equals(this.territoryInfoTitles, target)) { - return; - } + if (MUtil.equals(this.territoryInfoTitles, target)) { + return; + } // Apply this.territoryInfoTitles = target; @@ -634,9 +625,9 @@ public class MPlayer extends SenderEntity implements FactionsParticipat public String getFactionName() { Faction faction = this.getFaction(); - if (faction.isNone()) { - return ""; - } + if (faction.isNone()) { + return ""; + } return faction.getName(); } @@ -725,17 +716,17 @@ public class MPlayer extends SenderEntity implements FactionsParticipat public boolean isInOwnTerritory() { PS ps = MixinSenderPs.get().getSenderPs(this.getId()); - if (ps == null) { - return false; - } + if (ps == null) { + return false; + } return BoardColl.get().getFactionAt(ps) == this.getFaction(); } public boolean isInEnemyTerritory() { PS ps = MixinSenderPs.get().getSenderPs(this.getId()); - if (ps == null) { - return false; - } + if (ps == null) { + return false; + } return BoardColl.get().getFactionAt(ps).getRelationTo(this) == Rel.ENEMY; } @@ -763,9 +754,9 @@ public class MPlayer extends SenderEntity implements FactionsParticipat // Event EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(this.getSender(), this, myFaction, MembershipChangeReason.LEAVE); membershipChangeEvent.run(); - if (membershipChangeEvent.isCancelled()) { - return; - } + if (membershipChangeEvent.isCancelled()) { + return; + } if (myFaction.isNormal()) { for (MPlayer mplayer : myFaction.getMPlayersWhereOnline(true)) { @@ -800,20 +791,20 @@ public class MPlayer extends SenderEntity implements FactionsParticipat public boolean tryClaim(Faction newFaction, Collection pss, String formatOne, String formatMany) { // Args - if (formatOne == null) { - formatOne = "%s %s %d chunk %s."; - } - if (formatMany == null) { - formatMany = "%s %s %d chunks near %s."; - } + if (formatOne == null) { + formatOne = "%s %s %d chunk %s."; + } + if (formatMany == null) { + formatMany = "%s %s %d chunks near %s."; + } - if (newFaction == null) { - throw new NullPointerException("newFaction"); - } + if (newFaction == null) { + throw new NullPointerException("newFaction"); + } - if (pss == null) { - throw new NullPointerException("pss"); - } + if (pss == null) { + throw new NullPointerException("pss"); + } final Set chunks = PS.getDistinctChunks(pss); // NoChange @@ -840,9 +831,9 @@ public class MPlayer extends SenderEntity implements FactionsParticipat } EventFactionsChunksChange event = new EventFactionsChunksChange(sender, chunks, newFaction); event.run(); - if (event.isCancelled()) { - return false; - } + if (event.isCancelled()) { + return false; + } // Apply for (PS chunk : chunks) { @@ -860,7 +851,7 @@ public class MPlayer extends SenderEntity implements FactionsParticipat String chunkString = oldChunk.toString(PSFormatHumanSpace.get()); String typeString = type.past; - if (!AsciiMap.showChunkCoords(oldChunk)) { + if (!AsciiMap.showChunkCoordinates(oldChunk)) { chunkString = ""; formatMany = formatMany.replace(" near ", ""); } @@ -882,17 +873,17 @@ public class MPlayer extends SenderEntity implements FactionsParticipat public static Set getClaimInformees(MPlayer msender, Faction... factions) { Set ret = new HashSet<>(); - if (msender != null) { - ret.add(msender); - } + if (msender != null) { + ret.add(msender); + } for (Faction faction : factions) { - if (faction == null) { - continue; - } - if (faction.isNone()) { - continue; - } + if (faction == null) { + continue; + } + if (faction.isNone()) { + continue; + } ret.addAll(faction.getMPlayers()); } diff --git a/src/main/java/net/knarcraft/factions/entity/MPlayerColl.java b/src/main/java/net/knarcraft/factions/entity/MPlayerColl.java index dc8b94b5..85c4b4d1 100644 --- a/src/main/java/net/knarcraft/factions/entity/MPlayerColl.java +++ b/src/main/java/net/knarcraft/factions/entity/MPlayerColl.java @@ -7,7 +7,7 @@ public class MPlayerColl extends SenderColl { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MPlayerColl i = new MPlayerColl(); + private static final MPlayerColl i = new MPlayerColl(); public static MPlayerColl get() { return i; diff --git a/src/main/java/net/knarcraft/factions/entity/Rank.java b/src/main/java/net/knarcraft/factions/entity/Rank.java index f655c65c..870d117d 100644 --- a/src/main/java/net/knarcraft/factions/entity/Rank.java +++ b/src/main/java/net/knarcraft/factions/entity/Rank.java @@ -25,9 +25,9 @@ public class Rank extends EntityInternal implements MPerm.MPermable { for (Faction f : FactionColl.get().getAll()) { for (Entry> entry : f.getPerms().entrySet()) { Set value = entry.getValue(); - if (value == null) { - throw new NullPointerException(entry.getKey()); - } + if (value == null) { + throw new NullPointerException(entry.getKey()); + } value.remove(id); } } @@ -119,46 +119,46 @@ public class Rank extends EntityInternal implements MPerm.MPermable { // -------------------------------------------- // public boolean isLessThan(Rank otherRank) { - if (this.getContainer() != otherRank.getContainer()) { - throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId()); - } + if (this.getContainer() != otherRank.getContainer()) { + throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId()); + } return this.getPriority() < otherRank.getPriority(); } public boolean isMoreThan(Rank otherRank) { - if (this.getContainer() != otherRank.getContainer()) { - throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId()); - } + if (this.getContainer() != otherRank.getContainer()) { + throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId()); + } return this.getPriority() > otherRank.getPriority(); } public boolean isAtLeast(Rank otherRank) { - if (this.getContainer() != otherRank.getContainer()) { - throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId()); - } + if (this.getContainer() != otherRank.getContainer()) { + throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId()); + } return this.getPriority() >= otherRank.getPriority(); } public boolean isAtMost(Rank otherRank) { - if (this.getContainer() != otherRank.getContainer()) { - throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId()); - } + if (this.getContainer() != otherRank.getContainer()) { + throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId()); + } return this.getPriority() <= otherRank.getPriority(); } public boolean isLeader() { for (Rank otherRank : this.getContainer().getAll()) { - if (otherRank == this) { - continue; - } + if (otherRank == this) { + continue; + } - if (otherRank.isMoreThan(this)) { - return false; - } + if (otherRank.isMoreThan(this)) { + return false; + } } return true; } @@ -166,15 +166,15 @@ public class Rank extends EntityInternal implements MPerm.MPermable { public Rank getRankAbove() { Rank ret = null; for (Rank otherRank : this.getContainer().getAll()) { - if (otherRank == this) { - continue; - } - if (otherRank.isLessThan(this)) { - continue; - } - if (ret != null && ret.isLessThan(otherRank)) { - continue; - } + if (otherRank == this) { + continue; + } + if (otherRank.isLessThan(this)) { + continue; + } + if (ret != null && ret.isLessThan(otherRank)) { + continue; + } ret = otherRank; } @@ -184,15 +184,15 @@ public class Rank extends EntityInternal implements MPerm.MPermable { public Rank getRankBelow() { Rank ret = null; for (Rank otherRank : this.getContainer().getAll()) { - if (otherRank == this) { - continue; - } - if (otherRank.isMoreThan(this)) { - continue; - } - if (ret != null && ret.isMoreThan(otherRank)) { - continue; - } + if (otherRank == this) { + continue; + } + if (otherRank.isMoreThan(this)) { + continue; + } + if (ret != null && ret.isMoreThan(otherRank)) { + continue; + } ret = otherRank; } diff --git a/src/main/java/net/knarcraft/factions/entity/Vote.java b/src/main/java/net/knarcraft/factions/entity/Vote.java index 5888abd4..8681c2ba 100644 --- a/src/main/java/net/knarcraft/factions/entity/Vote.java +++ b/src/main/java/net/knarcraft/factions/entity/Vote.java @@ -41,7 +41,7 @@ public class Vote extends EntityInternal implements Named { return this.creationMillis; } - private String name; + private final String name; @Override public String getName() { @@ -86,25 +86,25 @@ public class Vote extends EntityInternal implements Named { // -------------------------------------------- // public void setVote(MPlayer mplayer, String choice) { - if (mplayer == null) { - throw new NullPointerException("mplayer"); - } - if (choice == null) { - throw new NullPointerException("choice"); - } + if (mplayer == null) { + throw new NullPointerException("mplayer"); + } + if (choice == null) { + throw new NullPointerException("choice"); + } - if (!this.getOptions().contains(choice)) { - throw new IllegalArgumentException(choice + " is not in " + this.getOptions()); - } + if (!this.getOptions().contains(choice)) { + throw new IllegalArgumentException(choice + " is not in " + this.getOptions()); + } id2Vote.put(mplayer.getId(), choice); this.changed(); } public String getVote(MPlayer mplayer) { - if (mplayer == null) { - throw new NullPointerException("mplayer"); - } + if (mplayer == null) { + throw new NullPointerException("mplayer"); + } return this.getId2Vote().get(mplayer.getId()); } diff --git a/src/main/java/net/knarcraft/factions/entity/Warp.java b/src/main/java/net/knarcraft/factions/entity/Warp.java index 1b62bd16..c59ff1a2 100644 --- a/src/main/java/net/knarcraft/factions/entity/Warp.java +++ b/src/main/java/net/knarcraft/factions/entity/Warp.java @@ -81,9 +81,9 @@ public class Warp extends EntityInternal implements Named { // -------------------------------------------- // public boolean verifyIsValid() { - if (this.isValid()) { - return true; - } + if (this.isValid()) { + return true; + } Faction fac = this.getFaction(); this.detach(); fac.msg("Your faction warp %s has been un-set since it is no longer in your territory.", this.getName()); @@ -91,13 +91,10 @@ public class Warp extends EntityInternal implements Named { } public boolean isValidFor(Faction faction) { - if (!MConf.get().warpsMustBeInClaimedTerritory) { - return true; - } - if (BoardColl.get().getFactionAt(this.getLocation()) == faction) { - return true; - } - return false; + if (!MConf.get().warpsMustBeInClaimedTerritory) { + return true; + } + return BoardColl.get().getFactionAt(this.getLocation()) == faction; } public boolean isValid() { diff --git a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorFaction001Invitations.java b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorFaction001Invitations.java index 26f6d986..442691ea 100644 --- a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorFaction001Invitations.java +++ b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorFaction001Invitations.java @@ -2,17 +2,17 @@ package net.knarcraft.factions.entity.migrator; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import net.knarcraft.factions.entity.Faction; import com.massivecraft.massivecore.store.migrator.MigratorFieldConvert; import com.massivecraft.massivecore.store.migrator.MigratorFieldRename; import com.massivecraft.massivecore.store.migrator.MigratorRoot; +import net.knarcraft.factions.entity.Faction; public class MigratorFaction001Invitations extends MigratorRoot { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MigratorFaction001Invitations i = new MigratorFaction001Invitations(); + private static final MigratorFaction001Invitations i = new MigratorFaction001Invitations(); public static MigratorFaction001Invitations get() { return i; @@ -24,7 +24,7 @@ public class MigratorFaction001Invitations extends MigratorRoot { this.addInnerMigrator(new MigratorFaction001InvitationsField()); } - public class MigratorFaction001InvitationsField extends MigratorFieldConvert { + public static class MigratorFaction001InvitationsField extends MigratorFieldConvert { // -------------------------------------------- // // CONSTRUCT // -------------------------------------------- // @@ -44,9 +44,9 @@ public class MigratorFaction001Invitations extends MigratorRoot { // If non-null if (!idList.isJsonNull()) { // ... and proper type ... - if (!idList.isJsonArray()) { - throw new IllegalArgumentException(idList.toString()); - } + if (!idList.isJsonArray()) { + throw new IllegalArgumentException(idList.toString()); + } // ... fill! for (JsonElement playerId : idList.getAsJsonArray()) { diff --git a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorFaction002Ranks.java b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorFaction002Ranks.java index fc07a854..711c5d3c 100644 --- a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorFaction002Ranks.java +++ b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorFaction002Ranks.java @@ -3,15 +3,15 @@ package net.knarcraft.factions.entity.migrator; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.MConf; -import net.knarcraft.factions.entity.MPerm; -import net.knarcraft.factions.entity.Rank; import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.collections.MassiveMap; import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.store.MStore; import com.massivecraft.massivecore.store.migrator.MigratorRoot; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.MConf; +import net.knarcraft.factions.entity.MPerm; +import net.knarcraft.factions.entity.Rank; import java.util.Iterator; import java.util.Map; @@ -22,7 +22,7 @@ public class MigratorFaction002Ranks extends MigratorRoot { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MigratorFaction002Ranks i = new MigratorFaction002Ranks(); + private static final MigratorFaction002Ranks i = new MigratorFaction002Ranks(); public static MigratorFaction002Ranks get() { return i; @@ -74,18 +74,18 @@ public class MigratorFaction002Ranks extends MigratorRoot { //Set value = new MassiveSet<>(mperm.getStandard()); Set value = new MassiveSet<>(MConf.get().perm2default.get(mperm.getId())); - if (value.remove("LEADER")) { - value.add(leaderId); - } - if (value.remove("OFFICER")) { - value.add(officerId); - } - if (value.remove("MEMBER")) { - value.add(memberId); - } - if (value.remove("RECRUIT")) { - value.add(recruitId); - } + if (value.remove("LEADER")) { + value.add(leaderId); + } + if (value.remove("OFFICER")) { + value.add(officerId); + } + if (value.remove("MEMBER")) { + value.add(memberId); + } + if (value.remove("RECRUIT")) { + value.add(recruitId); + } ret.put(mperm.getId(), value); } @@ -106,18 +106,18 @@ public class MigratorFaction002Ranks extends MigratorRoot { } Set value = entry.getValue(); - if (value.remove("LEADER")) { - value.add(leaderId); - } - if (value.remove("OFFICER")) { - value.add(officerId); - } - if (value.remove("MEMBER")) { - value.add(memberId); - } - if (value.remove("RECRUIT")) { - value.add(recruitId); - } + if (value.remove("LEADER")) { + value.add(leaderId); + } + if (value.remove("OFFICER")) { + value.add(officerId); + } + if (value.remove("MEMBER")) { + value.add(memberId); + } + if (value.remove("RECRUIT")) { + value.add(recruitId); + } ret.put(id, value); } } diff --git a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorFaction003Warps.java b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorFaction003Warps.java index 337833cd..b3405425 100644 --- a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorFaction003Warps.java +++ b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorFaction003Warps.java @@ -3,13 +3,13 @@ package net.knarcraft.factions.entity.migrator; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.Warp; import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.collections.MassiveMap; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.store.MStore; import com.massivecraft.massivecore.store.migrator.MigratorRoot; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.Warp; import java.util.Map; @@ -18,7 +18,7 @@ public class MigratorFaction003Warps extends MigratorRoot { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MigratorFaction003Warps i = new MigratorFaction003Warps(); + private static final MigratorFaction003Warps i = new MigratorFaction003Warps(); public static MigratorFaction003Warps get() { return i; @@ -35,13 +35,13 @@ public class MigratorFaction003Warps extends MigratorRoot { @Override public void migrateInner(JsonObject entity) { JsonElement jsonHome = entity.remove("home"); - if (jsonHome == null || jsonHome.isJsonNull()) { - return; - } + if (jsonHome == null || jsonHome.isJsonNull()) { + return; + } - if (!jsonHome.isJsonObject()) { - throw new RuntimeException("not JsonObject " + jsonHome); - } + if (!jsonHome.isJsonObject()) { + throw new RuntimeException("not JsonObject " + jsonHome); + } PS psHome = MassiveCore.gson.fromJson(jsonHome, PS.class); Warp warp = new Warp("home", psHome); diff --git a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorFaction004WarpsPerms.java b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorFaction004WarpsPerms.java index 522e92f1..f21dee13 100644 --- a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorFaction004WarpsPerms.java +++ b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorFaction004WarpsPerms.java @@ -2,15 +2,15 @@ package net.knarcraft.factions.entity.migrator; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import net.knarcraft.factions.entity.Faction; import com.massivecraft.massivecore.store.migrator.MigratorRoot; +import net.knarcraft.factions.entity.Faction; public class MigratorFaction004WarpsPerms extends MigratorRoot { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MigratorFaction004WarpsPerms i = new MigratorFaction004WarpsPerms(); + private static final MigratorFaction004WarpsPerms i = new MigratorFaction004WarpsPerms(); public static MigratorFaction004WarpsPerms get() { return i; @@ -27,21 +27,21 @@ public class MigratorFaction004WarpsPerms extends MigratorRoot { @Override public void migrateInner(JsonObject entity) { JsonElement perms = entity.get("perms"); - if (perms == null || perms.isJsonNull() || !perms.isJsonObject()) { - return; - } + if (perms == null || perms.isJsonNull() || !perms.isJsonObject()) { + return; + } JsonObject permsO = perms.getAsJsonObject(); JsonElement home = permsO.remove("home"); - if (home != null) { - permsO.add("warp", home); - } + if (home != null) { + permsO.add("warp", home); + } JsonElement sethome = permsO.remove("sethome"); - if (home != null) { - permsO.add("setwarp", home); - } + if (home != null) { + permsO.add("setwarp", home); + } } } diff --git a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf001EnumerationUtil.java b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf001EnumerationUtil.java index d3a84d2a..650b43de 100644 --- a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf001EnumerationUtil.java +++ b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf001EnumerationUtil.java @@ -4,9 +4,9 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; +import com.massivecraft.massivecore.store.migrator.MigratorRoot; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.util.EnumerationUtil; -import com.massivecraft.massivecore.store.migrator.MigratorRoot; import java.util.Collection; import java.util.Iterator; @@ -16,7 +16,7 @@ public class MigratorMConf001EnumerationUtil extends MigratorRoot { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MigratorMConf001EnumerationUtil i = new MigratorMConf001EnumerationUtil(); + private static final MigratorMConf001EnumerationUtil i = new MigratorMConf001EnumerationUtil(); public static MigratorMConf001EnumerationUtil get() { return i; @@ -49,21 +49,19 @@ public class MigratorMConf001EnumerationUtil extends MigratorRoot { private void removeFromStringsField(JsonObject entity, String fieldName, Collection removals) { JsonElement stringsElement = entity.get(fieldName); - if (!(stringsElement instanceof JsonArray)) { - return; - } - JsonArray strings = (JsonArray) stringsElement; + if (!(stringsElement instanceof JsonArray strings)) { + return; + } for (Iterator iterator = strings.iterator(); iterator.hasNext(); ) { JsonElement stringElement = iterator.next(); - if (!(stringElement instanceof JsonPrimitive)) { - continue; - } - JsonPrimitive string = (JsonPrimitive) stringElement; + if (!(stringElement instanceof JsonPrimitive string)) { + continue; + } - if (!removals.contains(string.getAsString())) { - continue; - } + if (!removals.contains(string.getAsString())) { + continue; + } iterator.remove(); } diff --git a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf002CleanInactivity.java b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf002CleanInactivity.java index 7d7daf42..86e0ecbf 100644 --- a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf002CleanInactivity.java +++ b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf002CleanInactivity.java @@ -1,15 +1,15 @@ package net.knarcraft.factions.entity.migrator; -import net.knarcraft.factions.entity.MConf; import com.massivecraft.massivecore.store.migrator.MigratorFieldRename; import com.massivecraft.massivecore.store.migrator.MigratorRoot; +import net.knarcraft.factions.entity.MConf; public class MigratorMConf002CleanInactivity extends MigratorRoot { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MigratorMConf002CleanInactivity i = new MigratorMConf002CleanInactivity(); + private static final MigratorMConf002CleanInactivity i = new MigratorMConf002CleanInactivity(); public static MigratorMConf002CleanInactivity get() { return i; diff --git a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf003CleanInactivity.java b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf003CleanInactivity.java index fe2eee6a..0419884a 100644 --- a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf003CleanInactivity.java +++ b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf003CleanInactivity.java @@ -1,15 +1,15 @@ package net.knarcraft.factions.entity.migrator; -import net.knarcraft.factions.entity.MConf; import com.massivecraft.massivecore.store.migrator.MigratorFieldRename; import com.massivecraft.massivecore.store.migrator.MigratorRoot; +import net.knarcraft.factions.entity.MConf; public class MigratorMConf003CleanInactivity extends MigratorRoot { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MigratorMConf003CleanInactivity i = new MigratorMConf003CleanInactivity(); + private static final MigratorMConf003CleanInactivity i = new MigratorMConf003CleanInactivity(); public static MigratorMConf003CleanInactivity get() { return i; diff --git a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf004Rank.java b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf004Rank.java index 33c2411b..8cc45eba 100644 --- a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf004Rank.java +++ b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf004Rank.java @@ -3,8 +3,8 @@ package net.knarcraft.factions.entity.migrator; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import net.knarcraft.factions.entity.MConf; import com.massivecraft.massivecore.store.migrator.MigratorRoot; +import net.knarcraft.factions.entity.MConf; import java.util.Iterator; @@ -13,7 +13,7 @@ public class MigratorMConf004Rank extends MigratorRoot { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MigratorMConf004Rank i = new MigratorMConf004Rank(); + private static final MigratorMConf004Rank i = new MigratorMConf004Rank(); public static MigratorMConf004Rank get() { return i; @@ -69,9 +69,9 @@ public class MigratorMConf004Rank extends MigratorRoot { boolean success = false; for (Iterator it = array.iterator(); it.hasNext(); ) { JsonElement e = it.next(); - if (!e.getAsString().equals("MEMBER")) { - continue; - } + if (!e.getAsString().equals("MEMBER")) { + continue; + } it.remove(); success = true; } diff --git a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf005Warps.java b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf005Warps.java index 0891ee7c..6a95d2fe 100644 --- a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf005Warps.java +++ b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMConf005Warps.java @@ -1,15 +1,15 @@ package net.knarcraft.factions.entity.migrator; -import net.knarcraft.factions.entity.MConf; import com.massivecraft.massivecore.store.migrator.MigratorFieldRename; import com.massivecraft.massivecore.store.migrator.MigratorRoot; +import net.knarcraft.factions.entity.MConf; public class MigratorMConf005Warps extends MigratorRoot { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MigratorMConf005Warps i = new MigratorMConf005Warps(); + private static final MigratorMConf005Warps i = new MigratorMConf005Warps(); public static MigratorMConf005Warps get() { return i; diff --git a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMPerm001Warps.java b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMPerm001Warps.java index 7a57d5de..cb04fb11 100644 --- a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMPerm001Warps.java +++ b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMPerm001Warps.java @@ -2,15 +2,15 @@ package net.knarcraft.factions.entity.migrator; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import net.knarcraft.factions.entity.MPerm; import com.massivecraft.massivecore.store.migrator.MigratorRoot; +import net.knarcraft.factions.entity.MPerm; public class MigratorMPerm001Warps extends MigratorRoot { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MigratorMPerm001Warps i = new MigratorMPerm001Warps(); + private static final MigratorMPerm001Warps i = new MigratorMPerm001Warps(); public static MigratorMPerm001Warps get() { return i; @@ -28,23 +28,23 @@ public class MigratorMPerm001Warps extends MigratorRoot { public void migrateInner(JsonObject entity) { JsonElement jsonName = entity.get("name"); String name = jsonName.getAsString(); - if (name.equalsIgnoreCase("home")) { - name = "warp"; - } - if (name.equalsIgnoreCase("sethome")) { - name = "setwarp"; - } + if (name.equalsIgnoreCase("home")) { + name = "warp"; + } + if (name.equalsIgnoreCase("sethome")) { + name = "setwarp"; + } entity.addProperty("name", name); JsonElement jsonDesc = entity.get("desc"); String desc = jsonDesc.getAsString(); - if (desc.equalsIgnoreCase("teleport home")) { - desc = "teleport to warp"; - } - if (desc.equalsIgnoreCase("set the home")) { - desc = "set warps"; - } + if (desc.equalsIgnoreCase("teleport home")) { + desc = "teleport to warp"; + } + if (desc.equalsIgnoreCase("set the home")) { + desc = "set warps"; + } entity.addProperty("desc", desc); } diff --git a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMPerm002MoveStandard.java b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMPerm002MoveStandard.java index 5c4d5b22..8eae953a 100644 --- a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMPerm002MoveStandard.java +++ b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMPerm002MoveStandard.java @@ -3,10 +3,10 @@ package net.knarcraft.factions.entity.migrator; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import net.knarcraft.factions.entity.MConf; -import net.knarcraft.factions.entity.MPerm; import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.store.migrator.MigratorRoot; +import net.knarcraft.factions.entity.MConf; +import net.knarcraft.factions.entity.MPerm; import java.util.Set; @@ -15,7 +15,7 @@ public class MigratorMPerm002MoveStandard extends MigratorRoot { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MigratorMPerm002MoveStandard i = new MigratorMPerm002MoveStandard(); + private static final MigratorMPerm002MoveStandard i = new MigratorMPerm002MoveStandard(); public static MigratorMPerm002MoveStandard get() { return i; @@ -32,9 +32,9 @@ public class MigratorMPerm002MoveStandard extends MigratorRoot { @Override public void migrateInner(JsonObject entity) { JsonElement jsonStandard = entity.remove("standard"); - if (jsonStandard == null || !jsonStandard.isJsonArray()) { - return; - } + if (jsonStandard == null || !jsonStandard.isJsonArray()) { + return; + } JsonArray jsonArray = jsonStandard.getAsJsonArray(); Set result = new MassiveSet<>(); diff --git a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMPlayer001Ranks.java b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMPlayer001Ranks.java index 6d9f8b5c..4402dc58 100644 --- a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMPlayer001Ranks.java +++ b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMPlayer001Ranks.java @@ -3,12 +3,12 @@ package net.knarcraft.factions.entity.migrator; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; +import com.massivecraft.massivecore.store.migrator.MigratorRoot; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.FactionColl; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.Rank; -import com.massivecraft.massivecore.store.migrator.MigratorRoot; import java.util.Collection; @@ -17,7 +17,7 @@ public class MigratorMPlayer001Ranks extends MigratorRoot { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MigratorMPlayer001Ranks i = new MigratorMPlayer001Ranks(); + private static final MigratorMPlayer001Ranks i = new MigratorMPlayer001Ranks(); public static MigratorMPlayer001Ranks get() { return i; @@ -48,32 +48,32 @@ public class MigratorMPlayer001Ranks extends MigratorRoot { JsonElement jsonFaction = entity.get("factionId"); String factionId; - if (jsonFaction == null) { - factionId = MConf.get().defaultPlayerFactionId; - } else { - factionId = jsonFaction.getAsString(); - } + if (jsonFaction == null) { + factionId = MConf.get().defaultPlayerFactionId; + } else { + factionId = jsonFaction.getAsString(); + } Faction faction = FactionColl.get().get(factionId); - if (faction == null) { - faction = FactionColl.get().getNone(); - } + if (faction == null) { + faction = FactionColl.get().getNone(); + } // Get rank Rank rank = null; if (role != null) { Collection ranks = faction.getRanks().getAll(); for (Rank r : ranks) { - if (!r.getName().equalsIgnoreCase(role)) { - continue; - } + if (!r.getName().equalsIgnoreCase(role)) { + continue; + } rank = r; break; } } - if (rank == null) { - rank = faction.getLowestRank(); - } + if (rank == null) { + rank = faction.getLowestRank(); + } entity.add("rankId", new JsonPrimitive(rank.getId())); } diff --git a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMPlayer002UsingAdminMode.java b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMPlayer002UsingAdminMode.java index c2089f7a..b5c192d6 100644 --- a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMPlayer002UsingAdminMode.java +++ b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorMPlayer002UsingAdminMode.java @@ -1,15 +1,15 @@ package net.knarcraft.factions.entity.migrator; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.store.migrator.MigratorFieldRename; import com.massivecraft.massivecore.store.migrator.MigratorRoot; +import net.knarcraft.factions.entity.MPlayer; public class MigratorMPlayer002UsingAdminMode extends MigratorRoot { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MigratorMPlayer002UsingAdminMode i = new MigratorMPlayer002UsingAdminMode(); + private static final MigratorMPlayer002UsingAdminMode i = new MigratorMPlayer002UsingAdminMode(); public static MigratorMPlayer002UsingAdminMode get() { return i; diff --git a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorTerritoryAccess001Restructure.java b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorTerritoryAccess001Restructure.java index 110a1bc8..3a648a6b 100644 --- a/src/main/java/net/knarcraft/factions/entity/migrator/MigratorTerritoryAccess001Restructure.java +++ b/src/main/java/net/knarcraft/factions/entity/migrator/MigratorTerritoryAccess001Restructure.java @@ -3,16 +3,16 @@ package net.knarcraft.factions.entity.migrator; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.massivecraft.massivecore.store.migrator.MigratorRoot; import net.knarcraft.factions.TerritoryAccess; import net.knarcraft.factions.adapter.TerritoryAccessAdapter; -import com.massivecraft.massivecore.store.migrator.MigratorRoot; public class MigratorTerritoryAccess001Restructure extends MigratorRoot { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static MigratorTerritoryAccess001Restructure i = new MigratorTerritoryAccess001Restructure(); + private static final MigratorTerritoryAccess001Restructure i = new MigratorTerritoryAccess001Restructure(); public static MigratorTerritoryAccess001Restructure get() { return i; @@ -43,9 +43,9 @@ public class MigratorTerritoryAccess001Restructure extends MigratorRoot { grantedIds.addAll(playerIdsArr); } - if (grantedIds.size() > 0) { - entity.add(TerritoryAccessAdapter.GRANTED_IDS, grantedIds); - } + if (grantedIds.size() > 0) { + entity.add(TerritoryAccessAdapter.GRANTED_IDS, grantedIds); + } } } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsAbstractSender.java b/src/main/java/net/knarcraft/factions/event/EventFactionsAbstractSender.java index 4259bbe4..0110e1ba 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsAbstractSender.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsAbstractSender.java @@ -1,7 +1,7 @@ package net.knarcraft.factions.event; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.event.EventMassiveCore; +import net.knarcraft.factions.entity.MPlayer; import org.bukkit.command.CommandSender; public abstract class EventFactionsAbstractSender extends EventMassiveCore { diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsChunkChangeType.java b/src/main/java/net/knarcraft/factions/event/EventFactionsChunkChangeType.java index cc0a219e..ead20808 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsChunkChangeType.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsChunkChangeType.java @@ -1,7 +1,7 @@ package net.knarcraft.factions.event; -import net.knarcraft.factions.entity.Faction; import com.massivecraft.massivecore.Colorized; +import net.knarcraft.factions.entity.Faction; import org.bukkit.ChatColor; public enum EventFactionsChunkChangeType implements Colorized { @@ -51,18 +51,18 @@ public enum EventFactionsChunkChangeType implements Colorized { // -------------------------------------------- // public static EventFactionsChunkChangeType get(Faction oldFaction, Faction newFaction, Faction self) { - if (newFaction == oldFaction) { - return NONE; - } - if (oldFaction.isNone()) { - return BUY; - } - if (newFaction.isNormal()) { - return CONQUER; - } - if (oldFaction == self) { - return SELL; - } + if (newFaction == oldFaction) { + return NONE; + } + if (oldFaction.isNone()) { + return BUY; + } + if (newFaction.isNormal()) { + return CONQUER; + } + if (oldFaction == self) { + return SELL; + } return PILLAGE; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsChunksChange.java b/src/main/java/net/knarcraft/factions/event/EventFactionsChunksChange.java index 52a6a79b..585944c2 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsChunksChange.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsChunksChange.java @@ -1,13 +1,14 @@ package net.knarcraft.factions.event; -import net.knarcraft.factions.entity.BoardColl; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.collections.MassiveMap; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.MUtil; +import net.knarcraft.factions.entity.BoardColl; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.MPlayer; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.Map; @@ -22,7 +23,7 @@ public class EventFactionsChunksChange extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsCreate.java b/src/main/java/net/knarcraft/factions/event/EventFactionsCreate.java index 4b187384..a94067b7 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsCreate.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsCreate.java @@ -2,6 +2,7 @@ package net.knarcraft.factions.event; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsCreate extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -11,7 +12,7 @@ public class EventFactionsCreate extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsCreateFlags.java b/src/main/java/net/knarcraft/factions/event/EventFactionsCreateFlags.java index 7feb5fe7..5497bc67 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsCreateFlags.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsCreateFlags.java @@ -1,6 +1,7 @@ package net.knarcraft.factions.event; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * External plugins that add Faction flags should make sure they exist when this event is called. @@ -13,7 +14,7 @@ public class EventFactionsCreateFlags extends EventFactionsAbstract { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsCreatePerms.java b/src/main/java/net/knarcraft/factions/event/EventFactionsCreatePerms.java index df8198d5..9cb78bfb 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsCreatePerms.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsCreatePerms.java @@ -1,6 +1,7 @@ package net.knarcraft.factions.event; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * External plugins that add Faction perms should make sure they exist when this event is called. @@ -13,7 +14,7 @@ public class EventFactionsCreatePerms extends EventFactionsAbstract { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsDescriptionChange.java b/src/main/java/net/knarcraft/factions/event/EventFactionsDescriptionChange.java index e6340632..cbc70f84 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsDescriptionChange.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsDescriptionChange.java @@ -3,6 +3,7 @@ package net.knarcraft.factions.event; import net.knarcraft.factions.entity.Faction; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsDescriptionChange extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -12,7 +13,7 @@ public class EventFactionsDescriptionChange extends EventFactionsAbstractSender private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsDisband.java b/src/main/java/net/knarcraft/factions/event/EventFactionsDisband.java index 1993b8b1..09d880fd 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsDisband.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsDisband.java @@ -3,6 +3,7 @@ package net.knarcraft.factions.event; import net.knarcraft.factions.entity.Faction; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsDisband extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -12,7 +13,7 @@ public class EventFactionsDisband extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsExpansions.java b/src/main/java/net/knarcraft/factions/event/EventFactionsExpansions.java index 7051dc2e..03feb360 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsExpansions.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsExpansions.java @@ -4,6 +4,7 @@ import com.massivecraft.massivecore.collections.MassiveTreeMap; import com.massivecraft.massivecore.comparator.ComparatorCaseInsensitive; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; import java.util.Map; @@ -15,7 +16,7 @@ public class EventFactionsExpansions extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsFactionShowAsync.java b/src/main/java/net/knarcraft/factions/event/EventFactionsFactionShowAsync.java index 0b434ea0..446f1534 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsFactionShowAsync.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsFactionShowAsync.java @@ -1,9 +1,10 @@ package net.knarcraft.factions.event; -import net.knarcraft.factions.entity.Faction; import com.massivecraft.massivecore.PriorityLines; +import net.knarcraft.factions.entity.Faction; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; @@ -16,7 +17,7 @@ public class EventFactionsFactionShowAsync extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsFlagChange.java b/src/main/java/net/knarcraft/factions/event/EventFactionsFlagChange.java index c5151ef4..9cd11529 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsFlagChange.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsFlagChange.java @@ -4,6 +4,7 @@ import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MFlag; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsFlagChange extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -13,7 +14,7 @@ public class EventFactionsFlagChange extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsInvitedChange.java b/src/main/java/net/knarcraft/factions/event/EventFactionsInvitedChange.java index 37b86654..9c54b60d 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsInvitedChange.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsInvitedChange.java @@ -4,6 +4,7 @@ import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MPlayer; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsInvitedChange extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -13,7 +14,7 @@ public class EventFactionsInvitedChange extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsMembershipChange.java b/src/main/java/net/knarcraft/factions/event/EventFactionsMembershipChange.java index 5118c3ba..c9c4e37e 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsMembershipChange.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsMembershipChange.java @@ -4,6 +4,7 @@ import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MPlayer; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsMembershipChange extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -13,7 +14,7 @@ public class EventFactionsMembershipChange extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsMotdChange.java b/src/main/java/net/knarcraft/factions/event/EventFactionsMotdChange.java index 7a8ab667..ab5915c8 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsMotdChange.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsMotdChange.java @@ -3,6 +3,7 @@ package net.knarcraft.factions.event; import net.knarcraft.factions.entity.Faction; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsMotdChange extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -12,7 +13,7 @@ public class EventFactionsMotdChange extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsNameChange.java b/src/main/java/net/knarcraft/factions/event/EventFactionsNameChange.java index 6773be41..982f88a0 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsNameChange.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsNameChange.java @@ -3,6 +3,7 @@ package net.knarcraft.factions.event; import net.knarcraft.factions.entity.Faction; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsNameChange extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -12,7 +13,7 @@ public class EventFactionsNameChange extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsPermChange.java b/src/main/java/net/knarcraft/factions/event/EventFactionsPermChange.java index 7b486e91..efb47e4e 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsPermChange.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsPermChange.java @@ -4,6 +4,7 @@ import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MPerm; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsPermChange extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -13,7 +14,7 @@ public class EventFactionsPermChange extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsPowerChange.java b/src/main/java/net/knarcraft/factions/event/EventFactionsPowerChange.java index 2a076a22..8ee2ecdd 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsPowerChange.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsPowerChange.java @@ -3,6 +3,7 @@ package net.knarcraft.factions.event; import net.knarcraft.factions.entity.MPlayer; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsPowerChange extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -12,7 +13,7 @@ public class EventFactionsPowerChange extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } @@ -66,7 +67,6 @@ public class EventFactionsPowerChange extends EventFactionsAbstractSender { DEATH, COMMAND, UNDEFINED, - ; } } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsPvpDisallowed.java b/src/main/java/net/knarcraft/factions/event/EventFactionsPvpDisallowed.java index 9e2f16c6..5fb147c6 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsPvpDisallowed.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsPvpDisallowed.java @@ -5,6 +5,7 @@ import net.knarcraft.factions.entity.MPlayer; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; /** * This event is fired when PVP is disallowed between players due to any rules in Factions. @@ -21,7 +22,7 @@ public class EventFactionsPvpDisallowed extends EventFactionsAbstract { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsRankChange.java b/src/main/java/net/knarcraft/factions/event/EventFactionsRankChange.java index 2024fd40..078ea68e 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsRankChange.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsRankChange.java @@ -4,6 +4,7 @@ import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.Rank; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsRankChange extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -13,7 +14,7 @@ public class EventFactionsRankChange extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsRelationChange.java b/src/main/java/net/knarcraft/factions/event/EventFactionsRelationChange.java index d4ddb258..3258c475 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsRelationChange.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsRelationChange.java @@ -4,6 +4,7 @@ import net.knarcraft.factions.Rel; import net.knarcraft.factions.entity.Faction; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsRelationChange extends EventFactionsAbstractSender { @@ -14,7 +15,7 @@ public class EventFactionsRelationChange extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsTitleChange.java b/src/main/java/net/knarcraft/factions/event/EventFactionsTitleChange.java index 6d9dbfff..c9ce8cda 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsTitleChange.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsTitleChange.java @@ -3,6 +3,7 @@ package net.knarcraft.factions.event; import net.knarcraft.factions.entity.MPlayer; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsTitleChange extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -12,7 +13,7 @@ public class EventFactionsTitleChange extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsVoteAdd.java b/src/main/java/net/knarcraft/factions/event/EventFactionsVoteAdd.java index 4b5d0f3e..4c42813c 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsVoteAdd.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsVoteAdd.java @@ -4,6 +4,7 @@ import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.Vote; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsVoteAdd extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -13,7 +14,7 @@ public class EventFactionsVoteAdd extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsVoteRemove.java b/src/main/java/net/knarcraft/factions/event/EventFactionsVoteRemove.java index 41fb3d5d..73f8ae4e 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsVoteRemove.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsVoteRemove.java @@ -4,6 +4,7 @@ import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.Vote; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsVoteRemove extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -13,7 +14,7 @@ public class EventFactionsVoteRemove extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsWarpAdd.java b/src/main/java/net/knarcraft/factions/event/EventFactionsWarpAdd.java index ddcbe756..3d33192a 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsWarpAdd.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsWarpAdd.java @@ -4,6 +4,7 @@ import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.Warp; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsWarpAdd extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -13,7 +14,7 @@ public class EventFactionsWarpAdd extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsWarpRemove.java b/src/main/java/net/knarcraft/factions/event/EventFactionsWarpRemove.java index 0503249a..b4096990 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsWarpRemove.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsWarpRemove.java @@ -4,6 +4,7 @@ import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.Warp; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsWarpRemove extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -13,7 +14,7 @@ public class EventFactionsWarpRemove extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/event/EventFactionsWarpTeleport.java b/src/main/java/net/knarcraft/factions/event/EventFactionsWarpTeleport.java index 870f71d2..073210a6 100644 --- a/src/main/java/net/knarcraft/factions/event/EventFactionsWarpTeleport.java +++ b/src/main/java/net/knarcraft/factions/event/EventFactionsWarpTeleport.java @@ -3,6 +3,7 @@ package net.knarcraft.factions.event; import net.knarcraft.factions.entity.Warp; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class EventFactionsWarpTeleport extends EventFactionsAbstractSender { // -------------------------------------------- // @@ -12,7 +13,7 @@ public class EventFactionsWarpTeleport extends EventFactionsAbstractSender { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/net/knarcraft/factions/integration/Econ.java b/src/main/java/net/knarcraft/factions/integration/Econ.java index 9cc7e71b..7ed6ed92 100644 --- a/src/main/java/net/knarcraft/factions/integration/Econ.java +++ b/src/main/java/net/knarcraft/factions/integration/Econ.java @@ -1,12 +1,12 @@ package net.knarcraft.factions.integration; +import com.massivecraft.massivecore.money.Money; import net.knarcraft.factions.EconomyParticipator; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPerm; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.util.RelationUtil; -import com.massivecraft.massivecore.money.Money; import java.util.HashSet; import java.util.Set; @@ -25,16 +25,16 @@ public class Econ { // -------------------------------------------- // public static boolean payForAction(double cost, MPlayer usender, String actionDescription) { - if (!isEnabled()) { - return true; - } - if (cost == 0D) { - return true; - } + if (!isEnabled()) { + return true; + } + if (cost == 0D) { + return true; + } - if (usender.isOverriding()) { - return true; - } + if (usender.isOverriding()) { + return true; + } Faction usenderFaction = usender.getFaction(); @@ -50,20 +50,20 @@ public class Econ { // -------------------------------------------- // public static void modifyUniverseMoney(Object universe, double delta) { - if (!isEnabled()) { - return; - } + if (!isEnabled()) { + return; + } - if (MConf.get().econUniverseAccount == null) { - return; - } - if (MConf.get().econUniverseAccount.length() == 0) { - return; - } + if (MConf.get().econUniverseAccount == null) { + return; + } + if (MConf.get().econUniverseAccount.length() == 0) { + return; + } - if (!Money.exists(MConf.get().econUniverseAccount)) { - return; - } + if (!Money.exists(MConf.get().econUniverseAccount)) { + return; + } Money.spawn(MConf.get().econUniverseAccount, null, delta); } @@ -74,19 +74,19 @@ public class Econ { public static boolean isMePermittedYou(EconomyParticipator me, EconomyParticipator you, MPerm mperm) { // Null means special system invocation and is always to be accepted. - if (me == null) { - return true; - } + if (me == null) { + return true; + } // Always accept when in admin mode. - if (me instanceof MPlayer && ((MPlayer) me).isOverriding()) { - return true; - } + if (me instanceof MPlayer && ((MPlayer) me).isOverriding()) { + return true; + } // Always accept control of self - if (me == you) { - return true; - } + if (me == you) { + return true; + } Faction fMe = RelationUtil.getFaction(me); Faction fYou = RelationUtil.getFaction(you); @@ -94,18 +94,16 @@ public class Econ { // A faction can always transfer away the money of it's members and its own money... // This will however probably never happen as a faction does not have free will. // Ohh by the way... Yes it could. For daily rent to the faction. - if (me == fMe && fMe == fYou) { - return true; - } + if (me == fMe && fMe == fYou) { + return true; + } // Factions can be controlled by those that have permissions if (you instanceof Faction) { - if (me instanceof Faction && mperm.has((Faction) me, fYou)) { - return true; - } - if (me instanceof MPlayer && mperm.has((MPlayer) me, fYou, false)) { - return true; - } + if (me instanceof Faction && mperm.has((Faction) me, fYou)) { + return true; + } + return me instanceof MPlayer && mperm.has((MPlayer) me, fYou, false); } // Otherwise you may not! ;,,; @@ -117,9 +115,9 @@ public class Econ { } public static boolean transferMoney(EconomyParticipator from, EconomyParticipator to, EconomyParticipator by, double amount, boolean notify) { - if (!isEnabled()) { - return false; - } + if (!isEnabled()) { + return false; + } // The amount must be positive. // If the amount is negative we must flip and multiply amount with -1. @@ -168,9 +166,7 @@ public class Econ { public static Set getMPlayers(EconomyParticipator ep) { Set mplayers = new HashSet<>(); - if (ep == null) { - // Add nothing - } else if (ep instanceof MPlayer) { + if (ep instanceof MPlayer) { mplayers.add((MPlayer) ep); } else if (ep instanceof Faction) { mplayers.addAll(((Faction) ep).getMPlayers()); @@ -209,9 +205,9 @@ public class Econ { } public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis) { - if (!isEnabled()) { - return true; - } + if (!isEnabled()) { + return true; + } if (getMoney(ep) < delta) { if (toDoThis != null && !toDoThis.isEmpty()) { @@ -223,12 +219,12 @@ public class Econ { } public static boolean modifyMoney(EconomyParticipator ep, double delta, String actionDescription) { - if (!isEnabled()) { - return false; - } - if (delta == 0) { - return true; - } + if (!isEnabled()) { + return false; + } + if (delta == 0) { + return true; + } String You = ep.describeTo(ep, true); String you = ep.describeTo(ep, false); @@ -288,15 +284,15 @@ public class Econ { if (fromFaction) { Faction faction = (Faction) from; double money = faction.getMoney(); - if (amount > money) { - return false; - } + if (amount > money) { + return false; + } faction.setMoney(money - amount); } else if (from != null) { boolean temp = Money.despawn(from, by, amount); - if (temp == false) { - return temp; - } + if (!temp) { + return false; + } } // Handle to diff --git a/src/main/java/net/knarcraft/factions/integration/dynmap/AreaMarkerValues.java b/src/main/java/net/knarcraft/factions/integration/dynmap/AreaMarkerValues.java index 247d84ca..732e7f7c 100644 --- a/src/main/java/net/knarcraft/factions/integration/dynmap/AreaMarkerValues.java +++ b/src/main/java/net/knarcraft/factions/integration/dynmap/AreaMarkerValues.java @@ -185,9 +185,9 @@ public class AreaMarkerValues { false // not persistent ); - if (ret == null) { - return null; - } + if (ret == null) { + return null; + } // Description ret.setDescription(this.getDescription()); @@ -253,20 +253,20 @@ public class AreaMarkerValues { public static boolean equals(AreaMarker marker, double[] x, double[] z) { int length = marker.getCornerCount(); - if (x.length != length) { - return false; - } - if (z.length != length) { - return false; - } + if (x.length != length) { + return false; + } + if (z.length != length) { + return false; + } for (int i = 0; i < length; i++) { - if (marker.getCornerX(i) != x[i]) { - return false; - } - if (marker.getCornerZ(i) != z[i]) { - return false; - } + if (marker.getCornerX(i) != x[i]) { + return false; + } + if (marker.getCornerZ(i) != z[i]) { + return false; + } } return true; diff --git a/src/main/java/net/knarcraft/factions/integration/dynmap/DynmapStyle.java b/src/main/java/net/knarcraft/factions/integration/dynmap/DynmapStyle.java index e2bfb7fe..18a3e84f 100644 --- a/src/main/java/net/knarcraft/factions/integration/dynmap/DynmapStyle.java +++ b/src/main/java/net/knarcraft/factions/integration/dynmap/DynmapStyle.java @@ -105,9 +105,9 @@ public class DynmapStyle { @SafeVarargs public static T coalesce(T... items) { for (T item : items) { - if (item != null) { - return item; - } + if (item != null) { + return item; + } } return null; } @@ -116,7 +116,7 @@ public class DynmapStyle { int ret = 0x00FF00; try { ret = Integer.parseInt(string.substring(1), 16); - } catch (NumberFormatException nfx) { + } catch (NumberFormatException ignored) { } return ret; diff --git a/src/main/java/net/knarcraft/factions/integration/dynmap/EngineDynmap.java b/src/main/java/net/knarcraft/factions/integration/dynmap/EngineDynmap.java index 098105b0..2f05d188 100644 --- a/src/main/java/net/knarcraft/factions/integration/dynmap/EngineDynmap.java +++ b/src/main/java/net/knarcraft/factions/integration/dynmap/EngineDynmap.java @@ -1,12 +1,5 @@ package net.knarcraft.factions.integration.dynmap; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.entity.BoardColl; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.MConf; -import net.knarcraft.factions.entity.MFlag; -import net.knarcraft.factions.entity.MPlayer; -import net.knarcraft.factions.integration.Econ; import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.collections.MassiveMap; @@ -17,6 +10,13 @@ import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.TimeDiffUtil; import com.massivecraft.massivecore.util.TimeUnit; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.entity.BoardColl; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.MConf; +import net.knarcraft.factions.entity.MFlag; +import net.knarcraft.factions.entity.MPlayer; +import net.knarcraft.factions.integration.Econ; import org.apache.commons.lang.StringEscapeUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -43,7 +43,7 @@ public class EngineDynmap extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineDynmap i = new EngineDynmap(); + private static final EngineDynmap i = new EngineDynmap(); public static EngineDynmap get() { return i; @@ -98,18 +98,18 @@ public class EngineDynmap extends Engine { public void updateFactionsDynmap(Map areas) { long before = System.currentTimeMillis(); - if (!Bukkit.isPrimaryThread()) { - throw new IllegalStateException("async"); - } + if (!Bukkit.isPrimaryThread()) { + throw new IllegalStateException("async"); + } - if (!fetchDynmapAPI()) { - return; - } + if (!fetchDynmapAPI()) { + return; + } // createLayer() is thread safe but it makes use of fields set in fetchDynmapAPI() so we must have it after. - if (!updateLayer(createLayer())) { - return; - } + if (!updateLayer(createLayer())) { + return; + } updateAreas(areas); @@ -125,9 +125,9 @@ public class EngineDynmap extends Engine { // Thread Safe / Asynchronous: Yes public static void logTimeSpent(String name, long start) { - if (!MConf.get().dynmapLogTimeSpent) { - return; - } + if (!MConf.get().dynmapLogTimeSpent) { + return; + } long end = System.currentTimeMillis(); long duration = end - start; @@ -220,14 +220,14 @@ public class EngineDynmap extends Engine { public Map createAreas(String world, Faction faction, Set chunks) { // If the faction is visible ... - if (!isVisible(faction, world)) { - return Collections.emptyMap(); - } + if (!isVisible(faction, world)) { + return Collections.emptyMap(); + } // ... and has any chunks ... - if (chunks.isEmpty()) { - return Collections.emptyMap(); - } + if (chunks.isEmpty()) { + return Collections.emptyMap(); + } Map ret = new MassiveMap<>(); @@ -257,20 +257,20 @@ public class EngineDynmap extends Engine { Set points = new MassiveSet<>(); for (PS corner : polygonCorners) { - if (points.contains(corner)) { - points.remove(corner); - } else { - points.add(corner); - } + if (points.contains(corner)) { + points.remove(corner); + } else { + points.add(corner); + } } Map edges_h = new MassiveMap<>(); Map edges_v = new MassiveMap<>(); List sorted_x = new MassiveList<>(points); - Collections.sort(sorted_x, this::xThenZ); + sorted_x.sort(this::xThenZ); List sorted_z = new MassiveList<>(points); - Collections.sort(sorted_z, this::zThenX); + sorted_z.sort(this::zThenX); // Create horizontal edges for (int i = 0; i < points.size(); ) { @@ -311,23 +311,23 @@ public class EngineDynmap extends Engine { } private int zThenX(PS a, PS b) { - if (a.getChunkZ() < b.getChunkZ() || (a.getChunkZ().equals(b.getChunkZ()) && a.getChunkX() < b.getChunkX())) { - return -1; - } else if (a.equals(b)) { - return 0; - } else { - return 1; - } + if (a.getChunkZ() < b.getChunkZ() || (a.getChunkZ().equals(b.getChunkZ()) && a.getChunkX() < b.getChunkX())) { + return -1; + } else if (a.equals(b)) { + return 0; + } else { + return 1; + } } private int xThenZ(PS a, PS b) { - if (a.getChunkX() < b.getChunkX() || (a.getChunkX().equals(b.getChunkX()) && a.getChunkZ() < b.getChunkZ())) { - return -1; - } else if (a.equals(b)) { - return 0; - } else { - return 1; - } + if (a.getChunkX() < b.getChunkX() || (a.getChunkX().equals(b.getChunkX()) && a.getChunkZ() < b.getChunkZ())) { + return -1; + } else if (a.equals(b)) { + return 0; + } else { + return 1; + } } private static PS getMinimum(Collection pss) { @@ -433,9 +433,9 @@ public class EngineDynmap extends Engine { String partial = IntegrationDynmap.FACTIONS_AREA_ + world + "__" + faction.getId() + "__"; // If different than last time, then reset the counter - if (!partial.equals(lastPartialMarkerId)) { - markerIdx = 0; - } + if (!partial.equals(lastPartialMarkerId)) { + markerIdx = 0; + } this.lastPartialMarkerId = partial; @@ -481,9 +481,9 @@ public class EngineDynmap extends Engine { // MOTD (probably shouldn't be shown but if the server owner specifies it, I don't care) String motd = faction.getMotd(); - if (motd != null) { - ret = addToHtml(ret, "motd", motd); - } + if (motd != null) { + ret = addToHtml(ret, "motd", motd); + } // Age long ageMillis = faction.getAge(); @@ -572,9 +572,9 @@ public class EngineDynmap extends Engine { } public static String getHtmlPlayerName(MPlayer mplayer) { - if (mplayer == null) { - return "none"; - } + if (mplayer == null) { + return "none"; + } return StringEscapeUtils.escapeHtml(mplayer.getName()); } @@ -583,15 +583,15 @@ public class EngineDynmap extends Engine { } public static String addToHtml(String ret, String target, String replace) { - if (ret == null) { - throw new NullPointerException("ret"); - } - if (target == null) { - throw new NullPointerException("target"); - } - if (replace == null) { - throw new NullPointerException("replace"); - } + if (ret == null) { + throw new NullPointerException("ret"); + } + if (target == null) { + throw new NullPointerException("target"); + } + if (replace == null) { + throw new NullPointerException("replace"); + } target = "%" + target + "%"; replace = ChatColor.stripColor(replace); @@ -601,12 +601,12 @@ public class EngineDynmap extends Engine { // Thread Safe / Asynchronous: Yes private boolean isVisible(Faction faction, String world) { - if (faction == null) { - throw new NullPointerException("faction"); - } - if (world == null) { - throw new NullPointerException("world"); - } + if (faction == null) { + throw new NullPointerException("faction"); + } + if (world == null) { + throw new NullPointerException("world"); + } final String factionId = faction.getId(); final String factionName = faction.getName(); @@ -614,12 +614,12 @@ public class EngineDynmap extends Engine { Set ids = MUtil.set(factionId, factionName, worldId); - if (factionId == null) { - throw new NullPointerException("faction id"); - } - if (factionName == null) { - throw new NullPointerException("faction name"); - } + if (factionId == null) { + throw new NullPointerException("faction id"); + } + if (factionName == null) { + throw new NullPointerException("faction name"); + } Set visible = MConf.get().dynmapVisibleFactions; Set hidden = MConf.get().dynmapHiddenFactions; @@ -629,12 +629,7 @@ public class EngineDynmap extends Engine { return false; } - if (!hidden.isEmpty() && hidden.stream().anyMatch(ids::contains)) { - return false; - } - - - return true; + return hidden.isEmpty() || hidden.stream().noneMatch(ids::contains); } // Thread Safe / Asynchronous: Yes @@ -649,7 +644,7 @@ public class EngineDynmap extends Engine { } public static void logSevere(String msg) { - String message = ChatColor.RED.toString() + msg; + String message = ChatColor.RED + msg; Factions.get().log(message); } @@ -657,31 +652,21 @@ public class EngineDynmap extends Engine { XPLUS, ZPLUS, XMINUS, ZMINUS; public PS adjacent(PS ps) { - switch (this) { - case XPLUS: - return PS.valueOf(ps.getChunkX() + 1, ps.getChunkZ()); - case ZPLUS: - return PS.valueOf(ps.getChunkX(), ps.getChunkZ() + 1); - case XMINUS: - return PS.valueOf(ps.getChunkX() - 1, ps.getChunkZ()); - case ZMINUS: - return PS.valueOf(ps.getChunkX(), ps.getChunkZ() - 1); - } - throw new RuntimeException("say what"); + return switch (this) { + case XPLUS -> PS.valueOf(ps.getChunkX() + 1, ps.getChunkZ()); + case ZPLUS -> PS.valueOf(ps.getChunkX(), ps.getChunkZ() + 1); + case XMINUS -> PS.valueOf(ps.getChunkX() - 1, ps.getChunkZ()); + case ZMINUS -> PS.valueOf(ps.getChunkX(), ps.getChunkZ() - 1); + }; } public PS getCorner(PS ps) { - switch (this) { - case XPLUS: - return PS.valueOf(ps.getChunkX() + 1, ps.getChunkZ()); - case ZPLUS: - return PS.valueOf(ps.getChunkX() + 1, ps.getChunkZ() + 1); - case XMINUS: - return PS.valueOf(ps.getChunkX(), ps.getChunkZ() + 1); - case ZMINUS: - return PS.valueOf(ps.getChunkX(), ps.getChunkZ()); - } - throw new RuntimeException("say what"); + return switch (this) { + case XPLUS -> PS.valueOf(ps.getChunkX() + 1, ps.getChunkZ()); + case ZPLUS -> PS.valueOf(ps.getChunkX() + 1, ps.getChunkZ() + 1); + case XMINUS -> PS.valueOf(ps.getChunkX(), ps.getChunkZ() + 1); + case ZMINUS -> PS.valueOf(ps.getChunkX(), ps.getChunkZ()); + }; } public Direction turnRight() { @@ -708,9 +693,9 @@ public class EngineDynmap extends Engine { // If it is in the source // Remove it from there to avoid double-counting (and endless recursion) - if (!source.remove(next)) { - continue; - } + if (!source.remove(next)) { + continue; + } // Add to destination destination.add(next); diff --git a/src/main/java/net/knarcraft/factions/integration/dynmap/IntegrationDynmap.java b/src/main/java/net/knarcraft/factions/integration/dynmap/IntegrationDynmap.java index 309accf0..aded9027 100644 --- a/src/main/java/net/knarcraft/factions/integration/dynmap/IntegrationDynmap.java +++ b/src/main/java/net/knarcraft/factions/integration/dynmap/IntegrationDynmap.java @@ -33,7 +33,7 @@ public class IntegrationDynmap extends Integration { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static IntegrationDynmap i = new IntegrationDynmap(); + private static final IntegrationDynmap i = new IntegrationDynmap(); public static IntegrationDynmap get() { return i; diff --git a/src/main/java/net/knarcraft/factions/integration/dynmap/LayerValues.java b/src/main/java/net/knarcraft/factions/integration/dynmap/LayerValues.java index f62ce5ff..34bcd49f 100644 --- a/src/main/java/net/knarcraft/factions/integration/dynmap/LayerValues.java +++ b/src/main/java/net/knarcraft/factions/integration/dynmap/LayerValues.java @@ -86,9 +86,9 @@ public class LayerValues { public MarkerSet create(MarkerAPI markerApi, String id) { MarkerSet ret = markerApi.createMarkerSet(id, this.label, null, false); // ("null, false" at the end means "all icons allowed, not perisistent") - if (ret == null) { - return null; - } + if (ret == null) { + return null; + } // Minimum Zoom if (this.minimumZoom > 0) { diff --git a/src/main/java/net/knarcraft/factions/integration/dynmap/MarkerValues.java b/src/main/java/net/knarcraft/factions/integration/dynmap/MarkerValues.java index 50496bc6..3f6c3312 100644 --- a/src/main/java/net/knarcraft/factions/integration/dynmap/MarkerValues.java +++ b/src/main/java/net/knarcraft/factions/integration/dynmap/MarkerValues.java @@ -119,9 +119,9 @@ public class MarkerValues { false // not persistent ); - if (ret == null) { - return null; - } + if (ret == null) { + return null; + } ret.setDescription(this.getDescription()); @@ -165,9 +165,9 @@ public class MarkerValues { public static MarkerIcon getMarkerIcon(MarkerAPI markerApi, String name) { MarkerIcon ret = markerApi.getMarkerIcon(name); - if (ret == null) { - ret = markerApi.getMarkerIcon(IntegrationDynmap.DYNMAP_STYLE_HOME_MARKER); - } + if (ret == null) { + ret = markerApi.getMarkerIcon(IntegrationDynmap.DYNMAP_STYLE_HOME_MARKER); + } return ret; } diff --git a/src/main/java/net/knarcraft/factions/integration/lwc/EngineLwc.java b/src/main/java/net/knarcraft/factions/integration/lwc/EngineLwc.java index c97fed54..6b62a5c3 100644 --- a/src/main/java/net/knarcraft/factions/integration/lwc/EngineLwc.java +++ b/src/main/java/net/knarcraft/factions/integration/lwc/EngineLwc.java @@ -3,15 +3,15 @@ package net.knarcraft.factions.integration.lwc; import com.griefcraft.lwc.LWC; import com.griefcraft.model.Protection; import com.griefcraft.sql.PhysDB; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.util.IdUtil; import net.knarcraft.factions.Factions; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.event.EventFactionsChunkChangeType; import net.knarcraft.factions.event.EventFactionsChunksChange; -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.ps.PS; -import com.massivecraft.massivecore.util.IdUtil; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -27,7 +27,7 @@ public class EngineLwc extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineLwc i = new EngineLwc(); + private static final EngineLwc i = new EngineLwc(); public static EngineLwc get() { return i; @@ -55,12 +55,12 @@ public class EngineLwc extends Engine { public void removeProtectionsOnChunkChange(Faction newFaction, EventFactionsChunkChangeType type, Set chunks) { // If we are supposed to clear at this chunk change type ... Boolean remove = MConf.get().lwcRemoveOnChange.get(type); - if (remove == null) { - return; - } - if (remove == false) { - return; - } + if (remove == null) { + return; + } + if (!remove) { + return; + } // ... then remove for all other factions than the new one. // First we wait one tick to make sure the chunk ownership changes have been applied. @@ -112,9 +112,9 @@ public class EngineLwc extends Engine { String ownerName = protection.getOwner(); String ownerId = IdUtil.getId(ownerName); MPlayer owner = MPlayer.get(ownerId); - if (nonAliens.contains(owner)) { - continue; - } + if (nonAliens.contains(owner)) { + continue; + } protection.remove(); } } diff --git a/src/main/java/net/knarcraft/factions/integration/lwc/FactionsLwcModule.java b/src/main/java/net/knarcraft/factions/integration/lwc/FactionsLwcModule.java index c258ab50..3ecef7ff 100644 --- a/src/main/java/net/knarcraft/factions/integration/lwc/FactionsLwcModule.java +++ b/src/main/java/net/knarcraft/factions/integration/lwc/FactionsLwcModule.java @@ -5,16 +5,16 @@ import com.griefcraft.model.Protection; import com.griefcraft.scripting.JavaModule; import com.griefcraft.scripting.event.LWCProtectionInteractEvent; import com.griefcraft.scripting.event.LWCProtectionRegisterEvent; -import net.knarcraft.factions.Factions; -import net.knarcraft.factions.engine.EnginePermBuild; -import net.knarcraft.factions.entity.MConf; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.SoundEffect; import com.massivecraft.massivecore.mixin.MixinMessage; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.SmokeUtil; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.Factions; +import net.knarcraft.factions.engine.EnginePermBuild; +import net.knarcraft.factions.entity.MConf; +import net.knarcraft.factions.entity.MPlayer; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -27,7 +27,7 @@ public class FactionsLwcModule extends JavaModule { // These plugin variables must be present. // They are set by LWC using reflection somehow. - private Factions plugin; + private final Factions plugin; private LWC lwc; // -------------------------------------------- // @@ -46,15 +46,15 @@ public class FactionsLwcModule extends JavaModule { @Override public void onRegisterProtection(LWCProtectionRegisterEvent event) { // If this feature is enabled ... - if (!MConf.get().lwcMustHaveBuildRightsToCreate) { - return; - } + if (!MConf.get().lwcMustHaveBuildRightsToCreate) { + return; + } // ... and the player don't have build rights here ... // NOTE: We verbosely check the build rights so that a proper info message is sent - if (EnginePermBuild.canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), true)) { - return; - } + if (EnginePermBuild.canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), true)) { + return; + } // ... then cancel the event. event.setCancelled(true); @@ -63,9 +63,9 @@ public class FactionsLwcModule extends JavaModule { @Override public void onProtectionInteract(LWCProtectionInteractEvent event) { // If this feature is enabled ... - if (!MConf.get().lwcRemoveIfNoBuildRights) { - return; - } + if (!MConf.get().lwcRemoveIfNoBuildRights) { + return; + } // ... gather data ... final Protection protection = event.getProtection(); @@ -75,16 +75,16 @@ public class FactionsLwcModule extends JavaModule { final String ownerName = protection.getOwner(); final String ownerId = IdUtil.getId(ownerName); final MPlayer mowner = MPlayer.get(ownerId); - if (mowner == null) { - return; - } + if (mowner == null) { + return; + } // ... and if the protection owner no longer has build rights for the area ... // NOTE: We silently check the build rights for the protection owner. // NOTE: The protection owner may even be offline at the moment. - if (EnginePermBuild.canPlayerBuildAt(mowner, ps, false)) { - return; - } + if (EnginePermBuild.canPlayerBuildAt(mowner, ps, false)) { + return; + } // ... remove the protection ... protection.remove(); diff --git a/src/main/java/net/knarcraft/factions/integration/lwc/IntegrationLwc.java b/src/main/java/net/knarcraft/factions/integration/lwc/IntegrationLwc.java index 84ce88cf..3a639fa1 100644 --- a/src/main/java/net/knarcraft/factions/integration/lwc/IntegrationLwc.java +++ b/src/main/java/net/knarcraft/factions/integration/lwc/IntegrationLwc.java @@ -8,7 +8,7 @@ public class IntegrationLwc extends Integration { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static IntegrationLwc i = new IntegrationLwc(); + private static final IntegrationLwc i = new IntegrationLwc(); public static IntegrationLwc get() { return i; diff --git a/src/main/java/net/knarcraft/factions/integration/placeholderapi/IntegrationPlaceholderAPI.java b/src/main/java/net/knarcraft/factions/integration/placeholderapi/IntegrationPlaceholderAPI.java index f38c92a0..eeec86d4 100644 --- a/src/main/java/net/knarcraft/factions/integration/placeholderapi/IntegrationPlaceholderAPI.java +++ b/src/main/java/net/knarcraft/factions/integration/placeholderapi/IntegrationPlaceholderAPI.java @@ -11,7 +11,7 @@ public class IntegrationPlaceholderAPI extends Integration { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static IntegrationPlaceholderAPI i = new IntegrationPlaceholderAPI(); + private static final IntegrationPlaceholderAPI i = new IntegrationPlaceholderAPI(); public static IntegrationPlaceholderAPI get() { return i; @@ -27,15 +27,15 @@ public class IntegrationPlaceholderAPI extends Integration { @Override public void setIntegrationActiveInner(boolean active) { - if (active) { - PlaceholderFactions.get().register(); - } + if (active) { + PlaceholderFactions.get().register(); + } } public static void ensureRegistered() { - if (PlaceholderFactions.get().isRegistered()) { - return; - } + if (PlaceholderFactions.get().isRegistered()) { + return; + } PlaceholderFactions.get().register(); } @@ -44,13 +44,13 @@ public class IntegrationPlaceholderAPI extends Integration { @EventHandler(priority = EventPriority.MONITOR) public void lookForCommand(PlayerCommandPreprocessEvent event) { String str = event.getMessage(); - if (str.startsWith("/")) { - str = str.substring(1); - } + if (str.startsWith("/")) { + str = str.substring(1); + } - if (!str.startsWith("papi")) { - return; - } + if (!str.startsWith("papi")) { + return; + } Bukkit.getScheduler().runTaskLater(this.getPlugin(), IntegrationPlaceholderAPI::ensureRegistered, 10L); } diff --git a/src/main/java/net/knarcraft/factions/integration/placeholderapi/PlaceholderFactions.java b/src/main/java/net/knarcraft/factions/integration/placeholderapi/PlaceholderFactions.java index cb19ea3a..f3741701 100644 --- a/src/main/java/net/knarcraft/factions/integration/placeholderapi/PlaceholderFactions.java +++ b/src/main/java/net/knarcraft/factions/integration/placeholderapi/PlaceholderFactions.java @@ -1,10 +1,11 @@ package net.knarcraft.factions.integration.placeholderapi; +import me.clip.placeholderapi.expansion.PlaceholderExpansion; import net.knarcraft.factions.Factions; import net.knarcraft.factions.entity.BoardColl; import net.knarcraft.factions.entity.MPlayer; -import me.clip.placeholderapi.expansion.PlaceholderExpansion; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; import java.text.DecimalFormat; @@ -13,7 +14,7 @@ public class PlaceholderFactions extends PlaceholderExpansion { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static PlaceholderFactions i = new PlaceholderFactions(); + private static final PlaceholderFactions i = new PlaceholderFactions(); public static PlaceholderFactions get() { return i; @@ -24,55 +25,45 @@ public class PlaceholderFactions extends PlaceholderExpansion { // -------------------------------------------- // @Override - public String getIdentifier() { + public @NotNull String getIdentifier() { return "factions"; } @Override - public String getAuthor() { + public @NotNull String getAuthor() { return "Madus"; } @Override - public String getVersion() { + public @NotNull String getVersion() { return Factions.get().getDescription().getVersion(); } @Override - public String onPlaceholderRequest(Player player, String params) { - if (player == null) { - return null; - } + public String onPlaceholderRequest(Player player, @NotNull String params) { + if (player == null) { + return null; + } MPlayer mplayer = MPlayer.get(player); - if ("role".equals(params)) { - params = "rank"; - } + if ("role".equals(params)) { + params = "rank"; + } DecimalFormat df = new DecimalFormat("#.##"); - switch (params) { - case "faction": - return mplayer.getFaction().getName(); - case "power": - return df.format(mplayer.getPower()); - case "powermax": - return df.format(mplayer.getPowerMax()); - case "factionpower": - return df.format(mplayer.getFaction().getPower()); - case "factionpowermax": - return df.format(mplayer.getFaction().getPowerMax()); - case "title": - return mplayer.getTitle(); - case "rank": - return mplayer.getRank().getName(); - case "claims": - return Long.toString(BoardColl.get().getAll().stream().mapToInt(board -> board.getCount(mplayer.getFaction())).sum()); - case "onlinemembers": - return Integer.toString(mplayer.getFaction().getMPlayersWhereOnlineTo(mplayer).size()); - case "allmembers": - return Integer.toString(mplayer.getFaction().getMPlayers().size()); - } - return null; + return switch (params) { + case "faction" -> mplayer.getFaction().getName(); + case "power" -> df.format(mplayer.getPower()); + case "powermax" -> df.format(mplayer.getPowerMax()); + case "factionpower" -> df.format(mplayer.getFaction().getPower()); + case "factionpowermax" -> df.format(mplayer.getFaction().getPowerMax()); + case "title" -> mplayer.getTitle(); + case "rank" -> mplayer.getRank().getName(); + case "claims" -> Long.toString(BoardColl.get().getAll().stream().mapToInt(board -> board.getCount(mplayer.getFaction())).sum()); + case "onlinemembers" -> Integer.toString(mplayer.getFaction().getMPlayersWhereOnlineTo(mplayer).size()); + case "allmembers" -> Integer.toString(mplayer.getFaction().getMPlayers().size()); + default -> null; + }; } } diff --git a/src/main/java/net/knarcraft/factions/integration/venturechat/EngineVentureChat.java b/src/main/java/net/knarcraft/factions/integration/venturechat/EngineVentureChat.java index 1c1a6391..342e45c5 100644 --- a/src/main/java/net/knarcraft/factions/integration/venturechat/EngineVentureChat.java +++ b/src/main/java/net/knarcraft/factions/integration/venturechat/EngineVentureChat.java @@ -1,13 +1,13 @@ package net.knarcraft.factions.integration.venturechat; -import net.knarcraft.factions.engine.EngineChat; -import net.knarcraft.factions.entity.Faction; -import net.knarcraft.factions.entity.MConf; -import net.knarcraft.factions.entity.MPlayer; import com.massivecraft.massivecore.Engine; import mineverse.Aust1n46.chat.api.MineverseChatAPI; import mineverse.Aust1n46.chat.api.MineverseChatPlayer; import mineverse.Aust1n46.chat.channel.ChatChannel; +import net.knarcraft.factions.engine.EngineChat; +import net.knarcraft.factions.entity.Faction; +import net.knarcraft.factions.entity.MConf; +import net.knarcraft.factions.entity.MPlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -20,7 +20,7 @@ public class EngineVentureChat extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineVentureChat i = new EngineVentureChat(); + private static final EngineVentureChat i = new EngineVentureChat(); public static EngineVentureChat get() { return i; @@ -50,9 +50,9 @@ public class EngineVentureChat extends Engine { // If the channel is the Factions channel boolean factionChat = channelName.equalsIgnoreCase(MConf.get().ventureChatFactionChannelName); boolean allyChat = channelName.equalsIgnoreCase(MConf.get().ventureChatAllyChannelName); - if (!(factionChat || allyChat)) { - return; - } + if (!(factionChat || allyChat)) { + return; + } MPlayer mplayer = MPlayer.get(player); Faction faction = mplayer.getFaction(); diff --git a/src/main/java/net/knarcraft/factions/integration/venturechat/IntegrationVentureChat.java b/src/main/java/net/knarcraft/factions/integration/venturechat/IntegrationVentureChat.java index 7892aa05..f3a1e954 100644 --- a/src/main/java/net/knarcraft/factions/integration/venturechat/IntegrationVentureChat.java +++ b/src/main/java/net/knarcraft/factions/integration/venturechat/IntegrationVentureChat.java @@ -8,7 +8,7 @@ public class IntegrationVentureChat extends Integration { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static IntegrationVentureChat i = new IntegrationVentureChat(); + private static final IntegrationVentureChat i = new IntegrationVentureChat(); public static IntegrationVentureChat get() { return i; diff --git a/src/main/java/net/knarcraft/factions/integration/worldguard/EngineWorldGuard.java b/src/main/java/net/knarcraft/factions/integration/worldguard/EngineWorldGuard.java index 25cefda3..50747c3d 100644 --- a/src/main/java/net/knarcraft/factions/integration/worldguard/EngineWorldGuard.java +++ b/src/main/java/net/knarcraft/factions/integration/worldguard/EngineWorldGuard.java @@ -1,9 +1,5 @@ package net.knarcraft.factions.integration.worldguard; -import net.knarcraft.factions.entity.MConf; -import net.knarcraft.factions.entity.MFlag; -import net.knarcraft.factions.entity.MPlayer; -import net.knarcraft.factions.event.EventFactionsChunksChange; import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.ps.PS; import com.sk89q.worldedit.bukkit.BukkitWorld; @@ -15,6 +11,10 @@ import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion; import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; import com.sk89q.worldguard.protection.regions.ProtectedRegion; +import net.knarcraft.factions.entity.MConf; +import net.knarcraft.factions.entity.MFlag; +import net.knarcraft.factions.entity.MPlayer; +import net.knarcraft.factions.event.EventFactionsChunksChange; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -28,7 +28,7 @@ public class EngineWorldGuard extends Engine { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static EngineWorldGuard i = new EngineWorldGuard(); + private static final EngineWorldGuard i = new EngineWorldGuard(); public static EngineWorldGuard get() { return i; @@ -50,53 +50,53 @@ public class EngineWorldGuard extends Engine { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void checkForRegion(EventFactionsChunksChange event) { // Skip checks if the configuration has worldguardCheckEnabled disabled - if (!MConf.get().worldguardCheckEnabled) { - return; - } + if (!MConf.get().worldguardCheckEnabled) { + return; + } // Permanent Factions should not apply this rule - if (event.getNewFaction().getFlag(MFlag.ID_PERMANENT)) { - return; - } + if (event.getNewFaction().getFlag(MFlag.ID_PERMANENT)) { + return; + } MPlayer mplayer = event.getMPlayer(); Player player = mplayer.getPlayer(); // Only do this for players - if (player == null) { - return; - } + if (player == null) { + return; + } LocalPlayer wrapperPlayer = WorldGuardPlugin.inst().wrapPlayer(player); - if (!MConf.get().worldguardCheckWorldsEnabled.contains(player)) { - return; - } + if (!MConf.get().worldguardCheckWorldsEnabled.contains(player)) { + return; + } // For overriders don't bother checking - if (mplayer.isOverriding()) { - return; - } + if (mplayer.isOverriding()) { + return; + } for (PS chunk : event.getChunks()) { // Grab any regions in the chunk final List regions = this.getProtectedRegionsFor(chunk); // Ensure there are actually regions to go over - if (regions == null || regions.isEmpty()) { - continue; - } + if (regions == null || regions.isEmpty()) { + continue; + } for (ProtectedRegion region : regions) { // Ensure it's not the global region, and check if they're a member - if (region instanceof GlobalProtectedRegion || region.isMember(wrapperPlayer)) { - continue; - } + if (region instanceof GlobalProtectedRegion || region.isMember(wrapperPlayer)) { + continue; + } // Check for a permission - can't use Perm enum for this - if (player.hasPermission("factions.allowregionclaim." + region.getId())) { - continue; - } + if (player.hasPermission("factions.allowregionclaim." + region.getId())) { + continue; + } // No permission, notify player and stop claiming mplayer.msg("You cannot claim the chunk at %s, %s as there is a region in the way.", chunk.getChunkX(), chunk.getChunkZ()); @@ -132,9 +132,8 @@ public class EngineWorldGuard extends Engine { List regionList = new ArrayList<>(regionMap.values()); // Let's find what we've overlapped - List overlapRegions = region.getIntersectingRegions(regionList); - return overlapRegions; + return region.getIntersectingRegions(regionList); } } diff --git a/src/main/java/net/knarcraft/factions/integration/worldguard/IntegrationWorldGuard.java b/src/main/java/net/knarcraft/factions/integration/worldguard/IntegrationWorldGuard.java index b7664160..949a0463 100644 --- a/src/main/java/net/knarcraft/factions/integration/worldguard/IntegrationWorldGuard.java +++ b/src/main/java/net/knarcraft/factions/integration/worldguard/IntegrationWorldGuard.java @@ -8,7 +8,7 @@ public class IntegrationWorldGuard extends Integration { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static IntegrationWorldGuard i = new IntegrationWorldGuard(); + private static final IntegrationWorldGuard i = new IntegrationWorldGuard(); public static IntegrationWorldGuard get() { return i; diff --git a/src/main/java/net/knarcraft/factions/mixin/PowerMixin.java b/src/main/java/net/knarcraft/factions/mixin/PowerMixin.java index 4097e432..2f017611 100644 --- a/src/main/java/net/knarcraft/factions/mixin/PowerMixin.java +++ b/src/main/java/net/knarcraft/factions/mixin/PowerMixin.java @@ -1,16 +1,16 @@ package net.knarcraft.factions.mixin; +import com.massivecraft.massivecore.mixin.Mixin; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MPlayer; -import com.massivecraft.massivecore.mixin.Mixin; public class PowerMixin extends Mixin { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static PowerMixin d = new PowerMixin(); - private static PowerMixin i = d; + private static final PowerMixin d = new PowerMixin(); + private static final PowerMixin i = d; public static PowerMixin get() { return i; diff --git a/src/main/java/net/knarcraft/factions/predicate/PredicateCommandSenderFaction.java b/src/main/java/net/knarcraft/factions/predicate/PredicateCommandSenderFaction.java index 50ac70f2..3ddc6542 100644 --- a/src/main/java/net/knarcraft/factions/predicate/PredicateCommandSenderFaction.java +++ b/src/main/java/net/knarcraft/factions/predicate/PredicateCommandSenderFaction.java @@ -1,14 +1,16 @@ package net.knarcraft.factions.predicate; +import com.massivecraft.massivecore.util.MUtil; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MPlayer; -import com.massivecraft.massivecore.util.MUtil; import org.bukkit.command.CommandSender; +import java.io.Serial; import java.io.Serializable; import java.util.function.Predicate; public class PredicateCommandSenderFaction implements Predicate, Serializable { + @Serial private static final long serialVersionUID = 1L; // -------------------------------------------- // @@ -35,9 +37,9 @@ public class PredicateCommandSenderFaction implements Predicate, @Override public boolean test(CommandSender sender) { - if (MUtil.isntSender(sender)) { - return false; - } + if (MUtil.isntSender(sender)) { + return false; + } MPlayer mplayer = MPlayer.get(sender); return this.factionId.equals(mplayer.getFaction().getId()); diff --git a/src/main/java/net/knarcraft/factions/predicate/PredicateMPlayerRank.java b/src/main/java/net/knarcraft/factions/predicate/PredicateMPlayerRank.java index 156a2c5a..e93a65f0 100644 --- a/src/main/java/net/knarcraft/factions/predicate/PredicateMPlayerRank.java +++ b/src/main/java/net/knarcraft/factions/predicate/PredicateMPlayerRank.java @@ -35,13 +35,13 @@ public class PredicateMPlayerRank implements Predicate { @Override public boolean test(MPlayer mplayer) { - if (mplayer == null) { - return false; - } + if (mplayer == null) { + return false; + } Faction faction = mplayer.getFaction(); - if (!faction.hasRank(this.getRank())) { - throw new IllegalStateException("rank: " + rank.getId() + " player:" + mplayer.getId()); - } + if (!faction.hasRank(this.getRank())) { + throw new IllegalStateException("rank: " + rank.getId() + " player:" + mplayer.getId()); + } return mplayer.getRank() == this.rank; } } diff --git a/src/main/java/net/knarcraft/factions/task/TaskFlagPermCreate.java b/src/main/java/net/knarcraft/factions/task/TaskFlagPermCreate.java index 5c244d0f..18f40fbb 100644 --- a/src/main/java/net/knarcraft/factions/task/TaskFlagPermCreate.java +++ b/src/main/java/net/knarcraft/factions/task/TaskFlagPermCreate.java @@ -1,9 +1,9 @@ package net.knarcraft.factions.task; -import net.knarcraft.factions.entity.MFlag; -import net.knarcraft.factions.entity.MPerm; import com.massivecraft.massivecore.ModuloRepeatTask; import com.massivecraft.massivecore.util.TimeUnit; +import net.knarcraft.factions.entity.MFlag; +import net.knarcraft.factions.entity.MPerm; public class TaskFlagPermCreate extends ModuloRepeatTask { // -------------------------------------------- // @@ -16,7 +16,7 @@ public class TaskFlagPermCreate extends ModuloRepeatTask { // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static TaskFlagPermCreate i = new TaskFlagPermCreate(); + private static final TaskFlagPermCreate i = new TaskFlagPermCreate(); public static TaskFlagPermCreate get() { return i; diff --git a/src/main/java/net/knarcraft/factions/task/TaskPlayerPowerUpdate.java b/src/main/java/net/knarcraft/factions/task/TaskPlayerPowerUpdate.java index b7e6cf52..1cf6c5bb 100644 --- a/src/main/java/net/knarcraft/factions/task/TaskPlayerPowerUpdate.java +++ b/src/main/java/net/knarcraft/factions/task/TaskPlayerPowerUpdate.java @@ -1,15 +1,15 @@ package net.knarcraft.factions.task; +import com.massivecraft.massivecore.ModuloRepeatTask; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.util.MUtil; +import com.massivecraft.massivecore.util.TimeUnit; import net.knarcraft.factions.entity.BoardColl; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MFlag; import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.event.EventFactionsPowerChange; -import com.massivecraft.massivecore.ModuloRepeatTask; -import com.massivecraft.massivecore.ps.PS; -import com.massivecraft.massivecore.util.MUtil; -import com.massivecraft.massivecore.util.TimeUnit; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -18,7 +18,7 @@ public class TaskPlayerPowerUpdate extends ModuloRepeatTask { // INSTANCE // -------------------------------------------- // - private static TaskPlayerPowerUpdate i = new TaskPlayerPowerUpdate(); + private static final TaskPlayerPowerUpdate i = new TaskPlayerPowerUpdate(); public static TaskPlayerPowerUpdate get() { return i; diff --git a/src/main/java/net/knarcraft/factions/task/TaskTax.java b/src/main/java/net/knarcraft/factions/task/TaskTax.java index 9cb55a19..05064e9f 100644 --- a/src/main/java/net/knarcraft/factions/task/TaskTax.java +++ b/src/main/java/net/knarcraft/factions/task/TaskTax.java @@ -1,5 +1,12 @@ package net.knarcraft.factions.task; +import com.massivecraft.massivecore.Couple; +import com.massivecraft.massivecore.Task; +import com.massivecraft.massivecore.collections.MassiveMap; +import com.massivecraft.massivecore.mixin.MixinMessage; +import com.massivecraft.massivecore.money.Money; +import com.massivecraft.massivecore.util.IdUtil; +import com.massivecraft.massivecore.util.TimeUnit; import net.knarcraft.factions.Factions; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.FactionColl; @@ -9,13 +16,6 @@ import net.knarcraft.factions.entity.MPlayer; import net.knarcraft.factions.entity.MPlayerColl; import net.knarcraft.factions.event.EventFactionsMembershipChange; import net.knarcraft.factions.integration.Econ; -import com.massivecraft.massivecore.Couple; -import com.massivecraft.massivecore.Task; -import com.massivecraft.massivecore.collections.MassiveMap; -import com.massivecraft.massivecore.mixin.MixinMessage; -import com.massivecraft.massivecore.money.Money; -import com.massivecraft.massivecore.util.IdUtil; -import com.massivecraft.massivecore.util.TimeUnit; import java.util.Comparator; import java.util.List; @@ -27,7 +27,7 @@ public class TaskTax extends Task { // INSTANCE // -------------------------------------------- // - private static TaskTax i = new TaskTax(); + private static final TaskTax i = new TaskTax(); public static TaskTax get() { return i; @@ -105,9 +105,9 @@ public class TaskTax extends Task { for (Couple couple : taxes) { double tax = doTaxPlayer(couple); - if (tax == 0D) { - continue; - } + if (tax == 0D) { + continue; + } // Log data Faction faction = couple.getFirst().getFaction(); @@ -142,11 +142,11 @@ public class TaskTax extends Task { if (success) { // Inform player if (mplayer.isOnline()) { - if (tax > 0) { - mplayer.msg("You were just taxed %s by your faction.", Money.format(tax)); // Tax - } else { - mplayer.msg("You were just paid %s by your faction.", Money.format(-tax)); // Salary - } + if (tax > 0) { + mplayer.msg("You were just taxed %s by your faction.", Money.format(tax)); // Tax + } else { + mplayer.msg("You were just paid %s by your faction.", Money.format(-tax)); // Salary + } } return tax; @@ -154,9 +154,9 @@ public class TaskTax extends Task { { faction.msg("%s couldn't afford tax!", mplayer.describeTo(faction)); boolean kicked = tryKickPlayer(mplayer); - if (!kicked) { - faction.msg("%s could not afford tax.", mplayer.describeTo(faction)); - } + if (!kicked) { + faction.msg("%s could not afford tax.", mplayer.describeTo(faction)); + } return 0D; } else // If a salary { @@ -167,40 +167,36 @@ public class TaskTax extends Task { private boolean shouldBeTaxed(long now, MPlayer mplayer) { // Must have faction - if (!mplayer.hasFaction()) { - return false; - } + if (!mplayer.hasFaction()) { + return false; + } // Must have been online recently long offlinePeriod; - if (mplayer.isOnline()) { - offlinePeriod = 0; - } else { - offlinePeriod = now - mplayer.getLastActivityMillis(); - } + if (mplayer.isOnline()) { + offlinePeriod = 0; + } else { + offlinePeriod = now - mplayer.getLastActivityMillis(); + } int inactiveDays = MConf.get().taxInactiveDays; - if (inactiveDays > 0 && offlinePeriod > inactiveDays * TimeUnit.MILLIS_PER_DAY) { - return false; - } - - return true; + return inactiveDays <= 0 || offlinePeriod <= inactiveDays * TimeUnit.MILLIS_PER_DAY; } private boolean tryKickPlayer(MPlayer mplayer) { Faction faction = mplayer.getFaction(); - if (mplayer.getRank().isLeader()) { - return false; - } - if (!faction.getFlag(MFlag.getFlagTaxKick())) { - return false; - } + if (mplayer.getRank().isLeader()) { + return false; + } + if (!faction.getFlag(MFlag.getFlagTaxKick())) { + return false; + } EventFactionsMembershipChange event = new EventFactionsMembershipChange(null, mplayer, FactionColl.get().getNone(), EventFactionsMembershipChange.MembershipChangeReason.KICK); event.run(); - if (event.isCancelled()) { - return false; - } + if (event.isCancelled()) { + return false; + } faction.msg("%s could not afford tax and was kicked from your faction.", mplayer.describeTo(faction)); diff --git a/src/main/java/net/knarcraft/factions/util/AsciiCompass.java b/src/main/java/net/knarcraft/factions/util/AsciiCompass.java index 72d78a9e..306736ec 100644 --- a/src/main/java/net/knarcraft/factions/util/AsciiCompass.java +++ b/src/main/java/net/knarcraft/factions/util/AsciiCompass.java @@ -32,9 +32,9 @@ public class AsciiCompass { private static String visualizeRow(AsciiCompassDirection directionFacing, AsciiCompassDirection... cardinals) { // Catch - if (cardinals == null) { - throw new NullPointerException("cardinals"); - } + if (cardinals == null) { + throw new NullPointerException("cardinals"); + } // Create StringBuilder ret = new StringBuilder(cardinals.length); diff --git a/src/main/java/net/knarcraft/factions/util/AsciiCompassDirection.java b/src/main/java/net/knarcraft/factions/util/AsciiCompassDirection.java index 224ba854..92b68689 100644 --- a/src/main/java/net/knarcraft/factions/util/AsciiCompassDirection.java +++ b/src/main/java/net/knarcraft/factions/util/AsciiCompassDirection.java @@ -73,9 +73,9 @@ public enum AsciiCompassDirection { // The conversion from bukkit to usable degrees is (degrees - 180) % 360 // But we reduced the 180 to 157 (-23) because it makes the math easier that follows. degrees = (degrees - 157) % 360; - if (degrees < 0) { - degrees += 360; - } + if (degrees < 0) { + degrees += 360; + } // Get ordinal int ordinal = (int) Math.floor(degrees / 45); diff --git a/src/main/java/net/knarcraft/factions/util/AsciiMap.java b/src/main/java/net/knarcraft/factions/util/AsciiMap.java index d78c02e5..1a87a8f5 100644 --- a/src/main/java/net/knarcraft/factions/util/AsciiMap.java +++ b/src/main/java/net/knarcraft/factions/util/AsciiMap.java @@ -1,15 +1,15 @@ package net.knarcraft.factions.util; -import net.knarcraft.factions.RelationParticipator; -import net.knarcraft.factions.TerritoryAccess; -import net.knarcraft.factions.entity.Board; -import net.knarcraft.factions.entity.BoardColl; -import net.knarcraft.factions.entity.Faction; import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PSFormatHumanSpace; import com.massivecraft.massivecore.util.Txt; +import net.knarcraft.factions.RelationParticipator; +import net.knarcraft.factions.TerritoryAccess; +import net.knarcraft.factions.entity.Board; +import net.knarcraft.factions.entity.BoardColl; +import net.knarcraft.factions.entity.Faction; import org.bukkit.ChatColor; import org.bukkit.GameRule; import org.bukkit.World; @@ -42,7 +42,7 @@ public class AsciiMap { private static final int HEIGHT_EXTRA_HALF = HEIGHT_EXTRA / 2; private static final String TITLE_FORMAT = "(%d,%d) %s"; - private static final String TITLE_FORMAT_NO_COORDS = "%s"; + private static final String TITLE_FORMAT_NO_COORDINATES = "%s"; private static final Mson KEY_MIDDLE = mson("+").color(ChatColor.AQUA); private static final Mson KEY_WILDERNESS = mson("-").color(ChatColor.GRAY).tooltip(); private static final Mson KEY_OVERFLOW = mson("-").style(ChatColor.MAGIC).add(mson("").style(ChatColor.RESET)); @@ -155,16 +155,16 @@ public class AsciiMap { int chunkZ = chunk.getChunkZ(); String factionName = faction.getName(this.getRelationParticipator()); - boolean showCoords = showChunkCoords(chunk); + boolean showCoordinates = showChunkCoordinates(chunk); String title; - if (showCoords) { + if (showCoordinates) { title = String.format(TITLE_FORMAT, chunkX, chunkZ, factionName); } else { - title = String.format(TITLE_FORMAT_NO_COORDS, factionName); + title = String.format(TITLE_FORMAT_NO_COORDINATES, factionName); } - // Titleize + // Title-ize return Txt.titleize(title); } @@ -210,8 +210,7 @@ public class AsciiMap { if (chunkName != null) { tooltip += "\n" + ChatColor.WHITE + chunkName; } - Mson charChunk = charFaction.tooltip(tooltip); - return charChunk; + return charFaction.tooltip(tooltip); } private Mson getCharFaction(Faction faction) { @@ -274,16 +273,16 @@ public class AsciiMap { return Mson.implode(ret, SPACE); } - public static boolean showChunkCoords(PS chunk) { - return showChunkCoords(chunk.asBukkitWorld(true)); + public static boolean showChunkCoordinates(PS chunk) { + return showChunkCoordinates(chunk.asBukkitWorld(true)); } - public static boolean showChunkCoords(World w) { + public static boolean showChunkCoordinates(World w) { return !w.getGameRuleValue(GameRule.REDUCED_DEBUG_INFO); } public static String getChunkDesc(PS chunk) { - return showChunkCoords(chunk) ? " at " + chunk.toString(PSFormatHumanSpace.get()) : ""; + return showChunkCoordinates(chunk) ? " at " + chunk.toString(PSFormatHumanSpace.get()) : ""; } public static String getChunkDescWithName(PS chunk, TerritoryAccess ta) { @@ -293,7 +292,7 @@ public class AsciiMap { } String ret = Txt.parse(" at %s", name); - if (showChunkCoords(chunk)) { + if (showChunkCoordinates(chunk)) { ret += Txt.parse(" (%s)", chunk.toString(PSFormatHumanSpace.get())); } return ret; diff --git a/src/main/java/net/knarcraft/factions/util/EnumerationUtil.java b/src/main/java/net/knarcraft/factions/util/EnumerationUtil.java index d7cf1c9c..d75865a5 100644 --- a/src/main/java/net/knarcraft/factions/util/EnumerationUtil.java +++ b/src/main/java/net/knarcraft/factions/util/EnumerationUtil.java @@ -1,7 +1,7 @@ package net.knarcraft.factions.util; -import net.knarcraft.factions.entity.MConf; import com.massivecraft.massivecore.collections.BackstringSet; +import net.knarcraft.factions.entity.MConf; import org.bukkit.Material; import org.bukkit.entity.EntityType; diff --git a/src/main/java/net/knarcraft/factions/util/MiscUtil.java b/src/main/java/net/knarcraft/factions/util/MiscUtil.java index 3cc41c6f..b35b0412 100644 --- a/src/main/java/net/knarcraft/factions/util/MiscUtil.java +++ b/src/main/java/net/knarcraft/factions/util/MiscUtil.java @@ -23,7 +23,7 @@ public class MiscUtil { return values; } - public static HashSet substanceChars = new HashSet<>(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", + public static final HashSet substanceChars = new HashSet<>(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")); diff --git a/src/main/java/net/knarcraft/factions/util/RelationUtil.java b/src/main/java/net/knarcraft/factions/util/RelationUtil.java index 01ef4f7e..8234be97 100644 --- a/src/main/java/net/knarcraft/factions/util/RelationUtil.java +++ b/src/main/java/net/knarcraft/factions/util/RelationUtil.java @@ -1,12 +1,12 @@ package net.knarcraft.factions.util; +import com.massivecraft.massivecore.util.Txt; import net.knarcraft.factions.Rel; import net.knarcraft.factions.RelationParticipator; import net.knarcraft.factions.entity.Faction; import net.knarcraft.factions.entity.MConf; import net.knarcraft.factions.entity.MFlag; import net.knarcraft.factions.entity.MPlayer; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; public class RelationUtil { @@ -26,14 +26,14 @@ public class RelationUtil { public static String describeThatToMe(RelationParticipator that, RelationParticipator me, boolean ucfirst) { String ret = ""; - if (that == null) { - return UNKNOWN_RELATION_OTHER; - } + if (that == null) { + return UNKNOWN_RELATION_OTHER; + } Faction thatFaction = getFaction(that); - if (thatFaction == null) { - return UNDEFINED_FACTION_OTHER; // ERROR - } + if (thatFaction == null) { + return UNDEFINED_FACTION_OTHER; // ERROR + } Faction myFaction = getFaction(me); @@ -48,8 +48,7 @@ public class RelationUtil { } else { ret = thatFactionName; } - } else if (that instanceof MPlayer) { - MPlayer mplayerthat = (MPlayer) that; + } else if (that instanceof MPlayer mplayerthat) { if (that == me) { ret = SELF; } else if (isSameFaction) { @@ -59,9 +58,9 @@ public class RelationUtil { } } - if (ucfirst) { - ret = Txt.upperCaseFirst(ret); - } + if (ucfirst) { + ret = Txt.upperCaseFirst(ret); + } return getColorOfThatToMe(that, me).toString() + ret; } @@ -80,23 +79,23 @@ public class RelationUtil { public static Rel getRelationOfThatToMe(RelationParticipator that, RelationParticipator me, boolean ignorePeaceful) { Faction myFaction = getFaction(me); - if (myFaction == null) { - return Rel.NEUTRAL; // ERROR - } + if (myFaction == null) { + return Rel.NEUTRAL; // ERROR + } Faction thatFaction = getFaction(that); - if (thatFaction == null) { - return Rel.NEUTRAL; // ERROR - } + if (thatFaction == null) { + return Rel.NEUTRAL; // ERROR + } if (myFaction.equals(thatFaction)) { return Rel.FACTION; } MFlag flagPeaceful = MFlag.getFlagPeaceful(); - if (!ignorePeaceful && (thatFaction.getFlag(flagPeaceful) || myFaction.getFlag(flagPeaceful))) { - return Rel.TRUCE; - } + if (!ignorePeaceful && (thatFaction.getFlag(flagPeaceful) || myFaction.getFlag(flagPeaceful))) { + return Rel.TRUCE; + } // The faction with the lowest wish "wins" Rel theirWish = thatFaction.getRelationWish(myFaction); @@ -109,13 +108,13 @@ public class RelationUtil { // -------------------------------------------- // public static Faction getFaction(RelationParticipator rp) { - if (rp instanceof Faction) { - return (Faction) rp; - } + if (rp instanceof Faction) { + return (Faction) rp; + } - if (rp instanceof MPlayer) { - return ((MPlayer) rp).getFaction(); - } + if (rp instanceof MPlayer) { + return ((MPlayer) rp).getFaction(); + } // ERROR return null; @@ -128,13 +127,13 @@ public class RelationUtil { public static ChatColor getColorOfThatToMe(RelationParticipator that, RelationParticipator me) { Faction thatFaction = getFaction(that); if (thatFaction != null && thatFaction != getFaction(me)) { - if (thatFaction.getFlag(MFlag.getFlagFriendlyire())) { - return MConf.get().colorFriendlyFire; - } + if (thatFaction.getFlag(MFlag.getFlagFriendlyire())) { + return MConf.get().colorFriendlyFire; + } - if (!thatFaction.getFlag(MFlag.getFlagPvp())) { - return MConf.get().colorNoPVP; - } + if (!thatFaction.getFlag(MFlag.getFlagPvp())) { + return MConf.get().colorNoPVP; + } } return getRelationOfThatToMe(that, me).getColor(); } diff --git a/src/main/java/net/knarcraft/factions/util/VisualizeUtil.java b/src/main/java/net/knarcraft/factions/util/VisualizeUtil.java index f69c3c5e..0a994635 100644 --- a/src/main/java/net/knarcraft/factions/util/VisualizeUtil.java +++ b/src/main/java/net/knarcraft/factions/util/VisualizeUtil.java @@ -18,7 +18,7 @@ import java.util.UUID; // TODO: Create packed queue to avoid freezes. public class VisualizeUtil { - protected static Map> playerLocations = new HashMap<>(); + protected static final Map> playerLocations = new HashMap<>(); public static Set getPlayerLocations(Player player) { return getPlayerLocations(player.getUniqueId()); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index eedc5e51..9344ef60 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,12 +1,12 @@ -main: ${project.groupId}.${project.name} +main: ${project.groupId}.factions.${project.name} name: ${project.name} version: ${project.version} website: ${project.url} description: ${project.description} -authors: [ Madus, Cayorion, Ulumulu1510, MarkehMe, Brettflan ] +authors: [ EpicKnarvik97, Madus, Cayorion, Ulumulu1510, MarkehMe, Brettflan ] depend: [ MassiveCore ] softdepend: [ PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, LocalAreaChat, LWC, ChatManager, AuthMe, Vault, WorldEdit, WorldGuard ] -api-version: 1.13 +api-version: 1.18 permissions: # -------------------------------------------- # # THE REAL NODES