From 1cc44d1b3ee4235c0ad3d33e0fcfdfe11cb66c5c Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Sun, 15 May 2016 00:20:07 -0300 Subject: [PATCH] Fixes for the following classes: KitGameModifier KitModifierType MultiBlockUpdaterAgent Shape GadgetManager KitModifierType HatLovestruck HatSecretPackage SetLove Animator AnimatorEntity AnimationPoint ICosmeticShape UtilText KitGameModifier KitModifierType Removed build.xml and org.eclipse.jdt.ui.prefs --- Plugins/Mineplex.Core.Common/build.xml | 145 ------------------ .../core/common/animation/AnimationPoint.java | 10 +- .../core/common/animation/Animator.java | 12 +- .../core/common/animation/AnimatorEntity.java | 5 +- .../common/block/MultiBlockUpdaterAgent.java | 10 +- ...ICosmeticShape.java => CosmeticShape.java} | 4 +- .../src/mineplex/core/common/shape/Shape.java | 7 +- .../mineplex/core/common/shape/ShapeBox.java | 4 +- .../mineplex/core/common/shape/ShapeGrid.java | 4 +- .../core/common/shape/ShapeSphere.java | 4 +- .../core/common/shape/ShapeWings.java | 2 +- .../mineplex/core/common/util/UtilText.java | 12 +- .../.settings/org.eclipse.jdt.ui.prefs | 3 - .../mineplex/core/gadget/GadgetManager.java | 32 ++-- .../gamemodifiers/kits/KitGameModifier.java | 11 +- .../gamemodifiers/kits/KitModifierType.java | 23 ++- .../gadget/gadgets/hat/HatLovestruck.java | 3 +- .../gadget/gadgets/hat/HatSecretPackage.java | 3 +- .../src/mineplex/core/gadget/set/SetLove.java | 5 - 19 files changed, 75 insertions(+), 224 deletions(-) delete mode 100644 Plugins/Mineplex.Core.Common/build.xml rename Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/{ICosmeticShape.java => CosmeticShape.java} (51%) delete mode 100644 Plugins/Mineplex.Core/.settings/org.eclipse.jdt.ui.prefs diff --git a/Plugins/Mineplex.Core.Common/build.xml b/Plugins/Mineplex.Core.Common/build.xml deleted file mode 100644 index 71796988b..000000000 --- a/Plugins/Mineplex.Core.Common/build.xml +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimationPoint.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimationPoint.java index 7b0030e13..82d819295 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimationPoint.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimationPoint.java @@ -2,6 +2,8 @@ package mineplex.core.common.animation; import org.bukkit.util.Vector; +import java.util.Objects; + public class AnimationPoint { @@ -41,16 +43,10 @@ public class AnimationPoint return false; } - @Override - public String toString() - { - return "[Tick: " + _tick + "," + _move.toString() + "]"; - } - @Override public int hashCode() { - return toString().hashCode(); + return Objects.hash(_tick, _move); } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/Animator.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/Animator.java index 62938e231..a3cfaa41d 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/Animator.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/Animator.java @@ -9,9 +9,9 @@ import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; import org.bukkit.util.Vector; -public class Animator +public abstract class Animator { - private Plugin _plugin; + private final Plugin _plugin; private TreeSet _points = new TreeSet<>((a, b) -> Integer.compare(a.getTick(), b.getTick())); @@ -132,12 +132,8 @@ public class Animator _repeat = repeat; } - protected void tick(Location loc) - { - } + protected abstract void tick(Location loc); - protected void finish(Location loc) - { - } + protected abstract void finish(Location loc); } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimatorEntity.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimatorEntity.java index b1eb061af..7db020576 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimatorEntity.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/animation/AnimatorEntity.java @@ -8,7 +8,7 @@ import org.bukkit.util.Vector; public class AnimatorEntity extends Animator { - private Entity _ent; + private final Entity _ent; public AnimatorEntity(Plugin plugin, Entity ent) { @@ -28,4 +28,7 @@ public class AnimatorEntity extends Animator _ent.teleport(loc); } + @Override + protected void finish(Location loc) {} + } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/MultiBlockUpdaterAgent.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/MultiBlockUpdaterAgent.java index 1d6398048..f8022fa36 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/MultiBlockUpdaterAgent.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/MultiBlockUpdaterAgent.java @@ -23,18 +23,12 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutMultiBlockChange.MultiBlockChan public class MultiBlockUpdaterAgent { - private Map> _chunks = new HashMap>(); + private Map> _chunks = new HashMap<>(); public void addBlock(Block block) { Chunk c = ((CraftChunk)block.getChunk()).getHandle(); - List list = _chunks.get(c); - - if(list == null) - { - list = new ArrayList(); - _chunks.put(c, list); - } + List list = _chunks.computeIfAbsent(c,chunk -> new ArrayList<>()); if(list.size() >= 64) return; diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ICosmeticShape.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/CosmeticShape.java similarity index 51% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ICosmeticShape.java rename to Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/CosmeticShape.java index fca4d89c5..2064c4932 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ICosmeticShape.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/CosmeticShape.java @@ -2,9 +2,9 @@ package mineplex.core.common.shape; import org.bukkit.Location; -public interface ICosmeticShape +public interface CosmeticShape { - public void display(Location loc); + void display(Location loc); } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/Shape.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/Shape.java index d79aaa0f9..6155299f3 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/Shape.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/Shape.java @@ -11,7 +11,7 @@ import org.bukkit.util.Vector; public class Shape { - protected final static double DefaultDensity = 1; + protected final static double DEFAULT_DENSITY = 1; protected HashSet _points = new HashSet<>(); @@ -21,11 +21,6 @@ public class Shape this._points.addAll(points); } - public Shape(Vector...points) - { - for(Vector v : points) this._points.add(v); - } - public void rotateOnXAxis(double radians) { for(Vector v : _points) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeBox.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeBox.java index 20202beb5..2ee5cf1b4 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeBox.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeBox.java @@ -7,12 +7,12 @@ public class ShapeBox extends Shape public ShapeBox(Vector localx, Vector localy, Vector localz) { - this(localx, localy, localz, false, DefaultDensity); + this(localx, localy, localz, false, DEFAULT_DENSITY); } public ShapeBox(Vector localx, Vector localy, Vector localz, boolean hollow) { - this(localx, localy, localz, hollow, DefaultDensity); + this(localx, localy, localz, hollow, DEFAULT_DENSITY); } public ShapeBox(Vector localx, Vector localy, Vector localz, boolean hollow, double density) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeGrid.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeGrid.java index 0df7b291a..978cca0a9 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeGrid.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeGrid.java @@ -13,7 +13,7 @@ public class ShapeGrid extends Shape */ public ShapeGrid(String... input) { - this(DefaultDensity, '#', input); + this(DEFAULT_DENSITY, '#', input); } /** @@ -24,7 +24,7 @@ public class ShapeGrid extends Shape */ public ShapeGrid(char read, String...input) { - this(DefaultDensity, read, input); + this(DEFAULT_DENSITY, read, input); } /** diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeSphere.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeSphere.java index 63cc59d56..acd9ac75c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeSphere.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeSphere.java @@ -12,12 +12,12 @@ public class ShapeSphere extends Shape public ShapeSphere(double x, double y, double z) { - this(x, y, z, false, DefaultDensity); + this(x, y, z, false, DEFAULT_DENSITY); } public ShapeSphere(double x, double y, double z, boolean hollow) { - this(x, y, z, hollow, DefaultDensity); + this(x, y, z, hollow, DEFAULT_DENSITY); } public ShapeSphere(double x, double y, double z, boolean hollow, double density) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java index 43a084a47..f766f39db 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java @@ -7,7 +7,7 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -public class ShapeWings extends ShapeGrid implements ICosmeticShape +public class ShapeWings extends ShapeGrid implements CosmeticShape { public static final String[] ANGEL_WING_PATTERN = new String[] { diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java index f9b989789..794e676bf 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java @@ -16,8 +16,10 @@ import mineplex.core.common.CurrencyType; public class UtilText { - private static HashMap _characters = new HashMap(); - private static HashMap _characterImages = new HashMap(); + private static HashMap _characters = new HashMap<>(); + private static HashMap _characterImages = new HashMap<>(); + + private final static char[] VOWELS = new char[]{'a', 'e', 'i', 'o', 'u'}; static { @@ -626,7 +628,7 @@ public class UtilText if(!plural(amount)) return word; String sufix = "s"; if(word.endsWith("s") || word.endsWith("x") || word.endsWith("z") || word.endsWith("ch")) sufix = "es"; - if(word.endsWith("y")) + else if(word.endsWith("y")) { word.substring(0, word.length()-2); sufix = "ies"; @@ -712,9 +714,7 @@ public class UtilText char v = word.toLowerCase().charAt(0); - char[] vowels = new char[]{'a', 'e', 'i', 'o', 'u', 'y'}; - - for(char c : vowels) + for(char c : VOWELS) { if(c == v) return true; } diff --git a/Plugins/Mineplex.Core/.settings/org.eclipse.jdt.ui.prefs b/Plugins/Mineplex.Core/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index e84db92fd..000000000 --- a/Plugins/Mineplex.Core/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.ui.javadoc=false -org.eclipse.jdt.ui.text.custom_code_templates= diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index d98b040e7..d229eda48 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -191,26 +191,26 @@ import mineplex.core.projectile.ProjectileManager; public class GadgetManager extends MiniPlugin { - private CoreClientManager _clientManager; - private DonationManager _donationManager; - private InventoryManager _inventoryManager; - private PetManager _petManager; - private PreferencesManager _preferencesManager; - private DisguiseManager _disguiseManager; - private BlockRestore _blockRestore; - private ProjectileManager _projectileManager; - private AchievementManager _achievementManager; - private MountManager _mountManager; - private PacketHandler _packetManager; - private HologramManager _hologramManager; - private OutfitWindUpSuitBoosterManager _boosterManager; + private final CoreClientManager _clientManager; + private final DonationManager _donationManager; + private final InventoryManager _inventoryManager; + private final PetManager _petManager; + private final PreferencesManager _preferencesManager; + private final DisguiseManager _disguiseManager; + private final BlockRestore _blockRestore; + private final ProjectileManager _projectileManager; + private final AchievementManager _achievementManager; + private final MountManager _mountManager; + private final PacketHandler _packetManager; + private final HologramManager _hologramManager; + private final OutfitWindUpSuitBoosterManager _boosterManager; private NautHashMap> _gadgets; - private NautHashMap _lastMove = new NautHashMap(); - private NautHashMap> _playerActiveGadgetMap = new NautHashMap>(); + private final NautHashMap _lastMove = new NautHashMap<>(); + private final NautHashMap> _playerActiveGadgetMap = new NautHashMap<>(); - private HashSet _sets = new HashSet<>(); + private final HashSet _sets = new HashSet<>(); private boolean _hideParticles = false; private int _activeItemSlot = 3; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/kits/KitGameModifier.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/kits/KitGameModifier.java index 10a619821..85dd1827e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/kits/KitGameModifier.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/kits/KitGameModifier.java @@ -1,6 +1,5 @@ package mineplex.core.gadget.gadgets.gamemodifiers.kits; -import com.sun.org.apache.xalan.internal.xsltc.dom.KeyIndex; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; import mineplex.core.gadget.types.GadgetGameModifier; @@ -10,6 +9,11 @@ import org.bukkit.entity.Player; import java.util.function.Predicate; +/** + * This class creates a Kit modifier, to be implemented in game kits, such as Survival Games or Bridges + * + * @author LCastr0 + */ public class KitGameModifier extends GadgetGameModifier { @@ -49,6 +53,11 @@ public class KitGameModifier extends GadgetGameModifier super.EnableCustom(player); } + /** + * Filters kit based on name + * @param kitName + * @return + */ public static Predicate getKitFilter(String kitName) { return new Predicate() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/kits/KitModifierType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/kits/KitModifierType.java index 15b89d36d..b26da1af5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/kits/KitModifierType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/kits/KitModifierType.java @@ -12,6 +12,11 @@ import org.bukkit.inventory.ItemStack; import java.util.List; +/** + * Lists types of KitGameModifier's + * + * @author LCastr0 + */ public enum KitModifierType { @@ -20,12 +25,20 @@ public enum KitModifierType SurvivalGames_HorsemanKit(GameModifierType.SurvivalGames, "Horseman", new String[]{"Placeholder"}, Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.HORSE)), SurvivalGames_NecromancerKit(GameModifierType.SurvivalGames, "Necromancer", new String[]{"Placeholder"}, Material.SKULL_ITEM, (byte) 0); - private GameModifierType _type; - private String _kitName; - private List _desc; - private Material _mat; - private byte _data; + private final GameModifierType _type; + private final String _kitName; + private final List _desc; + private final Material _mat; + private final byte _data; + /** + * + * @param type + * @param kitName + * @param desc + * @param mat + * @param data + */ KitModifierType(GameModifierType type, String kitName, String[] desc, Material mat, byte data) { _type = type; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatLovestruck.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatLovestruck.java index f07d14b93..d5cec5785 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatLovestruck.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatLovestruck.java @@ -14,8 +14,7 @@ public class HatLovestruck extends HatGadget { super(manager, "Love Struck", UtilText.splitLineToArray(C.cGray + "I think I'm in love... Wait a minute, did someone use a love potion on me?!", LineFormat.LORE), - -6, - SkinData.LOVESTRUCK.getSkull()); + -6, SkinData.LOVESTRUCK.getSkull()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatSecretPackage.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatSecretPackage.java index d1fa8b1e5..a369043ae 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatSecretPackage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/hat/HatSecretPackage.java @@ -14,8 +14,7 @@ public class HatSecretPackage extends HatGadget { super(manager, "Secret Package", UtilText.splitLineToArray(C.cGray + "I hope Chiss is inside!", LineFormat.LORE), - -6, - SkinData.SECRET_PACKAGE.getSkull()); + -6, SkinData.SECRET_PACKAGE.getSkull()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetLove.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetLove.java index 7808a83f8..12a6bf5e2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetLove.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetLove.java @@ -15,11 +15,6 @@ public class SetLove extends GadgetSet * Timestamp: February 4, 2016 */ - /* Note by LCastr0, at May 3rd, 2016: - * Seems to be a dupe of Cupid's Love set, will be commenting - * out the addition of this set to the GadgetManager. - * */ - public SetLove(GadgetManager manager) { super(manager, "Lovely!", "Coming soon...",