From a6af3c69c8bd093d402bc93a4e0f6cac8570fc80 Mon Sep 17 00:00:00 2001 From: Magnus Ulf Date: Mon, 6 May 2019 11:08:28 +0200 Subject: [PATCH] Further code cleanup --- .../massivecraft/factions/adapter/BoardAdapter.java | 5 +---- src/com/massivecraft/factions/chat/ChatTag.java | 2 +- .../factions/cmd/CmdFactionsAccessInspect.java | 2 +- .../massivecraft/factions/cmd/CmdFactionsStatus.java | 1 - .../factions/cmd/type/TypeFactionNameAbstract.java | 4 +--- .../factions/cmd/type/TypeMPermable.java | 1 - src/com/massivecraft/factions/engine/EngineShow.java | 1 - src/com/massivecraft/factions/entity/Rank.java | 3 +-- .../factions/integration/V19/EngineV19.java | 1 - .../massivecraft/factions/util/EnumerationUtil.java | 1 + src/com/massivecraft/factions/util/MiscUtil.java | 12 +++++------- 11 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/com/massivecraft/factions/adapter/BoardAdapter.java b/src/com/massivecraft/factions/adapter/BoardAdapter.java index b2df54c3..0965719a 100644 --- a/src/com/massivecraft/factions/adapter/BoardAdapter.java +++ b/src/com/massivecraft/factions/adapter/BoardAdapter.java @@ -6,12 +6,9 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParseException; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; -import com.massivecraft.factions.TerritoryAccess; import com.massivecraft.factions.entity.Board; -import com.massivecraft.massivecore.ps.PS; import java.lang.reflect.Type; -import java.util.Map; public class BoardAdapter implements JsonDeserializer, JsonSerializer { @@ -30,7 +27,7 @@ public class BoardAdapter implements JsonDeserializer, JsonSerializer) context.deserialize(json, Board.MAP_TYPE)); + return new Board(context.deserialize(json, Board.MAP_TYPE)); } @Override diff --git a/src/com/massivecraft/factions/chat/ChatTag.java b/src/com/massivecraft/factions/chat/ChatTag.java index 273d09e2..861e0b6f 100644 --- a/src/com/massivecraft/factions/chat/ChatTag.java +++ b/src/com/massivecraft/factions/chat/ChatTag.java @@ -12,7 +12,7 @@ public abstract class ChatTag extends ChatActive // -------------------------------------------- // private final static Map idToTag = new MassiveMap<>(); - public static ChatTag getTag(String tagId) { return (ChatTag) idToTag.get(tagId); } + public static ChatTag getTag(String tagId) { return idToTag.get(tagId); } // -------------------------------------------- // // CONSTRUCT diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAccessInspect.java b/src/com/massivecraft/factions/cmd/CmdFactionsAccessInspect.java index 102f88ba..61bdbe67 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAccessInspect.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsAccessInspect.java @@ -47,7 +47,7 @@ public class CmdFactionsAccessInspect extends FactionsCommand String factionId = faction.getId(); // Check if they have access perms, unless they are checking for their own access - if (mpermable != msender && mpermable != msenderFaction && mpermable != msender.getRank()); + if (mpermable != msender && mpermable != msenderFaction && mpermable != msender.getRank()) { if ( ! MPerm.getPermAccess().has(msender, faction, true)) return; } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsStatus.java b/src/com/massivecraft/factions/cmd/CmdFactionsStatus.java index 3609bc71..f1dcb1f9 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsStatus.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsStatus.java @@ -13,7 +13,6 @@ import com.massivecraft.massivecore.util.TimeDiffUtil; import com.massivecraft.massivecore.util.TimeUnit; import com.massivecraft.massivecore.util.Txt; -import java.util.Collections; import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; diff --git a/src/com/massivecraft/factions/cmd/type/TypeFactionNameAbstract.java b/src/com/massivecraft/factions/cmd/type/TypeFactionNameAbstract.java index f278c00a..8c08321d 100644 --- a/src/com/massivecraft/factions/cmd/type/TypeFactionNameAbstract.java +++ b/src/com/massivecraft/factions/cmd/type/TypeFactionNameAbstract.java @@ -1,6 +1,5 @@ package com.massivecraft.factions.cmd.type; -import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MPlayer; @@ -28,8 +27,7 @@ public class TypeFactionNameAbstract extends TypeNameAbstract public Named getCurrent(CommandSender sender) { MPlayer mplayer = MPlayer.get(sender); - Faction faction = mplayer.getFaction(); - return faction; + return mplayer.getFaction(); } @Override diff --git a/src/com/massivecraft/factions/cmd/type/TypeMPermable.java b/src/com/massivecraft/factions/cmd/type/TypeMPermable.java index 2e159319..c158a4c9 100644 --- a/src/com/massivecraft/factions/cmd/type/TypeMPermable.java +++ b/src/com/massivecraft/factions/cmd/type/TypeMPermable.java @@ -1,6 +1,5 @@ package com.massivecraft.factions.cmd.type; -import com.massivecraft.factions.Rel; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.MPerm; diff --git a/src/com/massivecraft/factions/engine/EngineShow.java b/src/com/massivecraft/factions/engine/EngineShow.java index abdea511..1dad84ff 100644 --- a/src/com/massivecraft/factions/engine/EngineShow.java +++ b/src/com/massivecraft/factions/engine/EngineShow.java @@ -19,7 +19,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import java.util.ArrayList; -import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedList; diff --git a/src/com/massivecraft/factions/entity/Rank.java b/src/com/massivecraft/factions/entity/Rank.java index 7c163e75..ae25f900 100644 --- a/src/com/massivecraft/factions/entity/Rank.java +++ b/src/com/massivecraft/factions/entity/Rank.java @@ -55,8 +55,7 @@ public class Rank extends EntityInternal implements MPerm.MPermable public Faction getFaction() { EntityInternalMap internalMap = (EntityInternalMap) this.getContainer(); - Faction faction = (Faction) internalMap.getEntity(); - return faction; + return (Faction) internalMap.getEntity(); } // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/integration/V19/EngineV19.java b/src/com/massivecraft/factions/integration/V19/EngineV19.java index 23d27067..6b273a5a 100644 --- a/src/com/massivecraft/factions/integration/V19/EngineV19.java +++ b/src/com/massivecraft/factions/integration/V19/EngineV19.java @@ -36,7 +36,6 @@ public class EngineV19 extends Engine // LISTENER // -------------------------------------------- // - @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void canCombatDamageHappen(AreaEffectCloudApplyEvent event) { diff --git a/src/com/massivecraft/factions/util/EnumerationUtil.java b/src/com/massivecraft/factions/util/EnumerationUtil.java index bf9a6de5..24f03445 100644 --- a/src/com/massivecraft/factions/util/EnumerationUtil.java +++ b/src/com/massivecraft/factions/util/EnumerationUtil.java @@ -209,6 +209,7 @@ public class EnumerationUtil "WITCH", // Minecraft 1.? "WITHER", // Minecraft 1.? "WITHER_SKELETON", + "STRAY", // Minecraft 1.? "ZOMBIE", // Minecraft 1.? "ZOMBIE_VILLAGER", "ILLUSIONER", // Minecraft 1.12 diff --git a/src/com/massivecraft/factions/util/MiscUtil.java b/src/com/massivecraft/factions/util/MiscUtil.java index 6b62f84f..608c4374 100644 --- a/src/com/massivecraft/factions/util/MiscUtil.java +++ b/src/com/massivecraft/factions/util/MiscUtil.java @@ -24,16 +24,14 @@ public class MiscUtil return values; } - public static HashSet substanceChars = new HashSet<>(Arrays.asList(new String[]{ - "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", + 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", "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" - })); + "s", "t", "u", "v", "w", "x", "y", "z")); public static String getComparisonString(String str) { - String ret = ""; + StringBuilder ret = new StringBuilder(); str = ChatColor.stripColor(str); str = str.toLowerCase(); @@ -42,10 +40,10 @@ public class MiscUtil { if (substanceChars.contains(String.valueOf(c))) { - ret += c; + ret.append(c); } } - return ret.toLowerCase(); + return ret.toString().toLowerCase(); } }