diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index c02db3d08..f7b4904a1 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -1,10 +1,13 @@ package mineplex.core.common.util; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; import net.minecraft.server.v1_8_R3.AxisAlignedBB; import net.minecraft.server.v1_8_R3.EntityBat; @@ -14,6 +17,7 @@ import net.minecraft.server.v1_8_R3.EntityHuman; import net.minecraft.server.v1_8_R3.EntityInsentient; import net.minecraft.server.v1_8_R3.EntityLiving; import net.minecraft.server.v1_8_R3.EntityTrackerEntry; +import net.minecraft.server.v1_8_R3.EntityTypes; import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.NavigationAbstract; import net.minecraft.server.v1_8_R3.PacketPlayOutEntity; @@ -43,6 +47,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Giant; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.Vector; @@ -60,7 +65,7 @@ public class UtilEnt private static Field _bsRestrictionGoal; private static Field _pathfinderBList; private static Field _pathfinderCList; - + public static HashMap GetEntityNames() { return _nameMap; @@ -994,7 +999,7 @@ public class UtilEnt { return ((CraftEntity)ent).getHandle().length; } - + public static double getWidth(Entity ent) { return ((CraftEntity)ent).getHandle().width; @@ -1062,4 +1067,26 @@ public class UtilEnt { return ((CraftEntity) entity).getHandle().inWater; } + + public static void registerEntityType(Class customClass, EntityType entityType, String name) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, NoSuchFieldException + { + Field cField = EntityTypes.class.getDeclaredField("c"); + Field eField = EntityTypes.class.getDeclaredField("e"); + + cField.setAccessible(true); + eField.setAccessible(true); + + ((Map) cField.get(null)).remove(name); + ((Map) eField.get(null)).remove((int) entityType.getTypeId()); + + Method method = EntityTypes.class.getDeclaredMethod("a", Class.class, String.class, int.class); + method.setAccessible(true); + method.invoke(null, customClass, name, entityType.getTypeId()); + } + + public static void spawnEntity(net.minecraft.server.v1_8_R3.Entity entity, Location location) + { + entity.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + ((CraftWorld) location.getWorld()).getHandle().addEntity(entity, SpawnReason.CUSTOM); + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java index 27a89d212..f85321a93 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/banner/CountryFlag.java @@ -66,6 +66,14 @@ public enum CountryFlag new Pattern(BLUE, CURLY_BORDER), new Pattern(WHITE, FLOWER)), + HEART("Heart", "Heart", RED, + new Pattern(BLACK, CURLY_BORDER), + new Pattern(BLACK, STRIPE_BOTTOM), + new Pattern(RED, RHOMBUS_MIDDLE), + new Pattern(RED, CIRCLE_MIDDLE), + new Pattern(BLACK, TRIANGLE_TOP), + new Pattern(BLACK, STRIPE_TOP)), + // Country AFGHANISTAN("Afghanistan", "Afghanistani", RED, new Pattern(BLACK, STRIPE_TOP), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 6e1606403..23d876bfb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -1474,15 +1474,15 @@ public enum Achievement ; - private String _name; - private String[] _desc; - private String[] _stats; - private int[][] _levelUpRewards; - private int[] _levels; - private String _defaultLevelName; - private String[] _levelNames; - private int _gems; - private AchievementCategory _category; + private final String _name; + private final String[] _desc; + private final String[] _stats; + private final int[][] _levelUpRewards; + private final int[] _levels; + private final String _defaultLevelName; + private final String[] _levelNames; + private final int _gems; + private final AchievementCategory _category; Achievement(String name, int gems, String[] stats, String[] desc, int[][] levelUpRewards, int[] levels, String defaultLevelName, String[] levelNames, AchievementCategory category) { @@ -1552,14 +1552,9 @@ public enum Achievement levels[i] = expReq; } -// for (int i=100 ; i> +@ReflectivelyCreateMiniPlugin +public class LevelingManager extends MiniDbClientPlugin> implements CommandCallback { - public enum Perm implements Permission - { - - VIEW_LEVEL_MENU - - } - - // That is a big old number private static final int MAX_LEVEL = 100; + private static final int EXCLUSIVE_REWARDS_LEVEL = 80; + public static int getMaxLevel() { return MAX_LEVEL; } - private final AchievementManager _achievement; + private final AchievementManager _achievementManager; + private final GadgetManager _gadgetManager; private final LevelingRepository _repository; private final LevelRewardShop _shop; - private final List> _rewards; + private final Map> _rewards; - public LevelingManager(AchievementManager achievementManager) + public LevelingManager() { super("Level Rewards"); - _achievement = achievementManager; + _achievementManager = require(AchievementManager.class); + _gadgetManager = require(GadgetManager.class); _repository = new LevelingRepository(); _shop = new LevelRewardShop(this, ClientManager, require(DonationManager.class)); - _rewards = new ArrayList<>(120); + _rewards = new HashMap<>(getMaxLevel()); + + ServerCommandManager.getInstance().registerCommandType(LevelBroadcastServerCommand.class, this); populateRewards(); - generatePermissions(); - - addCommand(new CommandBase(this, Perm.VIEW_LEVEL_MENU,"level") - { - @Override - public void Execute(Player caller, String[] args) - { - _shop.attemptShopOpen(caller); - } - }); - } - - private void generatePermissions() - { - PermissionGroup.PLAYER.setPermission(Perm.VIEW_LEVEL_MENU, true, true); } private void populateRewards() { + // 1-9 addCurrencyReward(1, GlobalCurrency.GEM, 100); addCurrencyReward(2, GlobalCurrency.GEM, 200); addChestReward(3, TreasureType.OLD, 1); @@ -90,17 +94,193 @@ public class LevelingManager extends MiniDbClientPlugin> addCurrencyReward(7, GlobalCurrency.GEM, 250); addCurrencyReward(8, GlobalCurrency.GEM, 250); addCurrencyReward(9, GlobalCurrency.GEM, 500); - addChestReward(10, TreasureType.OLD, 2); + // 10-19 + addChestReward(10, TreasureType.OLD, 5); + addCurrencyReward(11, GlobalCurrency.GEM, 750); + addCurrencyReward(12, GlobalCurrency.GEM, 250); + addCurrencyReward(12, GlobalCurrency.TREASURE_SHARD, 500); + addCurrencyReward(13, GlobalCurrency.GEM, 250); + addCurrencyReward(13, GlobalCurrency.TREASURE_SHARD, 500); + addCurrencyReward(14, GlobalCurrency.GEM, 1000); + addChestReward(15, TreasureType.OLD, 7); + addCurrencyReward(16, GlobalCurrency.GEM, 2000); + addCurrencyReward(17, GlobalCurrency.GEM, 500); + addCurrencyReward(17, GlobalCurrency.TREASURE_SHARD, 1000); + addCurrencyReward(18, GlobalCurrency.GEM, 500); + addCurrencyReward(18, GlobalCurrency.TREASURE_SHARD, 1000); + addChestReward(18, TreasureType.OLD, 8); + addCurrencyReward(19, GlobalCurrency.GEM, 5000); + // 20-29 + addGadgetReward(20, MorphOcelot.class); + addChestReward(20, TreasureType.OLD, 10); + addCurrencyReward(21, GlobalCurrency.GEM, 5000); + addCurrencyReward(22, GlobalCurrency.GEM, 500); + addCurrencyReward(22, GlobalCurrency.TREASURE_SHARD, 1000); + addChestReward(23, TreasureType.ANCIENT, 1); + addCurrencyReward(24, GlobalCurrency.GEM, 500); + addCurrencyReward(24, GlobalCurrency.TREASURE_SHARD, 1000); + addChestReward(25, TreasureType.ANCIENT, 5); + addCurrencyReward(26, GlobalCurrency.GEM, 10000); + addCurrencyReward(27, GlobalCurrency.GEM, 1000); + addCurrencyReward(27, GlobalCurrency.TREASURE_SHARD, 2000); + addCurrencyReward(28, GlobalCurrency.TREASURE_SHARD, 2000); + addChestReward(28, TreasureType.OLD, 2); + addChestReward(29, TreasureType.ANCIENT, 3); + // 30-39 + addCurrencyReward(30, GlobalCurrency.GEM, 20000); + addCurrencyReward(31, GlobalCurrency.GEM, 1000); + addCurrencyReward(32, GlobalCurrency.TREASURE_SHARD, 2500); + addChestReward(33, TreasureType.ANCIENT, 1); + addCurrencyReward(34, GlobalCurrency.GEM, 2000); + addCurrencyReward(34, GlobalCurrency.TREASURE_SHARD, 2500); + addCurrencyReward(35, GlobalCurrency.GEM, 30000); + addCurrencyReward(36, GlobalCurrency.TREASURE_SHARD, 500); + addChestReward(37, TreasureType.ANCIENT, 5); + addCurrencyReward(38, GlobalCurrency.TREASURE_SHARD, 1000); + addCurrencyReward(39, GlobalCurrency.TREASURE_SHARD, 500); + addChestReward(39, TreasureType.OLD, 5); + // 40-49 + addGadgetReward(40, ParticleWitchsCure.class); + addCurrencyReward(41, GlobalCurrency.TREASURE_SHARD, 1000); + addCurrencyReward(42, GlobalCurrency.TREASURE_SHARD, 1000); + addChestReward(42, TreasureType.OLD, 5); + addChestReward(43, TreasureType.ANCIENT, 6); + addCurrencyReward(44, GlobalCurrency.TREASURE_SHARD, 1000); + addChestReward(45, TreasureType.ANCIENT, 10); + addCurrencyReward(46, GlobalCurrency.TREASURE_SHARD, 1000); + addCurrencyReward(47, GlobalCurrency.TREASURE_SHARD, 1000); + addChestReward(48, TreasureType.OLD, 5); + addChestReward(48, TreasureType.ANCIENT, 7); + addCurrencyReward(49, GlobalCurrency.TREASURE_SHARD, 1000); + // 50-59 + addChestReward(50, TreasureType.OMEGA, 1); + addChestReward(51, TreasureType.ANCIENT, 10); + addCurrencyReward(52, GlobalCurrency.TREASURE_SHARD, 1500); + addCurrencyReward(53, GlobalCurrency.TREASURE_SHARD, 1500); + addChestReward(53, TreasureType.OLD, 10); + addChestReward(54, TreasureType.ANCIENT, 5); + addCurrencyReward(55, GlobalCurrency.TREASURE_SHARD, 1500); + addCurrencyReward(56, GlobalCurrency.TREASURE_SHARD, 1500); + addChestReward(57, TreasureType.ANCIENT, 10); + addCurrencyReward(58, GlobalCurrency.TREASURE_SHARD, 2500); + addChestReward(59, TreasureType.ANCIENT, 10); + // 60-69 + addGadgetReward(60, ParticleChickenWings.class); + addChestReward(60, TreasureType.MYTHICAL, 1); + addCurrencyReward(61, GlobalCurrency.TREASURE_SHARD, 1000); + addCurrencyReward(62, GlobalCurrency.TREASURE_SHARD, 1000); + addChestReward(62, TreasureType.ANCIENT, 1); + addChestReward(63, TreasureType.MYTHICAL, 2); + addCurrencyReward(64, GlobalCurrency.TREASURE_SHARD, 1000); + addCurrencyReward(65, GlobalCurrency.TREASURE_SHARD, 1000); + addChestReward(65, TreasureType.ANCIENT, 1); + addChestReward(66, TreasureType.MYTHICAL, 3); + addCurrencyReward(67, GlobalCurrency.TREASURE_SHARD, 1000); + addChestReward(67, TreasureType.ANCIENT, 1); + addCurrencyReward(68, GlobalCurrency.TREASURE_SHARD, 1000); + addChestReward(68, TreasureType.ANCIENT, 5); + addCurrencyReward(69, GlobalCurrency.TREASURE_SHARD, 1000); + // 70-79 + addChestReward(70, TreasureType.MYTHICAL, 6); + addCurrencyReward(71, GlobalCurrency.TREASURE_SHARD, 1000); + addCurrencyReward(72, GlobalCurrency.TREASURE_SHARD, 1000); + addChestReward(72, TreasureType.ANCIENT, 5); + addCurrencyReward(73, GlobalCurrency.TREASURE_SHARD, 1000); + addChestReward(74, TreasureType.MYTHICAL, 5); + addGameAmplifierReward(75, 1); + addCurrencyReward(75, GlobalCurrency.TREASURE_SHARD, 2500); + addCurrencyReward(76, GlobalCurrency.TREASURE_SHARD, 2500); + addChestReward(77, TreasureType.MYTHICAL, 10); + addCurrencyReward(78, GlobalCurrency.TREASURE_SHARD, 2500); + addCurrencyReward(79, GlobalCurrency.TREASURE_SHARD, 2500); + addChestReward(79, TreasureType.ANCIENT, 10); + // 80-89 + addGadgetReward(80, EasyModeTaunt.class); + addChestReward(80, TreasureType.ILLUMINATED, 1); + addChestReward(80, TreasureType.OMEGA, 1); + addChestReward(81, TreasureType.MYTHICAL, 5); + addCurrencyReward(82, GlobalCurrency.TREASURE_SHARD, 2500); + addCurrencyReward(83, GlobalCurrency.TREASURE_SHARD, 2500); + addCurrencyReward(84, GlobalCurrency.TREASURE_SHARD, 2500); + addChestReward(85, TreasureType.ILLUMINATED, 1); + addChestReward(85, TreasureType.MYTHICAL, 10); + addCurrencyReward(86, GlobalCurrency.TREASURE_SHARD, 2500); + addCurrencyReward(87, GlobalCurrency.TREASURE_SHARD, 2500); + addChestReward(87, TreasureType.MYTHICAL, 3); + addCurrencyReward(88, GlobalCurrency.TREASURE_SHARD, 2500); + addCurrencyReward(89, GlobalCurrency.TREASURE_SHARD, 2500); + // 90-99 + addGadgetReward(90, ParticleMacawWings.class); + addChestReward(90, TreasureType.ILLUMINATED, 1); + addChestReward(90, TreasureType.MYTHICAL, 10); + addCurrencyReward(91, GlobalCurrency.TREASURE_SHARD, 5000); + addCurrencyReward(92, GlobalCurrency.TREASURE_SHARD, 5000); + addChestReward(92, TreasureType.MYTHICAL, 3); + addCurrencyReward(93, GlobalCurrency.TREASURE_SHARD, 5000); + addChestReward(93, TreasureType.MYTHICAL, 5); + addCurrencyReward(94, GlobalCurrency.TREASURE_SHARD, 2500); + addChestReward(95, TreasureType.ILLUMINATED, 5); + addCurrencyReward(96, GlobalCurrency.TREASURE_SHARD, 10000); + addCurrencyReward(97, GlobalCurrency.TREASURE_SHARD, 10000); + addChestReward(97, TreasureType.MYTHICAL, 10); + addCurrencyReward(98, GlobalCurrency.TREASURE_SHARD, 10000); + addChestReward(98, TreasureType.MYTHICAL, 20); + addCurrencyReward(99, GlobalCurrency.TREASURE_SHARD, 15000); + // 100 + addGadgetReward(100, ParticleEnderDragonWings.class); + addChestReward(100, TreasureType.OMEGA, 5); + addDummyReward(100, C.cWhite + "10" + C.cPurple + " Different Level Colors"); + addCallbackReward(100, C.cRed + "Server Announcement", player -> + { + player.closeInventory(); + new LevelBroadcastServerCommand(player.getName()).publish(); + }); } private void addCurrencyReward(int level, GlobalCurrency type, int amount) { - _rewards.add(new SimpleEntry<>(level, new LevelCurrencyReward(type, amount))); + addReward(level, new LevelCurrencyReward(type, amount)); } private void addChestReward(int level, TreasureType type, int amount) { - _rewards.add(new SimpleEntry<>(level, new LevelChestReward(type, amount))); + addReward(level, new LevelChestReward(type, amount)); + } + + private void addGameAmplifierReward(int level, int amount) + { + addReward(level, new LevelGameAmplifierReward(amount)); + } + + private void addGadgetReward(int level, Class clazz) + { + addReward(level, new LevelGadgetReward(_gadgetManager.getGadget(clazz))); + } + + private void addDummyReward(int level, String description) + { + addReward(level, new LevelDummyReward(description)); + } + + private void addCallbackReward(int level, String description, Consumer callback) + { + addReward(level, new LevelCallbackReward(description, callback)); + } + + private void addReward(int level, LevelReward reward) + { + _rewards.computeIfAbsent(level, k -> new ArrayList<>(2)).add(reward); + } + + @Override + public void run(LevelBroadcastServerCommand command) + { + UtilTextMiddle.display(C.cRedB + command.getPlayer(), C.cGold + C.Scramble + "!!!" + C.cWhite + " Reached Level " + C.cRedB + "100 " + C.cGold + C.Scramble + "!!!",10, 60, 20, UtilServer.getPlayers()); + + for (Player player : UtilServer.getPlayersCollection()) + { + player.playSound(player.getLocation(), Sound.FIREWORK_TWINKLE, 1, 1); + } } @Override @@ -137,44 +317,26 @@ public class LevelingManager extends MiniDbClientPlugin> public int getLevel(Player player) { - return _achievement.getMineplexLevelNumber(player, false); + return _achievementManager.getMineplexLevelNumber(player, false); } public int getFirstUnclaimedLevel(Player player) { List claimed = Get(player); - for (Entry entry : _rewards) - { - int level = entry.getKey(); - - if (!claimed.contains(level)) - { - return level; - } - } - - return -1; + return _rewards.keySet().stream() + .filter(level -> !claimed.contains(level)) + .sorted() + .findFirst() + .orElse(-1); } public List getLevelRewards(int level) { - List rewards = new ArrayList<>(); - - for (Entry entry : _rewards) - { - int rewardLevel = entry.getKey(); - - if (level == rewardLevel) - { - rewards.add(entry.getValue()); - } - } - - return rewards; + return _rewards.get(level); } - public List> getLevelRewards() + public Map> getLevelRewards() { return _rewards; } @@ -183,7 +345,7 @@ public class LevelingManager extends MiniDbClientPlugin> { boolean claimed = hasClaimed(player, level); boolean canClaim = canClaim(player, level); - boolean exclusive = level > 100; + boolean exclusive = level >= EXCLUSIVE_REWARDS_LEVEL; Material material; byte data = 0; @@ -220,9 +382,22 @@ public class LevelingManager extends MiniDbClientPlugin> builder.setTitle(title); builder.addLore(""); + boolean hide = !canClaim && exclusive; + for (LevelReward reward : rewards) { - builder.addLore(" " + reward.getDescription()); + String lore = C.cWhite + " - "; + + if (hide) + { + lore += C.cRed + C.Scramble + "?????"; + } + else + { + lore += reward.getDescription(); + } + + builder.addLore(lore); } builder.addLore("", bottomLine); @@ -233,7 +408,7 @@ public class LevelingManager extends MiniDbClientPlugin> public void claim(Player player, int level) { Get(player).add(level); - _repository.claimReward(ClientManager.Get(player), level); + _repository.claimReward(ClientManager.getAccountId(player), level); } public boolean hasClaimed(Player player, int level) @@ -245,4 +420,23 @@ public class LevelingManager extends MiniDbClientPlugin> { return getLevel(player) >= level; } + + public long getUnclaimedLevels(Player player) + { + return _rewards.keySet().stream() + .filter(level -> !hasClaimed(player, level) && canClaim(player, level)) + .count(); + } + + public List>> getSortedRewards() + { + return _rewards.entrySet().stream() + .sorted(Comparator.comparingInt(Entry::getKey)) + .collect(Collectors.toList()); + } + + public LevelRewardShop getShop() + { + return _shop; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/LevelingRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/LevelingRepository.java index 0662a195d..3453efe0b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/LevelingRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/LevelingRepository.java @@ -1,6 +1,5 @@ package mineplex.core.achievement.leveling; -import mineplex.core.account.CoreClient; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.column.ColumnInt; @@ -15,10 +14,8 @@ public class LevelingRepository extends RepositoryBase super(DBPool.getAccount()); } - public void claimReward(CoreClient client, int level) + public void claimReward(int accountId, int level) { - int accountId = client.getAccountId(); - executeInsert(CLAIM_REWARD, null, new ColumnInt("accountId", accountId), new ColumnInt("level", level) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelCallbackReward.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelCallbackReward.java new file mode 100644 index 000000000..5c124979d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelCallbackReward.java @@ -0,0 +1,24 @@ +package mineplex.core.achievement.leveling.rewards; + +import java.util.function.Consumer; + +import org.bukkit.entity.Player; + +public class LevelCallbackReward extends LevelDummyReward +{ + + private final Consumer _callback; + + public LevelCallbackReward(String description, Consumer callback) + { + super(description); + + _callback = callback; + } + + @Override + public void claim(Player player) + { + _callback.accept(player); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelChestReward.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelChestReward.java index d43e706cb..c234c4d9f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelChestReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelChestReward.java @@ -2,7 +2,6 @@ package mineplex.core.achievement.leveling.rewards; import org.bukkit.entity.Player; -import mineplex.core.common.util.C; import mineplex.core.treasure.types.TreasureType; public class LevelChestReward implements LevelReward @@ -26,6 +25,6 @@ public class LevelChestReward implements LevelReward @Override public String getDescription() { - return C.cWhite + "- " + _amount + " " + _chest.getName(); + return _amount + " " + _chest.getName(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelCurrencyReward.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelCurrencyReward.java index e4db06375..5c7ed66af 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelCurrencyReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelCurrencyReward.java @@ -26,6 +26,6 @@ public class LevelCurrencyReward implements LevelReward @Override public String getDescription() { - return C.cWhite + "- " + F.currency(_type, _amount); + return F.currency(_type, _amount); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelDummyReward.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelDummyReward.java new file mode 100644 index 000000000..bb334bb2b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelDummyReward.java @@ -0,0 +1,26 @@ +package mineplex.core.achievement.leveling.rewards; + +import org.bukkit.entity.Player; + +public class LevelDummyReward implements LevelReward +{ + + private final String _description; + + public LevelDummyReward(String description) + { + _description = description; + } + + @Override + public void claim(Player player) + { + + } + + @Override + public String getDescription() + { + return _description; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelGadgetReward.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelGadgetReward.java new file mode 100644 index 000000000..e47556be5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelGadgetReward.java @@ -0,0 +1,30 @@ +package mineplex.core.achievement.leveling.rewards; + +import org.bukkit.entity.Player; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.gadget.types.Gadget; + +public class LevelGadgetReward implements LevelReward +{ + + private final Gadget _gadget; + + public LevelGadgetReward(Gadget gadget) + { + _gadget = gadget; + } + + @Override + public void claim(Player player) + { + DONATION.purchaseUnknownSalesPackage(player, _gadget.getName(), GlobalCurrency.TREASURE_SHARD, 0, true, null); + } + + @Override + public String getDescription() + { + return C.cGreen + _gadget.getName() + C.cWhite + " (" + C.cGreen + _gadget.getGadgetType().getCategoryType() + C.cWhite + ")"; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelGameAmplifierReward.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelGameAmplifierReward.java new file mode 100644 index 000000000..a0bcebece --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelGameAmplifierReward.java @@ -0,0 +1,29 @@ +package mineplex.core.achievement.leveling.rewards; + +import org.bukkit.entity.Player; + +import mineplex.core.boosters.BoosterManager; +import mineplex.core.common.util.C; + +public class LevelGameAmplifierReward implements LevelReward +{ + + private final int _amount; + + public LevelGameAmplifierReward(int amount) + { + _amount = amount; + } + + @Override + public void claim(Player player) + { + INVENTORY.addItemToInventory(player, BoosterManager.BOOSTER_ITEM, _amount); + } + + @Override + public String getDescription() + { + return C.cGreen + _amount + " Game Amplifer" + (_amount != 1 ? "s" : ""); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/ui/page/LevelRewardMainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/ui/page/LevelRewardMainPage.java index e6a04d53a..9fb362ef2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/ui/page/LevelRewardMainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/ui/page/LevelRewardMainPage.java @@ -5,12 +5,10 @@ import java.util.Map.Entry; import org.bukkit.Material; import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.PermissionGroup; -import mineplex.core.account.repository.token.Rank; import mineplex.core.achievement.leveling.LevelingManager; import mineplex.core.achievement.leveling.rewards.LevelReward; import mineplex.core.achievement.leveling.ui.LevelRewardShop; @@ -19,7 +17,6 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilMath; import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.shop.item.IButton; import mineplex.core.shop.page.ShopPageBase; public class LevelRewardMainPage extends ShopPageBase @@ -54,6 +51,26 @@ public class LevelRewardMainPage extends ShopPageBase _shop.openPageForPlayer(player, new LevelRewardViewAllPage(getPlugin(), getShop(), this, getClientManager(), getDonationManager(), player))); } private void addButton(int slot, int level, List rewards) { - if (level < 0 || rewards.isEmpty()) + if (level < 0 || rewards == null) { return; } @@ -109,7 +108,7 @@ public class LevelRewardMainPage extends ShopPageBase entry : _plugin.getLevelRewards()) + for (Entry> entry : _plugin.getLevelRewards().entrySet()) { int currentLevel = entry.getKey(); @@ -126,17 +125,17 @@ public class LevelRewardMainPage extends ShopPageBase entry : _plugin.getLevelRewards()) + for (Entry> entry : _plugin.getLevelRewards().entrySet()) { int currentLevel = entry.getKey(); if (currentLevel == level) { - foundSearch = true; + found = true; } - else if (foundSearch) + else if (found) { return currentLevel; } @@ -144,14 +143,4 @@ public class LevelRewardMainPage extends ShopPageBase { - private static final int DISPLAY_SIZE = 45; - private static final ItemStack UNKNOWN_REWARD = new ItemBuilder(Material.OBSIDIAN) - .setTitle(C.cRed + "???") - .addLore("", C.cRed + "You aren't a high enough level to claim this reward.") - .build(); private static final ItemStack GO_BACK = new ItemBuilder(Material.BED) - .setTitle(C.cGreen + "Click to go back.") + .setTitle(C.cGreen + "Go back") .build(); private final ShopPageBase _menu; - private int _startingLevel; + private final MultiPageManager>> _pageManager; - LevelRewardViewAllPage(LevelingManager plugin, LevelRewardShop shop, ShopPageBase menu, CoreClientManager clientManager, DonationManager donationManager, Player player, int startingLevel) + LevelRewardViewAllPage(LevelingManager plugin, LevelRewardShop shop, ShopPageBase menu, CoreClientManager clientManager, DonationManager donationManager, Player player) { super(plugin, shop, clientManager, donationManager, "All Level Rewards", player); _menu = menu; - _startingLevel = startingLevel; + _pageManager = new MultiPageManager<>(this, plugin::getSortedRewards, this::buildItem); buildPage(); } @@ -46,90 +41,22 @@ public class LevelRewardViewAllPage extends ShopPageBase= LevelingManager.getMaxLevel()) - { - lastPage = true; - break; - } - - List rewards = _plugin.getLevelRewards(level); - - // No reward for that level - if (rewards.isEmpty()) - { - level++; - continue; - } - - ItemStack itemStack; - - if (level > 100 && playerLevel < level) - { - itemStack = UNKNOWN_REWARD; - } - else - { - itemStack = _plugin.getLevelItem(_player, rewards, level); - } - - addButton(i++, itemStack, new LevelRewardButton(this, rewards, level)); - level++; - } - - // Not the first page - if (_startingLevel > 1) - { - addButton(46, getChangePageItem(true), new LevelRewardChangePageButton(_startingLevel - DISPLAY_SIZE)); - } - // Not the last page - else if (!lastPage) - { - addButton(53, getChangePageItem(false), new LevelRewardChangePageButton(_startingLevel + DISPLAY_SIZE)); - } - - addButton(49, GO_BACK, new GoBackButton()); - } - - private ItemStack getChangePageItem(boolean previous) - { - return new ItemBuilder(Material.ARROW) - .setTitle(previous ? "Previous Page" : "Next Page") - .build(); - } - - private class LevelRewardChangePageButton implements IButton - { - - private int _newStartingIndex; - - LevelRewardChangePageButton(int newStartingIndex) - { - _newStartingIndex = newStartingIndex; - } - - @Override - public void onClick(Player player, ClickType clickType) - { - // Update the starting index and rebuild the page - _startingLevel = _newStartingIndex; - refresh(); - } - } - - private class GoBackButton implements IButton - { - - @Override - public void onClick(Player player, ClickType clickType) + addButton(4, GO_BACK, (player, clickType) -> { + _menu.refresh(); _shop.openPageForPlayer(player, _menu); - } + }); } + + private void buildItem(Entry> entry, int slot) + { + int level = entry.getKey(); + List rewards = entry.getValue(); + ItemStack itemStack = _plugin.getLevelItem(_player, rewards, level); + + addButton(slot, itemStack, new LevelRewardButton(this, rewards, level)); + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index d869ba17e..3630c52a3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -42,6 +42,7 @@ import mineplex.core.account.ILoginProcessor; import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; +import mineplex.core.achievement.leveling.LevelingManager; import mineplex.core.bonuses.animations.AnimationCarl; import mineplex.core.bonuses.commands.AnimationCommand; import mineplex.core.bonuses.commands.GuiCommand; @@ -152,6 +153,7 @@ public class BonusManager extends MiniClientPlugin implements I private YoutubeManager _youtubeManager; private PowerPlayClubRepository _powerPlayClubRepository; private ThankManager _thankManager; + private LevelingManager _levelingManager; public boolean _enabled; private Npc _carlNpc; private Location _carlLocation; @@ -210,6 +212,7 @@ public class BonusManager extends MiniClientPlugin implements I _hologramManager = hologramManager; _inventoryManager = inventoryManager; _thankManager = thankManager; + _levelingManager = require(LevelingManager.class); _creeperName = creeperName; if (gadgetManager == null) @@ -1012,6 +1015,7 @@ public class BonusManager extends MiniClientPlugin implements I if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).getPrimaryGroup()) != null) availableRewards++; if (_thankManager.Get(player).getThankToClaim() > 0) availableRewards++; if (PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository)) availableRewards++; + availableRewards += _levelingManager.getUnclaimedLevels(player); Hologram hologram; @@ -1228,6 +1232,11 @@ public class BonusManager extends MiniClientPlugin implements I return _inventoryManager; } + public LevelingManager getLevelingManager() + { + return _levelingManager; + } + public Location getCarlLocation() { return _carlLocation; @@ -1242,4 +1251,4 @@ public class BonusManager extends MiniClientPlugin implements I { return _carlNpc; } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java index 1095a1716..976e54877 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/BonusGui.java @@ -8,6 +8,7 @@ import mineplex.core.bonuses.gui.buttons.CarlSpinButton; import mineplex.core.bonuses.gui.buttons.ClaimTipsButton; import mineplex.core.bonuses.gui.buttons.DailyBonusButton; import mineplex.core.bonuses.gui.buttons.FacebookButton; +import mineplex.core.bonuses.gui.buttons.LevelRewardsButton; import mineplex.core.bonuses.gui.buttons.PlayWireButton; import mineplex.core.bonuses.gui.buttons.PollButton; import mineplex.core.bonuses.gui.buttons.PowerPlayClubButton; @@ -22,16 +23,17 @@ import mineplex.core.youtube.YoutubeManager; public class BonusGui extends SimpleGui { - private final int VOTE_SLOT = 32; - private final int RANK_BONUS_SLOT = 10; - private final int DAILY_BONUS_SLOT = 12; - private final int POLL_SLOT = 28; - private final int FACEBOOK_SLOT = 20; - private final int CLAIM_TIPS_SLOT = 30; - private final int POWER_PLAY_SLOT = 16; - private final int CARL_SPINNER_SLOT = 14; - private final int YOUTUBE_SLOT = 24; - private final int TWITTER_SLOT = 34; + private static final int VOTE_SLOT = 32; + private static final int RANK_BONUS_SLOT = 10; + private static final int DAILY_BONUS_SLOT = 12; + private static final int POLL_SLOT = 28; + private static final int FACEBOOK_SLOT = 20; + private static final int CLAIM_TIPS_SLOT = 30; + private static final int POWER_PLAY_SLOT = 16; + private static final int CARL_SPINNER_SLOT = 14; + private static final int YOUTUBE_SLOT = 24; + private static final int TWITTER_SLOT = 34; + private static final int LEVEL_REWARDS_SLOT = 22; private static final int INV_SIZE = 45; @@ -58,6 +60,8 @@ public class BonusGui extends SimpleGui setItem(POWER_PLAY_SLOT, new PowerPlayClubButton(player, manager)); setItem(CARL_SPINNER_SLOT, new CarlSpinButton(getPlugin(), player, manager, rewardManager)); + + setItem(LEVEL_REWARDS_SLOT, new LevelRewardsButton(manager.getLevelingManager(), player)); } @Override @@ -65,4 +69,4 @@ public class BonusGui extends SimpleGui { super.finalize(); } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/LevelRewardsButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/LevelRewardsButton.java new file mode 100644 index 000000000..e6914e2c3 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/LevelRewardsButton.java @@ -0,0 +1,56 @@ +package mineplex.core.bonuses.gui.buttons; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.achievement.leveling.LevelingManager; +import mineplex.core.common.util.C; +import mineplex.core.gui.GuiItem; +import mineplex.core.itemstack.ItemBuilder; + +public class LevelRewardsButton implements GuiItem +{ + + private final LevelingManager _manager; + private final Player _player; + private final ItemStack _itemStack; + + public LevelRewardsButton(LevelingManager manager, Player player) + { + _manager = manager; + _player = player; + long levelsToClaim = manager.getUnclaimedLevels(player); + boolean anyToClaim = levelsToClaim > 0; + _itemStack = new ItemBuilder(anyToClaim ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK) + .setTitle((anyToClaim ? C.cGreenB : C.cRedB) + "Level Rewards") + .addLore("", "Earn rewards every time you", "level up your Mineplex Level!", "Unclaimed Rewards: " + C.cYellow + levelsToClaim, "", C.cGreen + "Click here to view rewards") + .setGlow(anyToClaim) + .build(); + } + + @Override + public void setup() + { + + } + + @Override + public void close() + { + + } + + @Override + public void click(ClickType clickType) + { + _manager.getShop().attemptShopOpen(_player); + } + + @Override + public ItemStack getObject() + { + return _itemStack; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java index 41e8f560e..8b3e25b2d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java @@ -33,9 +33,9 @@ import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.treasure.TreasureManager; import mineplex.core.pet.PetManager; import mineplex.core.punish.Punish; +import mineplex.core.treasure.TreasureManager; import mineplex.core.twofactor.TwoFactorAuth; public class CosmeticManager extends MiniPlugin diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java index c3d1791f3..d8761158c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java @@ -6,11 +6,9 @@ import org.bukkit.plugin.messaging.PluginMessageListener; import mineplex.core.account.CoreClientManager; import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.page.GadgetPage; import mineplex.core.cosmetic.ui.page.ItemGadgetPage; import mineplex.core.cosmetic.ui.page.Menu; import mineplex.core.cosmetic.ui.page.PetTagPage; -import mineplex.core.cosmetic.ui.page.custompet.name.CustomPetTagPage; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.event.ItemGadgetOutOfAmmoEvent; import mineplex.core.shop.ShopBase; @@ -46,16 +44,6 @@ public class CosmeticShop extends ShopBase implements PluginMes ((PetTagPage) getPlayerPageMap().get(player.getUniqueId())).SetTagName(tagName); } } - - if (getPlayerPageMap().containsKey(player.getUniqueId()) && getPlayerPageMap().get(player.getUniqueId()) instanceof CustomPetTagPage) - { - if (message != null && message.length >= 1) - { - String tagName = new String(message); - - ((CustomPetTagPage) getPlayerPageMap().get(player.getUniqueId())).setTagName(tagName); - } - } } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenGameModifiers.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenGameModifiers.java index a95742fa4..3b1b1e65d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenGameModifiers.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenGameModifiers.java @@ -1,10 +1,10 @@ package mineplex.core.cosmetic.ui.button.open; +import org.bukkit.entity.Player; + import mineplex.core.cosmetic.ui.page.Menu; import mineplex.core.cosmetic.ui.page.gamemodifiers.GameCosmeticsPage; import mineplex.core.gadget.types.Gadget; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; public class OpenGameModifiers extends OpenPageButton { @@ -14,15 +14,6 @@ public class OpenGameModifiers extends OpenPageButton super(menu, active); } - @Override - public void onClick(Player player, ClickType clickType) - { - if (clickType.isLeftClick()) - { - leftClick(player); - } - } - @Override protected void leftClick(Player player) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenWeaponNames.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenWeaponNames.java new file mode 100644 index 000000000..83a9fa88a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenWeaponNames.java @@ -0,0 +1,22 @@ +package mineplex.core.cosmetic.ui.button.open; + +import org.bukkit.entity.Player; + +import mineplex.core.cosmetic.ui.page.Menu; +import mineplex.core.cosmetic.ui.page.WeaponNamePage; +import mineplex.core.gadget.types.Gadget; + +public class OpenWeaponNames extends OpenPageButton +{ + + public OpenWeaponNames(Menu menu, Gadget active) + { + super(menu, active); + } + + @Override + protected void leftClick(Player player) + { + getMenu().getShop().openPageForPlayer(player, new WeaponNamePage(getMenu().getPlugin(), getMenu().getShop(), getMenu().getClientManager(), getMenu().getDonationManager(), player)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java index a01f40674..6001127aa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java @@ -6,9 +6,12 @@ import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilServer; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.event.GadgetChangeEvent; +import mineplex.core.gadget.event.GadgetChangeEvent.GadgetState; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.OutfitGadget; @@ -78,6 +81,7 @@ public class CostumePage extends GadgetPage { gadgetDisabled = true; gadget.disable(player); + UtilServer.CallEvent(new GadgetChangeEvent(player, gadget, GadgetState.DISABLED)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index f79967dce..55fe02078 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -24,6 +24,7 @@ import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.button.GadgetButton; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.event.GadgetChangeEvent; +import mineplex.core.gadget.event.GadgetChangeEvent.GadgetState; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetSet; import mineplex.core.gadget.types.GadgetType; @@ -243,6 +244,12 @@ public class GadgetPage extends ShopPageBase itemLore.add(C.cBlue + "Found in Trick or Treat Treasure"); break; + case CostConstants.FOUND_IN_MINESTRIKE_CHESTS: + itemLore.add(C.cBlack); + itemLore.add(C.cBlue + "Found in MineStrike Chests"); + break; + + // Ranks case CostConstants.UNLOCKED_WITH_ULTRA: itemLore.add(C.cBlack); @@ -293,6 +300,11 @@ public class GadgetPage extends ShopPageBase itemLore.add(C.cBlue + "Purchased from mineplex.com/shop"); break; + case CostConstants.LEVEL_REWARDS: + itemLore.add(C.cBlack); + itemLore.add(C.cBlue + "Unlocked in Level Rewards"); + break; + default: break; } @@ -326,14 +338,26 @@ public class GadgetPage extends ShopPageBase itemLore.add(C.cGreen + "Left-Click to Enable"); } + if (set != null) + { + if (set.isActive(getPlayer())) + { + itemLore.add(C.cGreen + "Shift-Click to Disable Set"); + } + else + { + itemLore.add(C.cGreen + "Shift-Click to Enable Set"); + } + } + meta.setLore(itemLore); gadgetItemStack.setItemMeta(meta); addButton(slot, new ShopItem(gadgetItemStack, false, false).hideInfo(), (player, clickType) -> { - if (clickType.isRightClick()) + if (clickType.isShiftClick()) { - handleRightClick(player, gadget); + toggleSet(player, gadget); } else { @@ -397,8 +421,10 @@ public class GadgetPage extends ShopPageBase ); } - public void toggleGadget(Player player, Gadget gadget) + private void toggleGadget(Player player, Gadget gadget) { + playAcceptSound(player); + if (gadget.isActive(player)) { deactivateGadget(player, gadget); @@ -409,26 +435,47 @@ public class GadgetPage extends ShopPageBase } } - public void activateGadget(Player player, Gadget gadget) + private void toggleSet(Player player, Gadget gadget) { - playAcceptSound(player); - gadget.enable(player); - GadgetChangeEvent gadgetChangeEvent = new GadgetChangeEvent(player, gadget, GadgetChangeEvent.GadgetState.ENABLED); - UtilServer.CallEvent(gadgetChangeEvent); + GadgetSet set = gadget.getSet(); + if (set == null) + { + return; + } + + if (set.isActive(player)) + { + for (Gadget setGadget : set.getGadgets()) + { + deactivateGadget(player, setGadget); + } + + playAcceptSound(player); + } + else + { + for (Gadget setGadget : set.getGadgets()) + { + if (setGadget.ownsGadget(player)) + { + activateGadget(player, setGadget); + } + } + } + } + + private void activateGadget(Player player, Gadget gadget) + { + gadget.enable(player); + UtilServer.CallEvent(new GadgetChangeEvent(player, gadget, GadgetState.ENABLED)); refresh(); } - public void handleRightClick(Player player, Gadget gadget) + private void deactivateGadget(Player player, Gadget gadget) { - } - - public void deactivateGadget(Player player, Gadget gadget) - { - playAcceptSound(player); gadget.disable(player); - GadgetChangeEvent gadgetChangeEvent = new GadgetChangeEvent(player, gadget, GadgetChangeEvent.GadgetState.DISABLED); - UtilServer.CallEvent(gadgetChangeEvent); + UtilServer.CallEvent(new GadgetChangeEvent(player, gadget, GadgetState.DISABLED)); refresh(); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ListGadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ListGadgetPage.java new file mode 100644 index 000000000..369a737f8 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/ListGadgetPage.java @@ -0,0 +1,31 @@ +package mineplex.core.cosmetic.ui.page; + +import java.util.List; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.types.Gadget; + +public class ListGadgetPage extends GadgetPage +{ + + private final List _gadgetList; + + ListGadgetPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, List gadgetList) + { + super(plugin, shop, clientManager, donationManager, name, player); + + _gadgetList = gadgetList; + buildPage(); + } + + @Override + protected List getGadgetsToDisplay() + { + return _gadgetList; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index c7725753b..08a3ded86 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -23,6 +23,7 @@ import mineplex.core.cosmetic.ui.button.open.OpenCostumes; import mineplex.core.cosmetic.ui.button.open.OpenGameModifiers; import mineplex.core.cosmetic.ui.button.open.OpenItems; import mineplex.core.cosmetic.ui.button.open.OpenPets; +import mineplex.core.cosmetic.ui.button.open.OpenWeaponNames; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.event.GadgetChangeEvent; import mineplex.core.gadget.event.GadgetChangeEvent.GadgetState; @@ -72,7 +73,9 @@ public class Menu extends ShopPageBase int flagSlot = 34; int morphSlot = 25; int costumeSlot = 16; + int weaponNameSlot = 4; int powerPlaySlot = 22; + int chatColourSlot = 40; EnumMap ownedCount = new EnumMap<>(GadgetType.class); EnumMap maxCount = new EnumMap<>(GadgetType.class); @@ -200,6 +203,16 @@ public class Menu extends ShopPageBase addButton(flagSlot, new ShopItem(Material.BANNER, "Flags", lore, 1, false), generateButton(type, enabled.get(type))); if (enabled.containsKey(type)) addGlow(flagSlot); + type = GadgetType.WEAPON_NAME; + lore = getLore(ownedCount.get(type), maxCount.get(type), "Something something", VISIBILITY_GAMES, null); + addButton(weaponNameSlot, new ShopItem(Material.DIAMOND_SWORD, "Weapon Names", lore, 1, false), new OpenWeaponNames(this, null)); + if (enabled.containsKey(type)) addGlow(weaponNameSlot); + + type = GadgetType.LEVEL_PREFIX; + lore = getLore(ownedCount.get(type), maxCount.get(type), "Something something", VISIBILITY_HUB, enabled.get(type)); + addButton(chatColourSlot, new ShopItem(Material.PAPER, "Level Colors", lore, 1, false), generateButton(type, enabled.get(type))); + if (enabled.containsKey(type)) addGlow(weaponNameSlot); + // Copy over banner design BannerMeta banner = (BannerMeta) CountryFlag.MINEPLEX.getBanner().getItemMeta(); BannerMeta meta = ((BannerMeta) getItem(flagSlot).getItemMeta()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WeaponNamePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WeaponNamePage.java new file mode 100644 index 000000000..005988b73 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WeaponNamePage.java @@ -0,0 +1,76 @@ +package mineplex.core.cosmetic.ui.page; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilUI; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.gadget.types.WeaponNameGadget; +import mineplex.core.gadget.types.WeaponNameGadget.WeaponType; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.itemstack.ItemStackFactory; + +public class WeaponNamePage extends GadgetPage +{ + + public WeaponNamePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Weapon Names", player); + + buildPage(); + } + + @Override + protected void buildPage() + { + WeaponType[] types = WeaponType.values(); + int[] slots = UtilUI.getIndicesFor(types.length, 2); + int index = 0; + Map> gadgets = new HashMap<>(types.length); + + for (Gadget gadget : _plugin.getGadgetManager().getGadgets(GadgetType.WEAPON_NAME)) + { + gadgets.computeIfAbsent(((WeaponNameGadget) gadget).getWeaponNameType().getWeaponType(), k -> new ArrayList<>()).add(gadget); + } + + for (WeaponType type : types) + { + int own = 0, total = 0; + List gadgetList = gadgets.get(type); + + for (Gadget gadget : gadgetList) + { + if (gadget.ownsGadget(getPlayer())) + { + own++; + } + total++; + } + + ItemBuilder builder = new ItemBuilder(type.getMaterial()); + String name = ItemStackFactory.Instance.GetName(builder.getType(), (byte) 0, false); + + builder.setTitle(C.cGreenB + name); + builder.addLore( + "", + C.cWhite + "You own " + own + "/" + total, + "", + C.cGreen + "Left-Click to view " + name + " cosmetics" + ); + + addButton(slots[index++], builder.build(), (player, clickType) -> getShop().openPageForPlayer(player, new ListGadgetPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), name, player, gadgetList))); + } + + addBackButton(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/ActivateCustomPetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/ActivateCustomPetButton.java deleted file mode 100644 index 7a090129e..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/ActivateCustomPetButton.java +++ /dev/null @@ -1,25 +0,0 @@ -package mineplex.core.cosmetic.ui.page.custompet; - -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -import mineplex.core.cosmetic.ui.page.GadgetPage; -import mineplex.core.shop.item.IButton; - -public class ActivateCustomPetButton implements IButton -{ - private GadgetPage _page; - - public ActivateCustomPetButton(GadgetPage page) - { - _page = page; - } - - @Override - public void onClick(Player player, ClickType clickType) - { - /*_page.playAcceptSound(player); - _page.getPlugin().getPetManager().addPetOwner(player, PetType.CUSTOM, player.getLocation()); - _page.getShop().openPageForPlayer(player, new Menu(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), player));*/ - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/CustomPetBasePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/CustomPetBasePage.java deleted file mode 100644 index 8b52b34a8..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/CustomPetBasePage.java +++ /dev/null @@ -1,62 +0,0 @@ -package mineplex.core.cosmetic.ui.page.custompet; - -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.cosmetic.ui.page.GadgetPage; -import mineplex.core.cosmetic.ui.page.Menu; -import mineplex.core.donation.DonationManager; -import mineplex.core.pet.custom.CustomPet; -import mineplex.core.shop.item.ShopItem; - -public class CustomPetBasePage extends GadgetPage -{ - - public CustomPetBasePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) - { - super(plugin, shop, clientManager, donationManager, name, player); - } - - @Override - protected void buildPage() - { - - // TODO - // EDIT PET - // DISABLE PET - // RENAME PET - // RESET PET - - int slot = 10; - - for (CustomPet.CustomPetType customPetType : CustomPet.CustomPetType.values()) - { - - addButton(slot, new ShopItem(customPetType.getMaterial(), customPetType.getData(), customPetType.getName(), new String[]{}, 1, false, false), (player, clickType) -> - { - CustomPet customPet = CustomPet.getCustomPet(player); - if (customPet == null) - { - customPet = customPetType.getCustomPet(getPlugin().getPetManager(), player); - } - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - slot++; - - if (slot == 17) - slot += 2; - } - - addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) -> - { - getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); - CustomPet.removeCustomPet(player); - }); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/CustomPetConfirmPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/CustomPetConfirmPage.java deleted file mode 100644 index 965a1d6ef..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/CustomPetConfirmPage.java +++ /dev/null @@ -1,59 +0,0 @@ -package mineplex.core.cosmetic.ui.page.custompet; - -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.cosmetic.ui.page.GadgetPage; -import mineplex.core.donation.DonationManager; -import mineplex.core.pet.custom.CustomPet; -import mineplex.core.shop.item.ShopItem; - -public class CustomPetConfirmPage extends GadgetPage -{ - - public CustomPetConfirmPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) - { - super(plugin, shop, clientManager, donationManager, name, player); - } - - @Override - protected void buildPage() - { - - CustomPet customPet = CustomPet.getCustomPet(getPlayer()); - if (customPet == null) - { - CustomPet.removeCustomPet(getPlayer()); - getPlayer().closeInventory(); - return; - } - - int[] confirm = {19, 20, 21, 28, 29, 30, 37, 38, 39}; - int[] cancel = {23, 24, 25, 32, 33, 34, 41, 42, 43}; - - ShopItem confirmItem = new ShopItem(Material.WOOL, (byte) 5, "Confirm", new String[]{}, 1, false, false); - ShopItem cancelItem = new ShopItem(Material.WOOL, (byte) 14, "Cancel", new String[]{}, 1, false, false); - - for (int aConfirm : confirm) - { - addButton(aConfirm, confirmItem, new ActivateCustomPetButton(this)); - } - - for (int aCancel : cancel) - { - addButton(aCancel, cancelItem, (player, clickType) -> - { - player.closeInventory(); - CustomPet.removeCustomPet(player); - }); - } - - addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) -> - getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager()))); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/age/CustomPetAgePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/age/CustomPetAgePage.java deleted file mode 100644 index 70feb8529..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/age/CustomPetAgePage.java +++ /dev/null @@ -1,61 +0,0 @@ -package mineplex.core.cosmetic.ui.page.custompet.age; - -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.cosmetic.ui.page.GadgetPage; -import mineplex.core.donation.DonationManager; -import mineplex.core.pet.custom.CustomPet; -import mineplex.core.pet.custom.CustomPetAgeable; -import mineplex.core.shop.item.ShopItem; - -public class CustomPetAgePage extends GadgetPage -{ - - public CustomPetAgePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) - { - super(plugin, shop, clientManager, donationManager, name, player); - } - - @Override - protected void buildPage() - { - - CustomPet customPet = CustomPet.getCustomPet(getPlayer()); - if (customPet == null) - { - CustomPet.removeCustomPet(getPlayer()); - getPlayer().closeInventory(); - return; - } - - if (!(customPet instanceof CustomPetAgeable)) - { - CustomPet.removeCustomPet(getPlayer()); - getPlayer().closeInventory(); - return; - } - - CustomPetAgeable customPetAgeable = (CustomPetAgeable) customPet; - - addButton(29, new ShopItem(Material.SEEDS, "Baby", 1, false), (player, clickType) -> - { - customPetAgeable.setBaby(true); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(33, new ShopItem(Material.WHEAT, "Adult", 1, false), (player, clickType) -> - { - customPetAgeable.setBaby(false); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) -> - getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager()))); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/equipment/CustomPetBootsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/equipment/CustomPetBootsPage.java deleted file mode 100644 index edfc55ece..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/equipment/CustomPetBootsPage.java +++ /dev/null @@ -1,89 +0,0 @@ -package mineplex.core.cosmetic.ui.page.custompet.equipment; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.cosmetic.ui.page.GadgetPage; -import mineplex.core.donation.DonationManager; -import mineplex.core.pet.custom.CustomPet; -import mineplex.core.pet.custom.CustomPetEquipment; -import mineplex.core.shop.item.ShopItem; - -public class CustomPetBootsPage extends GadgetPage -{ - - public CustomPetBootsPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) - { - super(plugin, shop, clientManager, donationManager, name, player); - } - - @Override - protected void buildPage() - { - - CustomPet customPet = CustomPet.getCustomPet(getPlayer()); - if (customPet == null) - { - CustomPet.removeCustomPet(getPlayer()); - getPlayer().closeInventory(); - return; - } - - if (!(customPet instanceof CustomPetEquipment)) - { - CustomPet.removeCustomPet(getPlayer()); - getPlayer().closeInventory(); - return; - } - - CustomPetEquipment customPetEquipment = (CustomPetEquipment) customPet; - - // Leather helmet - addButton(19, new ShopItem(Material.LEATHER_BOOTS, "Leather", 1, false), (player, clickType) -> - { - // TODO COLORED ARMOR - customPetEquipment.setBoots(new ItemStack(Material.LEATHER_BOOTS)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(22, new ShopItem(Material.CHAINMAIL_BOOTS, "Chain", 1, false), (player, clickType) -> - { - customPetEquipment.setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(25, new ShopItem(Material.IRON_BOOTS, "Iron", 1, false), (player, clickType) -> - { - customPetEquipment.setBoots(new ItemStack(Material.IRON_HELMET)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(38, new ShopItem(Material.GOLD_BOOTS, "Gold", 1, false), (player, clickType) -> - { - customPetEquipment.setBoots(new ItemStack(Material.GOLD_BOOTS)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(40, new ShopItem(Material.BARRIER, "None", 1, false), (player, clickType) -> - { - customPetEquipment.setBoots(new ItemStack(Material.AIR)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(42, new ShopItem(Material.DIAMOND_BOOTS, "Diamond", 1, false), (player, clickType) -> - { - customPetEquipment.setBoots(new ItemStack(Material.DIAMOND_BOOTS)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) -> - getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager()))); - } - - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/equipment/CustomPetChestplatePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/equipment/CustomPetChestplatePage.java deleted file mode 100644 index d9da369f4..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/equipment/CustomPetChestplatePage.java +++ /dev/null @@ -1,88 +0,0 @@ -package mineplex.core.cosmetic.ui.page.custompet.equipment; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.cosmetic.ui.page.GadgetPage; -import mineplex.core.donation.DonationManager; -import mineplex.core.pet.custom.CustomPet; -import mineplex.core.pet.custom.CustomPetEquipment; -import mineplex.core.shop.item.ShopItem; - -public class CustomPetChestplatePage extends GadgetPage -{ - - public CustomPetChestplatePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) - { - super(plugin, shop, clientManager, donationManager, name, player); - } - - @Override - protected void buildPage() - { - - CustomPet customPet = CustomPet.getCustomPet(getPlayer()); - if (customPet == null) - { - CustomPet.removeCustomPet(getPlayer()); - getPlayer().closeInventory(); - return; - } - - if (!(customPet instanceof CustomPetEquipment)) - { - CustomPet.removeCustomPet(getPlayer()); - getPlayer().closeInventory(); - return; - } - - CustomPetEquipment customPetEquipment = (CustomPetEquipment) customPet; - - // Leather helmet - addButton(19, new ShopItem(Material.LEATHER_CHESTPLATE, "Leather", 1, false), (player, clickType) -> - { - // TODO COLORED ARMOR - customPetEquipment.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(22, new ShopItem(Material.CHAINMAIL_CHESTPLATE, "Chain", 1, false), (player, clickType) -> - { - customPetEquipment.setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(25, new ShopItem(Material.IRON_CHESTPLATE, "Iron", 1, false), (player, clickType) -> - { - customPetEquipment.setChestplate(new ItemStack(Material.IRON_HELMET)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(38, new ShopItem(Material.GOLD_CHESTPLATE, "Gold", 1, false), (player, clickType) -> - { - customPetEquipment.setChestplate(new ItemStack(Material.GOLD_CHESTPLATE)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(40, new ShopItem(Material.BARRIER, "None", 1, false), (player, clickType) -> - { - customPetEquipment.setChestplate(new ItemStack(Material.AIR)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(42, new ShopItem(Material.DIAMOND_CHESTPLATE, "Diamond", 1, false), (player, clickType) -> - { - customPetEquipment.setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) -> - getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager()))); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/equipment/CustomPetHelmetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/equipment/CustomPetHelmetPage.java deleted file mode 100644 index dc90f4c9c..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/equipment/CustomPetHelmetPage.java +++ /dev/null @@ -1,88 +0,0 @@ -package mineplex.core.cosmetic.ui.page.custompet.equipment; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.cosmetic.ui.page.GadgetPage; -import mineplex.core.donation.DonationManager; -import mineplex.core.pet.custom.CustomPet; -import mineplex.core.pet.custom.CustomPetEquipment; -import mineplex.core.shop.item.ShopItem; - -public class CustomPetHelmetPage extends GadgetPage -{ - - public CustomPetHelmetPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) - { - super(plugin, shop, clientManager, donationManager, name, player); - } - - @Override - protected void buildPage() - { - - CustomPet customPet = CustomPet.getCustomPet(getPlayer()); - if (customPet == null) - { - CustomPet.removeCustomPet(getPlayer()); - getPlayer().closeInventory(); - return; - } - - if (!(customPet instanceof CustomPetEquipment)) - { - CustomPet.removeCustomPet(getPlayer()); - getPlayer().closeInventory(); - return; - } - - CustomPetEquipment customPetEquipment = (CustomPetEquipment) customPet; - - // Leather helmet - addButton(19, new ShopItem(Material.LEATHER_HELMET, "Leather", 1, false), (player, clickType) -> - { - // TODO COLORED ARMOR - customPetEquipment.setHelmet(new ItemStack(Material.LEATHER_HELMET)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(22, new ShopItem(Material.CHAINMAIL_HELMET, "Chain", 1, false), (player, clickType) -> - { - customPetEquipment.setHelmet(new ItemStack(Material.CHAINMAIL_HELMET)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(25, new ShopItem(Material.IRON_HELMET, "Iron", 1, false), (player, clickType) -> - { - customPetEquipment.setHelmet(new ItemStack(Material.IRON_HELMET)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(38, new ShopItem(Material.GOLD_HELMET, "Gold", 1, false), (player, clickType) -> - { - customPetEquipment.setHelmet(new ItemStack(Material.GOLD_HELMET)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(40, new ShopItem(Material.BARRIER, "None", 1, false), (player, clickType) -> - { - customPetEquipment.setHelmet(new ItemStack(Material.AIR)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(42, new ShopItem(Material.DIAMOND_HELMET, "Diamond", 1, false), (player, clickType) -> - { - customPetEquipment.setHelmet(new ItemStack(Material.DIAMOND_HELMET)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) -> - getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager()))); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/equipment/CustomPetLeggingsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/equipment/CustomPetLeggingsPage.java deleted file mode 100644 index eaa0fdf9a..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/equipment/CustomPetLeggingsPage.java +++ /dev/null @@ -1,88 +0,0 @@ -package mineplex.core.cosmetic.ui.page.custompet.equipment; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.cosmetic.ui.page.GadgetPage; -import mineplex.core.donation.DonationManager; -import mineplex.core.pet.custom.CustomPet; -import mineplex.core.pet.custom.CustomPetEquipment; -import mineplex.core.shop.item.ShopItem; - -public class CustomPetLeggingsPage extends GadgetPage -{ - - public CustomPetLeggingsPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) - { - super(plugin, shop, clientManager, donationManager, name, player); - } - - @Override - protected void buildPage() - { - - CustomPet customPet = CustomPet.getCustomPet(getPlayer()); - if (customPet == null) - { - CustomPet.removeCustomPet(getPlayer()); - getPlayer().closeInventory(); - return; - } - - if (!(customPet instanceof CustomPetEquipment)) - { - CustomPet.removeCustomPet(getPlayer()); - getPlayer().closeInventory(); - return; - } - - CustomPetEquipment customPetEquipment = (CustomPetEquipment) customPet; - - // Leather helmet - addButton(19, new ShopItem(Material.LEATHER_LEGGINGS, "Leather", 1, false), (player, clickType) -> - { - // TODO COLORED ARMOR - customPetEquipment.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(22, new ShopItem(Material.CHAINMAIL_LEGGINGS, "Chain", 1, false), (player, clickType) -> - { - customPetEquipment.setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(25, new ShopItem(Material.IRON_LEGGINGS, "Iron", 1, false), (player, clickType) -> - { - customPetEquipment.setLeggings(new ItemStack(Material.IRON_HELMET)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(38, new ShopItem(Material.GOLD_LEGGINGS, "Gold", 1, false), (player, clickType) -> - { - customPetEquipment.setLeggings(new ItemStack(Material.GOLD_LEGGINGS)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(40, new ShopItem(Material.BARRIER, "None", 1, false), (player, clickType) -> - { - customPetEquipment.setLeggings(new ItemStack(Material.AIR)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(42, new ShopItem(Material.DIAMOND_LEGGINGS, "Diamond", 1, false), (player, clickType) -> - { - customPetEquipment.setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) -> - getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager()))); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CloseCustomPetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CloseCustomPetButton.java deleted file mode 100644 index d2bef0f22..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CloseCustomPetButton.java +++ /dev/null @@ -1,16 +0,0 @@ -package mineplex.core.cosmetic.ui.page.custompet.name; - -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -import mineplex.core.pet.custom.CustomPet; -import mineplex.core.shop.item.IButton; - -public class CloseCustomPetButton implements IButton -{ - public void onClick(Player player, ClickType clickType) - { - player.closeInventory(); - CustomPet.removeCustomPet(player); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetNamePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetNamePage.java deleted file mode 100644 index 60d71a10d..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetNamePage.java +++ /dev/null @@ -1,63 +0,0 @@ -package mineplex.core.cosmetic.ui.page.custompet.name; - -import net.minecraft.server.v1_8_R3.Blocks; -import net.minecraft.server.v1_8_R3.ChatMessage; -import net.minecraft.server.v1_8_R3.EntityPlayer; -import net.minecraft.server.v1_8_R3.Items; -import net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow; -import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; - -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.cosmetic.ui.page.GadgetPage; -import mineplex.core.donation.DonationManager; -import mineplex.core.pet.custom.CustomPet; -import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.AnvilContainer; - -public class CustomPetNamePage extends GadgetPage -{ - - public CustomPetNamePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) - { - super(plugin, shop, clientManager, donationManager, name, player); - } - - @Override - protected void buildPage() - { - - CustomPet customPet = CustomPet.getCustomPet(getPlayer()); - if (customPet == null) - { - CustomPet.removeCustomPet(getPlayer()); - getPlayer().closeInventory(); - return; - } - - addButton(31, new ShopItem(Material.NAME_TAG, "Name", 1, false), (player, clickType) -> - { - CustomPetTagPage customPetTagPage = new CustomPetTagPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Pet Name", getPlayer()); - EntityPlayer entityPlayer = ((CraftPlayer) getPlayer()).getHandle(); - int containerCounter = entityPlayer.nextContainerCounter(); - UtilPlayer.sendPacket(player, new PacketPlayOutOpenWindow(containerCounter, "minecraft:anvil", new ChatMessage(Blocks.ANVIL.a() + ".name", new Object[0]))); - entityPlayer.activeContainer = new AnvilContainer(entityPlayer.inventory, customPetTagPage.getInventory()); - entityPlayer.activeContainer.windowId = containerCounter; - entityPlayer.activeContainer.addSlotListener(entityPlayer); - UtilPlayer.sendPacket(player, new PacketPlayOutSetSlot(containerCounter, 0, new net.minecraft.server.v1_8_R3.ItemStack(Items.NAME_TAG))); - - getShop().setCurrentPageForPlayer(getPlayer(), customPetTagPage); - }); - - addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) -> - getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager()))); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java deleted file mode 100644 index 2350f8eba..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java +++ /dev/null @@ -1,101 +0,0 @@ -package mineplex.core.cosmetic.ui.page.custompet.name; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilItem; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.punish.PunishClient; -import net.minecraft.server.v1_8_R3.ItemStack; -import net.minecraft.server.v1_8_R3.Items; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.donation.DonationManager; -import mineplex.core.pet.custom.CustomPet; -import mineplex.core.shop.page.ShopPageBase; - -public class CustomPetTagPage extends ShopPageBase -{ - private String _tagName = "Pet Name"; - - public CustomPetTagPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) - { - super(plugin, shop, clientManager, donationManager, name, player, 3); - - buildPage(); - } - - @Override - protected void buildPage() - { - inventory.setItem(0, new ItemStack(Items.NAME_TAG)); - - getButtonMap().put(0, new CloseCustomPetButton()); - getButtonMap().put(1, new CloseCustomPetButton()); - getButtonMap().put(2, new SelectCustomPetTagButton(this)); - - } - - @Override - public void playerClosed() - { - super.playerClosed(); - } - - public void selectTag() - { - CustomPet customPet = CustomPet.getCustomPet(_player); - if (customPet == null) - { - _player.closeInventory(); - CustomPet.removeCustomPet(_player); - return; - } - - _tagName = ChatColor.stripColor(_tagName); - _tagName = _tagName.replaceAll("[^A-Za-z0-9]", ""); - System.out.println("Pet name: " + _tagName + "."); - if (_tagName.length() == 0) - { - UtilPlayer.message(getPlayer(), F.main(getPlugin().getName(), ChatColor.RED + "Supplied pet name contains invalid characters.")); - playDenySound(getPlayer()); - - getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - return; - } - - if (_tagName.length() > 16) - { - UtilPlayer.message(getPlayer(), F.main(getPlugin().getName(), ChatColor.RED + "Pet name cannot be longer than 16 characters.")); - playDenySound(getPlayer()); - - getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - return; - } - - if (_tagName.toLowerCase().contains("ultra")) - { - UtilPlayer.message(getPlayer(), F.main(getPlugin().getName(), ChatColor.RED + _tagName + " is a restricted name.")); - playDenySound(getPlayer()); - - getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - return; - } - - customPet.setName(_tagName); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - - } - - public void setTagName(String tagName) - { - _tagName = tagName; - } -} - diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/SelectCustomPetTagButton.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/SelectCustomPetTagButton.java deleted file mode 100644 index c934f7648..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/SelectCustomPetTagButton.java +++ /dev/null @@ -1,21 +0,0 @@ -package mineplex.core.cosmetic.ui.page.custompet.name; - -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -import mineplex.core.shop.item.IButton; - -public class SelectCustomPetTagButton implements IButton -{ - private CustomPetTagPage _page; - - public SelectCustomPetTagButton(CustomPetTagPage page) - { - _page = page; - } - - public void onClick(Player player, ClickType clickType) - { - _page.selectTag(); - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/zombie/CustomPetZombieTypePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/zombie/CustomPetZombieTypePage.java deleted file mode 100644 index 70f017744..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/zombie/CustomPetZombieTypePage.java +++ /dev/null @@ -1,61 +0,0 @@ -package mineplex.core.cosmetic.ui.page.custompet.zombie; - -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.cosmetic.ui.page.GadgetPage; -import mineplex.core.donation.DonationManager; -import mineplex.core.pet.custom.CustomPet; -import mineplex.core.pet.custom.CustomPetZombie; -import mineplex.core.shop.item.ShopItem; - -public class CustomPetZombieTypePage extends GadgetPage -{ - - public CustomPetZombieTypePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) - { - super(plugin, shop, clientManager, donationManager, name, player); - } - - @Override - protected void buildPage() - { - - CustomPet customPet = CustomPet.getCustomPet(getPlayer()); - if (customPet == null) - { - CustomPet.removeCustomPet(getPlayer()); - getPlayer().closeInventory(); - return; - } - - if (!(customPet instanceof CustomPetZombie)) - { - CustomPet.removeCustomPet(getPlayer()); - getPlayer().closeInventory(); - return; - } - - CustomPetZombie customPetZombie = (CustomPetZombie) customPet; - - addButton(29, new ShopItem(Material.BARRIER, "Zombie", 1, false), (player, clickType) -> - { - customPetZombie.setVillager(false); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(33, new ShopItem(Material.WHEAT, "Zombie Villager", 1, false), (player, clickType) -> - { - customPetZombie.setVillager(true); - getShop().openPageForPlayer(getPlayer(), customPet.getNextStep(getPlugin(), getShop(), getClientManager(), getDonationManager())); - }); - - addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) -> - getShop().openPageForPlayer(getPlayer(), customPet.getPreviousStep(getPlugin(), getShop(), getClientManager(), getDonationManager()))); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameCosmeticCategoryPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameCosmeticCategoryPage.java index d434d300a..a7da2c735 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameCosmeticCategoryPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameCosmeticCategoryPage.java @@ -70,8 +70,8 @@ public class GameCosmeticCategoryPage extends GadgetPage getShop().openPageForPlayer(player, page); } }); - - addButton(4, new ShopItem(Material.BED, C.cGreen + "Go Back", new String[0], 1, false), (player, clickType) -> getShop().openPageForPlayer(getPlayer(), new GameCosmeticsPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), player))); } + + addButton(4, new ShopItem(Material.BED, C.cGreen + "Go Back", new String[0], 1, false), (player, clickType) -> getShop().openPageForPlayer(getPlayer(), new GameCosmeticsPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), player))); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSilverFish.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSilverFish.java new file mode 100644 index 000000000..2a7a8c5ac --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseSilverFish.java @@ -0,0 +1,13 @@ +package mineplex.core.disguise.disguises; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; + +public class DisguiseSilverFish extends DisguiseMonster +{ + + public DisguiseSilverFish(Entity entity) + { + super(EntityType.SILVERFISH, entity); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 657f36b71..f7056e1e4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -2,25 +2,31 @@ package mineplex.core.gadget; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.AnvilInventory; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import mineplex.core.MiniPlugin; @@ -29,11 +35,12 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.account.permissions.Permission; import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.achievement.AchievementManager; +import mineplex.core.arcadeevents.CoreGameStartEvent; +import mineplex.core.arcadeevents.CoreGameStopEvent; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; @@ -44,14 +51,18 @@ import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.commands.AmmoCommand; import mineplex.core.gadget.commands.LockCosmeticsCommand; +import mineplex.core.gadget.commands.TestTauntCommand; import mineplex.core.gadget.commands.UnlockCosmeticCommand; import mineplex.core.gadget.commands.UnlockCosmeticsCommand; +import mineplex.core.gadget.event.GadgetBlockEvent; import mineplex.core.gadget.event.GadgetChangeEvent; import mineplex.core.gadget.event.GadgetChangeEvent.GadgetState; import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.event.GadgetEnableEvent; +import mineplex.core.gadget.event.GadgetSelectLocationEvent; import mineplex.core.gadget.event.PlayerToggleSwimEvent; import mineplex.core.gadget.event.TauntCommandEvent; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBalance; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; @@ -61,6 +72,7 @@ import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHalloween; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailLegend; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailPresent; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRainbow; @@ -69,8 +81,9 @@ import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailSpring; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailTitan; -import mineplex.core.gadget.gadgets.balloons.BalloonItem; import mineplex.core.gadget.gadgets.balloons.BalloonType; +import mineplex.core.gadget.gadgets.chat.LevelPrefixType; +import mineplex.core.gadget.gadgets.death.DeathBalance; import mineplex.core.gadget.gadgets.death.DeathBlood; import mineplex.core.gadget.gadgets.death.DeathCandyCane; import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; @@ -79,6 +92,7 @@ import mineplex.core.gadget.gadgets.death.DeathEnchant; import mineplex.core.gadget.gadgets.death.DeathFreedom; import mineplex.core.gadget.gadgets.death.DeathFrostLord; import mineplex.core.gadget.gadgets.death.DeathHalloween; +import mineplex.core.gadget.gadgets.death.DeathLegend; import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; import mineplex.core.gadget.gadgets.death.DeathMusic; import mineplex.core.gadget.gadgets.death.DeathPinataBurst; @@ -88,6 +102,7 @@ import mineplex.core.gadget.gadgets.death.DeathShadow; import mineplex.core.gadget.gadgets.death.DeathSpring; import mineplex.core.gadget.gadgets.death.DeathStorm; import mineplex.core.gadget.gadgets.death.DeathTitan; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBalance; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; @@ -97,6 +112,7 @@ import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHalloween; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpLegend; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpPresent; @@ -109,8 +125,6 @@ import mineplex.core.gadget.gadgets.flag.FlagType; import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticCategory; import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticManager; import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticType; -import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.GemHuntersMountGadget; -import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.GemHuntersMountType; import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin; import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin; import mineplex.core.gadget.gadgets.gamemodifiers.moba.shopmorph.ShopMorphGadget; @@ -124,6 +138,7 @@ import mineplex.core.gadget.gadgets.item.ItemBow; import mineplex.core.gadget.gadgets.item.ItemCandy; import mineplex.core.gadget.gadgets.item.ItemCoal; import mineplex.core.gadget.gadgets.item.ItemCoinBomb; +import mineplex.core.gadget.gadgets.item.ItemConnect4; import mineplex.core.gadget.gadgets.item.ItemDuelingSword; import mineplex.core.gadget.gadgets.item.ItemEtherealPearl; import mineplex.core.gadget.gadgets.item.ItemFirework; @@ -139,6 +154,7 @@ import mineplex.core.gadget.gadgets.item.ItemPaintbrush; import mineplex.core.gadget.gadgets.item.ItemPartyPopper; import mineplex.core.gadget.gadgets.item.ItemSnowball; import mineplex.core.gadget.gadgets.item.ItemTNT; +import mineplex.core.gadget.gadgets.item.ItemTrampoline; import mineplex.core.gadget.gadgets.kitselector.HalloweenKitSelector; import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector; import mineplex.core.gadget.gadgets.kitselector.RainCloudKitSelector; @@ -166,9 +182,11 @@ import mineplex.core.gadget.gadgets.morph.MorphGrimReaper; import mineplex.core.gadget.gadgets.morph.MorphLoveDoctor; import mineplex.core.gadget.gadgets.morph.MorphMelonHead; import mineplex.core.gadget.gadgets.morph.MorphMetalMan; +import mineplex.core.gadget.gadgets.morph.MorphOcelot; import mineplex.core.gadget.gadgets.morph.MorphPig; import mineplex.core.gadget.gadgets.morph.MorphPumpkinKing; import mineplex.core.gadget.gadgets.morph.MorphSanta; +import mineplex.core.gadget.gadgets.morph.MorphSkeleton; import mineplex.core.gadget.gadgets.morph.MorphSlime; import mineplex.core.gadget.gadgets.morph.MorphSnowman; import mineplex.core.gadget.gadgets.morph.MorphSquid; @@ -178,14 +196,15 @@ import mineplex.core.gadget.gadgets.morph.MorphUncleSam; import mineplex.core.gadget.gadgets.morph.MorphVillager; import mineplex.core.gadget.gadgets.morph.MorphWitch; import mineplex.core.gadget.gadgets.morph.MorphWither; +import mineplex.core.gadget.gadgets.morph.MorphWolf; import mineplex.core.gadget.gadgets.morph.managers.SoulManager; import mineplex.core.gadget.gadgets.morph.moba.MorphAnath; import mineplex.core.gadget.gadgets.morph.moba.MorphBardolf; import mineplex.core.gadget.gadgets.morph.moba.MorphBiff; -import mineplex.core.gadget.gadgets.morph.moba.MorphIvy; import mineplex.core.gadget.gadgets.morph.moba.MorphDana; import mineplex.core.gadget.gadgets.morph.moba.MorphDevon; import mineplex.core.gadget.gadgets.morph.moba.MorphHattori; +import mineplex.core.gadget.gadgets.morph.moba.MorphIvy; import mineplex.core.gadget.gadgets.morph.moba.MorphLarissa; import mineplex.core.gadget.gadgets.morph.moba.MorphRowena; import mineplex.core.gadget.gadgets.mount.types.MountBabyReindeer; @@ -228,36 +247,47 @@ import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksBoots; import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksChestplate; import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksHat; import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksLeggings; -import mineplex.core.gadget.gadgets.outfit.windupsuit.OutfitWindUpSuitBoosterManager; import mineplex.core.gadget.gadgets.particle.ParticleBlood; import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; -import mineplex.core.gadget.gadgets.particle.christmas.ParticleBlizzard; -import mineplex.core.gadget.gadgets.particle.christmas.ParticleChristmasTree; import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes; +import mineplex.core.gadget.gadgets.particle.ParticleDeepSeaSwirl; +import mineplex.core.gadget.gadgets.particle.ParticleInfused; import mineplex.core.gadget.gadgets.particle.ParticleEmerald; import mineplex.core.gadget.gadgets.particle.ParticleEnchant; +import mineplex.core.gadget.gadgets.particle.ParticleWitchsCure; import mineplex.core.gadget.gadgets.particle.ParticleFairy; -import mineplex.core.gadget.gadgets.particle.christmas.ParticleFidgetSpinner; import mineplex.core.gadget.gadgets.particle.ParticleFireRings; import mineplex.core.gadget.gadgets.particle.ParticleFoot; import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleHalloween; import mineplex.core.gadget.gadgets.particle.ParticleHeart; +import mineplex.core.gadget.gadgets.particle.ParticleMacawWings; +import mineplex.core.gadget.gadgets.particle.ParticleChickenWings; +import mineplex.core.gadget.gadgets.particle.ParticleEnderDragonWings; +import mineplex.core.gadget.gadgets.particle.ParticleFoxTail; +import mineplex.core.gadget.gadgets.particle.ParticleJetPack; +import mineplex.core.gadget.gadgets.particle.ParticleCape; +import mineplex.core.gadget.gadgets.particle.ParticleLegendaryHero; +import mineplex.core.gadget.gadgets.particle.ParticleWolfTail; import mineplex.core.gadget.gadgets.particle.ParticleLegend; import mineplex.core.gadget.gadgets.particle.ParticleMusic; import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; -import mineplex.core.gadget.gadgets.particle.ParticleHalloween; import mineplex.core.gadget.gadgets.particle.ParticleRain; import mineplex.core.gadget.gadgets.particle.ParticleRainbow; +import mineplex.core.gadget.gadgets.particle.ParticleRainbowTrail; import mineplex.core.gadget.gadgets.particle.ParticleTitan; import mineplex.core.gadget.gadgets.particle.ParticleWingsAngel; import mineplex.core.gadget.gadgets.particle.ParticleWingsBee; -import mineplex.core.gadget.gadgets.particle.christmas.ParticlePumpkinShield; -import mineplex.core.gadget.gadgets.particle.christmas.ParticleWingsChristmas; import mineplex.core.gadget.gadgets.particle.ParticleWingsDemons; import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal; import mineplex.core.gadget.gadgets.particle.ParticleWingsLove; import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie; import mineplex.core.gadget.gadgets.particle.ParticleYinYang; +import mineplex.core.gadget.gadgets.particle.christmas.ParticleBlizzard; +import mineplex.core.gadget.gadgets.particle.christmas.ParticleChristmasTree; +import mineplex.core.gadget.gadgets.particle.christmas.ParticleFidgetSpinner; +import mineplex.core.gadget.gadgets.particle.christmas.ParticlePumpkinShield; +import mineplex.core.gadget.gadgets.particle.christmas.ParticleWingsChristmas; import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; @@ -267,17 +297,22 @@ import mineplex.core.gadget.gadgets.particle.king.CastleManager; import mineplex.core.gadget.gadgets.particle.king.ParticleKing; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; +import mineplex.core.gadget.gadgets.taunts.EasyModeTaunt; +import mineplex.core.gadget.gadgets.taunts.EmojiTaunt; import mineplex.core.gadget.gadgets.taunts.EternalTaunt; import mineplex.core.gadget.gadgets.taunts.FrostBreathTaunt; import mineplex.core.gadget.gadgets.taunts.InfernalTaunt; import mineplex.core.gadget.gadgets.taunts.RainbowTaunt; +import mineplex.core.gadget.gadgets.weaponname.WeaponNameType; import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken; +import mineplex.core.gadget.gadgets.wineffect.WinEffectEarthquake; import mineplex.core.gadget.gadgets.wineffect.WinEffectFlames; import mineplex.core.gadget.gadgets.wineffect.WinEffectHalloween; import mineplex.core.gadget.gadgets.wineffect.WinEffectLavaTrap; import mineplex.core.gadget.gadgets.wineffect.WinEffectLightningStrike; import mineplex.core.gadget.gadgets.wineffect.WinEffectLoveIsABattlefield; import mineplex.core.gadget.gadgets.wineffect.WinEffectMrPunchMan; +import mineplex.core.gadget.gadgets.wineffect.WinEffectPartyAnimal; import mineplex.core.gadget.gadgets.wineffect.WinEffectPodium; import mineplex.core.gadget.gadgets.wineffect.WinEffectRiseOfTheElderGuardian; import mineplex.core.gadget.gadgets.wineffect.WinEffectSnowTrails; @@ -289,6 +324,7 @@ import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffect import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankTitan; import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankUltra; import mineplex.core.gadget.persistence.UserGadgetPersistence; +import mineplex.core.gadget.set.SetBalance; import mineplex.core.gadget.set.SetCanadian; import mineplex.core.gadget.set.SetCandyCane; import mineplex.core.gadget.set.SetCupidsLove; @@ -297,6 +333,7 @@ import mineplex.core.gadget.set.SetFreedom; import mineplex.core.gadget.set.SetFrostLord; import mineplex.core.gadget.set.SetHalloween; import mineplex.core.gadget.set.SetHowlingWinds; +import mineplex.core.gadget.set.SetLegend; import mineplex.core.gadget.set.SetMusic; import mineplex.core.gadget.set.SetParty; import mineplex.core.gadget.set.SetRainbow; @@ -310,24 +347,21 @@ import mineplex.core.gadget.set.suits.SetRaveSuit; import mineplex.core.gadget.set.suits.SetReindeerSuit; import mineplex.core.gadget.set.suits.SetSpaceSuit; import mineplex.core.gadget.set.suits.SetStPatricksSuit; -import mineplex.core.gadget.types.ArrowEffectGadget; import mineplex.core.gadget.types.BalloonGadget; -import mineplex.core.gadget.types.DeathEffectGadget; import mineplex.core.gadget.types.DoubleJumpEffectGadget; import mineplex.core.gadget.types.FlagGadget; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetSet; import mineplex.core.gadget.types.GadgetType; -import mineplex.core.gadget.types.GameModifierGadget; import mineplex.core.gadget.types.HatGadget; import mineplex.core.gadget.types.ItemGadget; -import mineplex.core.gadget.types.KitSelectorGadget; +import mineplex.core.gadget.types.LevelPrefixGadget; import mineplex.core.gadget.types.MusicGadget; import mineplex.core.gadget.types.OutfitGadget; import mineplex.core.gadget.types.OutfitGadget.ArmorSlot; -import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.gadget.types.TauntGadget; -import mineplex.core.gadget.types.WinEffectGadget; +import mineplex.core.gadget.types.WeaponNameGadget; +import mineplex.core.gadget.util.CostConstants; import mineplex.core.game.GameDisplay; import mineplex.core.hologram.HologramManager; import mineplex.core.incognito.IncognitoManager; @@ -336,7 +370,6 @@ import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.packethandler.PacketHandler; import mineplex.core.pet.PetManager; -import mineplex.core.pet.custom.CustomPet; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; @@ -364,6 +397,7 @@ public class GadgetManager extends MiniPlugin LOCK_COSMETICS_COMMAND, UNLOCK_COSMETIC_COMMAND, UNLOCK_COSMETICS_COMMAND, + TEST_TAUNT_COMMAND } private final CoreClientManager _clientManager; @@ -377,7 +411,6 @@ public class GadgetManager extends MiniPlugin private final AchievementManager _achievementManager; private final PacketHandler _packetManager; private final HologramManager _hologramManager; - private final OutfitWindUpSuitBoosterManager _boosterManager; private final IncognitoManager _incognitoManager; private final GameCosmeticManager _gameCosmeticManager; private SoulManager _soulManager; @@ -394,11 +427,10 @@ public class GadgetManager extends MiniPlugin private UserGadgetPersistence _userGadgetPersistence; - private boolean _hideParticles = false; + private boolean _hideParticles, _showWeaponNames = true; private int _activeItemSlot = 3; - private boolean _gadgetsEnabled = true; + private boolean _gadgetsEnabled = true, _gameIsLive = false; - private final Set _gadgetCollideWhitelist = new HashSet<>(); private final Set _swimmingPlayers = new HashSet<>(); private GadgetManager() @@ -417,7 +449,6 @@ public class GadgetManager extends MiniPlugin _packetManager = require(PacketHandler.class); _hologramManager = require(HologramManager.class); _userGadgetPersistence = new UserGadgetPersistence(this); - _boosterManager = new OutfitWindUpSuitBoosterManager(this); _incognitoManager = require(IncognitoManager.class); _gameCosmeticManager = require(GameCosmeticManager.class); _soulManager = new SoulManager(); @@ -450,6 +481,12 @@ public class GadgetManager extends MiniPlugin PermissionGroup.QA.setPermission(Perm.UNLOCK_COSMETICS_COMMAND, true, true); PermissionGroup.ADMIN.setPermission(Perm.LOCK_COSMETICS_COMMAND, true, true); PermissionGroup.ADMIN.setPermission(Perm.UNLOCK_COSMETICS_COMMAND, true, true); + PermissionGroup.ADMIN.setPermission(Perm.TEST_TAUNT_COMMAND, true, true); + + if (UtilServer.isTestServer()) + { + PermissionGroup.QA.setPermission(Perm.TEST_TAUNT_COMMAND, true, true); + } } @Override @@ -459,25 +496,22 @@ public class GadgetManager extends MiniPlugin addCommand(new UnlockCosmeticsCommand(this)); addCommand(new LockCosmeticsCommand(this)); addCommand(new AmmoCommand(this)); + addCommand(new TestTauntCommand(this)); } private void createSets() { - //Particles - addSet(new SetFrostLord(this)); - addSet(new SetCandyCane(this)); - addSet(new SetTitan(this)); - //Costumes addSet(new SetRaveSuit(this)); addSet(new SetSpaceSuit(this)); addSet(new SetFreezeSuit(this)); addSet(new SetStPatricksSuit(this)); addSet(new SetReindeerSuit(this)); - // Hidden in this update - //addSet(new SetWindUpSuit(this)); // Sets + addSet(new SetFrostLord(this)); + addSet(new SetCandyCane(this)); + addSet(new SetTitan(this)); addSet(new SetParty(this)); addSet(new SetCupidsLove(this)); addSet(new SetEmerald(this)); @@ -491,6 +525,8 @@ public class GadgetManager extends MiniPlugin addSet(new SetCanadian(this)); addSet(new SetHalloween(this)); addSet(new SetRainbow(this)); + addSet(new SetLegend(this)); + addSet(new SetBalance(this)); } private void createGadgets() @@ -521,6 +557,8 @@ public class GadgetManager extends MiniPlugin addGadget(new ItemOAndX(this)); addGadget(new ItemMobBomb(this)); addGadget(new ItemBallCatch(this)); + addGadget(new ItemTrampoline(this)); + addGadget(new ItemConnect4(this)); // Costume addGadget(new OutfitRaveSuitHelmet(this)); @@ -533,12 +571,6 @@ public class GadgetManager extends MiniPlugin addGadget(new OutfitSpaceSuitLeggings(this)); addGadget(new OutfitSpaceSuitBoots(this)); - // Hidden in this update - /*addGadget(new OutfitWindUpSuitHelmet(this)); - addGadget(new OutfitWindUpSuitChestplate(this)); - addGadget(new OutfitWindUpSuitLeggings(this)); - addGadget(new OutfitWindUpSuitBoots(this));*/ - addGadget(new OutfitFreezeSuitHelmet(this)); addGadget(new OutfitFreezeSuitChestplate(this)); addGadget(new OutfitFreezeSuitLeggings(this)); @@ -582,8 +614,6 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphMetalMan(this)); addGadget(new MorphTurkey(this)); addGadget(new MorphChristmasKing(this)); - // Not in this update - //addGadget(new MorphStray(this)); addGadget(new MorphSanta(this)); addGadget(new MorphDinnerbone(this)); addGadget(new MorphLoveDoctor(this)); @@ -603,6 +633,9 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphIvy(this)); addGadget(new MorphGhast(this)); addGadget(new MorphFrostGolem(this)); + addGadget(new MorphSkeleton(this)); + addGadget(new MorphOcelot(this)); + addGadget(new MorphWolf(this)); // Mounts addGadget(new MountUndead(this)); @@ -667,6 +700,18 @@ public class GadgetManager extends MiniPlugin addGadget(new ParticleFidgetSpinner(this)); addGadget(new ParticlePumpkinShield(this)); addGadget(new ParticleRainbow(this, _achievementManager)); + addGadget(new ParticleMacawWings(this)); + addGadget(new ParticleChickenWings(this)); + addGadget(new ParticleEnderDragonWings(this)); + addGadget(new ParticleFoxTail(this)); + addGadget(new ParticleJetPack(this)); + addGadget(new ParticleCape(this)); + addGadget(new ParticleLegendaryHero(this)); + addGadget(new ParticleWolfTail(this)); + addGadget(new ParticleWitchsCure(this)); + addGadget(new ParticleRainbowTrail(this)); + addGadget(new ParticleDeepSeaSwirl(this)); + addGadget(new ParticleInfused(this)); // Arrow Trails addGadget(new ArrowTrailFrostLord(this)); @@ -686,6 +731,8 @@ public class GadgetManager extends MiniPlugin addGadget(new ArrowTrailRedWhite(this)); addGadget(new ArrowTrailPresent(this)); addGadget(new ArrowTrailRainbow(this, _achievementManager)); + addGadget(new ArrowTrailLegend(this)); + addGadget(new ArrowTrailBalance(this)); // Death Effect addGadget(new DeathFrostLord(this)); @@ -705,6 +752,8 @@ public class GadgetManager extends MiniPlugin addGadget(new DeathMapleLeaf(this)); addGadget(new DeathHalloween(this)); addGadget(new DeathRainbow(this, _achievementManager)); + addGadget(new DeathLegend(this)); + addGadget(new DeathBalance(this)); // Double Jump addGadget(new DoubleJumpFrostLord(this)); @@ -724,6 +773,8 @@ public class GadgetManager extends MiniPlugin addGadget(new DoubleJumpMaple(this)); addGadget(new DoubleJumpPresent(this)); addGadget(new DoubleJumpRainbow(this, _achievementManager)); + addGadget(new DoubleJumpLegend(this)); + addGadget(new DoubleJumpBalance(this)); // Hat for (HatType hatType : HatType.values()) @@ -734,10 +785,8 @@ public class GadgetManager extends MiniPlugin //Win Effects addGadget(new WinEffectPodium(this)); addGadget(new WinEffectMrPunchMan(this)); - //addGadget(new WinEffectFireworks(this)); addGadget(new WinEffectFlames(this)); addGadget(new WinEffectSnowTrails(this)); - //addGadget(new WinEffectDragonRider(this)); addGadget(new WinEffectBabyChicken(this)); addGadget(new WinEffectLightningStrike(this)); addGadget(new WinEffectRiseOfTheElderGuardian(this)); @@ -746,6 +795,8 @@ public class GadgetManager extends MiniPlugin addGadget(new WinEffectWinterWarfare(this)); addGadget(new WinEffectLoveIsABattlefield(this)); addGadget(new WinEffectTornado(this)); + addGadget(new WinEffectEarthquake(this)); + addGadget(new WinEffectPartyAnimal(this)); // Rank based win effects addGadget(new WinEffectRankUltra(this)); @@ -770,7 +821,7 @@ public class GadgetManager extends MiniPlugin // Balloons for (BalloonType balloonType : BalloonType.values()) { - addGadget(new BalloonItem(this, balloonType)); + addGadget(new BalloonGadget(this, balloonType)); } // TAUNTS!!! @@ -779,6 +830,8 @@ public class GadgetManager extends MiniPlugin addGadget(new RainbowTaunt(this)); addGadget(new InfernalTaunt(this)); addGadget(new FrostBreathTaunt(this)); + addGadget(new EmojiTaunt(this)); + addGadget(new EasyModeTaunt(this)); // Flags addGadget(new FlagGadget(this, FlagType.CANADA)); @@ -789,6 +842,7 @@ public class GadgetManager extends MiniPlugin addGadget(new FlagGadget(this, FlagType.PRESENT)); addGadget(new FlagGadget(this, FlagType.WREATH)); addGadget(new FlagGadget(this, FlagType.SNOW_FLAKE)); + addGadget(new FlagGadget(this, FlagType.HEART)); // Kit Selectors addGadget(new WaterWingsKitSelector(this)); @@ -805,6 +859,16 @@ public class GadgetManager extends MiniPlugin _singleParticleSelectors.put(singleParticleSelectors, gadget); } + for (WeaponNameType weaponNameType : WeaponNameType.values()) + { + addGadget(new WeaponNameGadget(this, weaponNameType)); + } + + for (LevelPrefixType prefixType : LevelPrefixType.values()) + { + addGadget(new LevelPrefixGadget(this, prefixType)); + } + new GameCosmeticType(this, GameDisplay.MineStrike) { @Override @@ -817,7 +881,7 @@ public class GadgetManager extends MiniPlugin { for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(1)) { - addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, -2)); + addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, CostConstants.FOUND_IN_MINESTRIKE_CHESTS)); } } }; @@ -828,7 +892,7 @@ public class GadgetManager extends MiniPlugin { for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(2)) { - addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, -2)); + addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, CostConstants.FOUND_IN_MINESTRIKE_CHESTS)); } } }; @@ -839,7 +903,7 @@ public class GadgetManager extends MiniPlugin { for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(3)) { - addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, -2)); + addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, CostConstants.FOUND_IN_MINESTRIKE_CHESTS)); } } }; @@ -850,7 +914,7 @@ public class GadgetManager extends MiniPlugin { for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(4)) { - addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, -2)); + addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, CostConstants.FOUND_IN_MINESTRIKE_CHESTS)); } } }; @@ -861,7 +925,7 @@ public class GadgetManager extends MiniPlugin { for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(5)) { - addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, -2)); + addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, CostConstants.FOUND_IN_MINESTRIKE_CHESTS)); } } }; @@ -872,7 +936,7 @@ public class GadgetManager extends MiniPlugin { for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(6)) { - addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, -2)); + addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, CostConstants.FOUND_IN_MINESTRIKE_CHESTS)); } } }; @@ -956,16 +1020,6 @@ public class GadgetManager extends MiniPlugin return null; } - public Set getSets(Gadget gadget) - { - HashSet hset = new HashSet<>(); - for (GadgetSet set : _sets) - { - if (set.isPartOfSet(gadget)) hset.add(set); - } - return hset; - } - public GadgetSet getGadgetSet(Class c) { for (GadgetSet set : _sets) @@ -982,12 +1036,7 @@ public class GadgetManager extends MiniPlugin public void addGadget(Gadget gadget) { - if (!_gadgets.containsKey(gadget.getGadgetType())) - { - _gadgets.put(gadget.getGadgetType(), new ArrayList<>()); - } - - _gadgets.get(gadget.getGadgetType()).add(gadget); + _gadgets.computeIfAbsent(gadget.getGadgetType(), k -> new ArrayList<>()).add(gadget); } @EventHandler @@ -1025,27 +1074,12 @@ public class GadgetManager extends MiniPlugin List gadgets = getGadgets(gadgetType); for (Gadget gadget : gadgets) { - if (gadget.getName().equalsIgnoreCase(name) - || Arrays.asList(gadget.getAlternativePackageNames()).contains(name)) - return gadget; - } - return null; - } - - public List getActiveBalloons(Player player) - { - List balloonGadgets = new ArrayList<>(); - for (Gadget gadget : getGadgets(GadgetType.BALLOON)) - { - if (gadget instanceof BalloonGadget) + if (gadget.getName().equalsIgnoreCase(name) || Arrays.asList(gadget.getAlternativePackageNames()).contains(name)) { - if (gadget.isActive(player)) - { - balloonGadgets.add((BalloonGadget) gadget); - } + return gadget; } } - return balloonGadgets; + return null; } public HatGadget getHatGadget(HatType type) @@ -1081,16 +1115,18 @@ public class GadgetManager extends MiniPlugin public BalloonGadget getBalloonGadget(BalloonType balloonType) { - for (Gadget gadget : getGadgets(GadgetType.BALLOON)) - { - if (gadget instanceof BalloonGadget) - { - BalloonGadget balloonGadget = (BalloonGadget) gadget; - if (balloonGadget.getBalloonType().equals(balloonType)) - return balloonGadget; - } - } - return null; + return (BalloonGadget) getGadgets(GadgetType.BALLOON).stream() + .filter(gadget -> ((BalloonGadget) gadget).getBalloonType() == balloonType) + .findFirst() + .orElse(null); + } + + public WeaponNameGadget getWeaponNameGadget(WeaponNameType weaponNameType) + { + return (WeaponNameGadget) getGadgets(GadgetType.WEAPON_NAME).stream() + .filter(gadget -> ((WeaponNameGadget) gadget).getWeaponNameType() == weaponNameType) + .findFirst() + .orElse(null); } public SingleParticleKitSelector getSingleParticleKitSelector(SingleParticleKitSelector.SingleParticleSelectors singleParticleSelectors) @@ -1143,37 +1179,13 @@ public class GadgetManager extends MiniPlugin { _userGadgetPersistence.setEnabled(false); - for (GadgetType gadgetType : _gadgets.keySet()) + _gadgets.forEach((type, gadgets) -> { - for (Gadget gadget : _gadgets.get(gadgetType)) + if (type.disableForGame()) { - if (gadget instanceof ParticleGadget) - continue; - - if (gadget instanceof ArrowEffectGadget) - continue; - - if (gadget instanceof DoubleJumpEffectGadget) - continue; - - if (gadget instanceof DeathEffectGadget) - continue; - - if (gadget instanceof WinEffectGadget) - continue; - - if (gadget instanceof GameModifierGadget) - continue; - - if (gadget instanceof TauntGadget) - continue; - - if (gadget instanceof KitSelectorGadget) - continue; - - gadget.disableForAll(); + gadgets.forEach(Gadget::disableForAll); } - } + }); } public void disableAll(Player player) @@ -1222,6 +1234,60 @@ public class GadgetManager extends MiniPlugin } } + public boolean selectLocation(Gadget gadget, Location location) + { + GadgetSelectLocationEvent event = new GadgetSelectLocationEvent(gadget, location); + UtilServer.CallEvent(event); + return !event.isCancelled(); + } + + public boolean selectBlocks(Gadget gadget, Block block) + { + // Use an ArrayList since removing is unsupported for singletonLists + return selectBlocks(gadget, new ArrayList<>(Collections.singletonList(block))); + } + + public boolean selectBlocks(Gadget gadget, Collection blocks) + { + GadgetBlockEvent event = new GadgetBlockEvent(gadget, blocks); + UtilServer.CallEvent(event); + + if (event.getBlocks().isEmpty()) + { + event.setCancelled(true); + } + + return !event.isCancelled(); + } + + public boolean selectEntity(Gadget gadget, Entity entity) + { + GadgetCollideEntityEvent event = new GadgetCollideEntityEvent(gadget, entity); + event.setCancelled(entity instanceof ArmorStand); + UtilServer.CallEvent(event); + return !event.isCancelled(); + } + + public void informNoUse(Player player) + { + player.sendMessage(F.main(getName(), "You cannot use that cosmetic in this area.")); + } + + public void playLeapEffect(Player player) + { + if (hideParticles()) + { + return; + } + + Gadget gadget = getActive(player, GadgetType.DOUBLE_JUMP); + + if (gadget != null) + { + ((DoubleJumpEffectGadget) gadget).doEffect(player); + } + } + public PetManager getPetManager() { return _petManager; @@ -1262,20 +1328,6 @@ public class GadgetManager extends MiniPlugin return _inventoryManager; } - public OutfitWindUpSuitBoosterManager getBoosterManager() - { - return _boosterManager; - } - - public boolean collideEvent(Player shooter, Gadget gadget, Entity other) - { - GadgetCollideEntityEvent collideEvent = new GadgetCollideEntityEvent(shooter, gadget, other); - - Bukkit.getServer().getPluginManager().callEvent(collideEvent); - - return collideEvent.isCancelled(); - } - public BlockRestore getBlockRestore() { return _blockRestore; @@ -1286,29 +1338,27 @@ public class GadgetManager extends MiniPlugin return _packetManager; } - @EventHandler + @EventHandler(priority = EventPriority.MONITOR) public void setMoving(PlayerMoveEvent event) { - if (UtilMath.offset(event.getFrom(), event.getTo()) <= 0.1) + Location from = event.getFrom(), to = event.getTo(); + + if (from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ()) + { return; + } _lastMove.put(event.getPlayer(), System.currentTimeMillis()); } public boolean isMoving(Player player) { - if (!UtilEnt.isGrounded(player)) return true; - - if (!_lastMove.containsKey(player)) - return false; - - return !UtilTime.elapsed(_lastMove.get(player), 500); + return !UtilEnt.isGrounded(player) || !UtilTime.elapsed(_lastMove.getOrDefault(player, Long.MAX_VALUE), 500); } @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { - //saveGadgets(event.getPlayer()); event.getPlayer().setWalkSpeed(0.2f); event.getPlayer().setFlySpeed(0.1f); disableAll(event.getPlayer(), false); @@ -1317,9 +1367,6 @@ public class GadgetManager extends MiniPlugin event.getPlayer().setWalkSpeed(0.2f); event.getPlayer().setFlySpeed(0.1f); _soulManager.giveSoul(event.getPlayer()); - - // Removes custom pet - CustomPet.removeCustomPet(event.getPlayer()); } @EventHandler @@ -1328,68 +1375,19 @@ public class GadgetManager extends MiniPlugin _lastMove.remove(event.getEntity()); } - - @EventHandler(priority = EventPriority.LOW) - public void onGadgetCollide(GadgetCollideEntityEvent event) - { - if (event.getOther() instanceof Player) - { - event.setCancelled(false); - return; - } - if (isAffectedByGadgets(event.getOther())) - { - event.setCancelled(false); - } - } - - /** - * @param e The entity to check - * @return Returns true if the entity is affected by gadgets like snowballs, flesh hooks etc - */ - public boolean isAffectedByGadgets(Entity e) - { - return _gadgetCollideWhitelist.contains(e); - } - - /** - * Set whether or not the given entity should be affected by gadgets by snowball, flesh hooks etc - * By default only players and naturally spawned entities are affected. - */ - public void setAffectedByGadgets(Entity e, boolean affected) - { - if (affected) - { - _gadgetCollideWhitelist.add(e); - } - else - { - _gadgetCollideWhitelist.remove(e); - } - } - public void setActive(Player player, Gadget gadget) { - if (!_playerActiveGadgetMap.containsKey(player)) - _playerActiveGadgetMap.put(player, new HashMap<>()); - - _playerActiveGadgetMap.get(player).put(gadget.getGadgetType(), gadget); + _playerActiveGadgetMap.computeIfAbsent(player, k -> new HashMap<>()).put(gadget.getGadgetType(), gadget); } public Gadget getActive(Player player, GadgetType gadgetType) { - if (!_playerActiveGadgetMap.containsKey(player)) - _playerActiveGadgetMap.put(player, new HashMap<>()); - - return _playerActiveGadgetMap.get(player).get(gadgetType); + return _playerActiveGadgetMap.computeIfAbsent(player, k -> new HashMap<>()).get(gadgetType); } public void removeActive(Player player, Gadget gadget) { - if (!_playerActiveGadgetMap.containsKey(player)) - _playerActiveGadgetMap.put(player, new HashMap<>()); - - _playerActiveGadgetMap.get(player).remove(gadget.getGadgetType()); + _playerActiveGadgetMap.computeIfAbsent(player, k -> new HashMap<>()).remove(gadget.getGadgetType()); } public void setHideParticles(boolean b) @@ -1402,6 +1400,16 @@ public class GadgetManager extends MiniPlugin return _hideParticles; } + public void setShowWeaponNames(boolean showWeaponNames) + { + _showWeaponNames = showWeaponNames; + } + + public boolean showWeaponNames() + { + return _showWeaponNames; + } + public void setActiveItemSlot(int i) { _activeItemSlot = i; @@ -1597,6 +1605,53 @@ public class GadgetManager extends MiniPlugin taunt.start(player); } + @EventHandler(priority = EventPriority.HIGH) + public void anvilUse(InventoryClickEvent event) + { + if (event.isCancelled() || !showWeaponNames()) + { + return; + } + + Inventory inventory = event.getClickedInventory(); + + if (inventory == null || !(inventory instanceof AnvilInventory) || event.getRawSlot() != 2) + { + return; + } + + ItemStack itemStack = inventory.getItem(event.getRawSlot()); + + if (itemStack == null || !itemStack.hasItemMeta() || !itemStack.getItemMeta().hasDisplayName()) + { + return; + } + + event.setCancelled(true); + + Player player = (Player) event.getWhoClicked(); + + player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 1); + player.sendMessage(F.main(_moduleName, "You cannot rename an item in an " + F.name("Anvil") + ".")); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void gameStart(CoreGameStartEvent event) + { + _gameIsLive = true; + } + + @EventHandler(priority = EventPriority.LOWEST) + public void gameStop(CoreGameStopEvent event) + { + _gameIsLive = false; + } + + public boolean isGameLive() + { + return _gameIsLive; + } + public CastleManager getCastleManager() { return _castleManager; @@ -1606,4 +1661,9 @@ public class GadgetManager extends MiniPlugin { return _gameCosmeticManager; } + + public AchievementManager getAchievementManager() + { + return _achievementManager; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/TestTauntCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/TestTauntCommand.java new file mode 100644 index 000000000..304c99468 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/TestTauntCommand.java @@ -0,0 +1,43 @@ +package mineplex.core.gadget.commands; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.util.F; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.GadgetManager.Perm; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.gadget.types.TauntGadget; + +public class TestTauntCommand extends CommandBase +{ + + public TestTauntCommand(GadgetManager plugin) + { + super(plugin, Perm.TEST_TAUNT_COMMAND, "testtaunt"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + caller.sendMessage(F.main(Plugin.getName(), "/" + _aliasUsed + " ")); + return; + } + + String name = Arrays.stream(args).collect(Collectors.joining(" ")); + TauntGadget gadget = (TauntGadget) Plugin.getGadget(name, GadgetType.TAUNT); + + if (gadget == null) + { + caller.sendMessage(F.main(Plugin.getName(), "There is no taunt named " + F.name(name) + ".")); + return; + } + + gadget.start(caller); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetBlockEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetBlockEvent.java index e42fbd699..0bbb42650 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetBlockEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetBlockEvent.java @@ -1,23 +1,25 @@ package mineplex.core.gadget.event; -import java.util.List; - -import mineplex.core.gadget.types.Gadget; +import java.util.Collection; import org.bukkit.block.Block; +import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -public class GadgetBlockEvent extends Event -{ - private static final HandlerList handlers = new HandlerList(); - - private Gadget _gadget; - private List _blocks; - - private boolean _cancelled = false; +import mineplex.core.gadget.types.Gadget; - public GadgetBlockEvent(Gadget gadget, List blocks) +public class GadgetBlockEvent extends Event implements Cancellable +{ + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Gadget _gadget; + private final Collection _blocks; + + private boolean _cancelled; + + public GadgetBlockEvent(Gadget gadget, Collection blocks) { _gadget = gadget; _blocks = blocks; @@ -25,12 +27,12 @@ public class GadgetBlockEvent extends Event public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } public Gadget getGadget() @@ -38,16 +40,18 @@ public class GadgetBlockEvent extends Event return _gadget; } - public List getBlocks() + public Collection getBlocks() { return _blocks; } - + + @Override public void setCancelled(boolean cancel) { _cancelled = cancel; } - + + @Override public boolean isCancelled() { return _cancelled; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetCollideEntityEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetCollideEntityEvent.java index f297c13c3..47c1bfdce 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetCollideEntityEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetCollideEntityEvent.java @@ -1,63 +1,47 @@ package mineplex.core.gadget.event; import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; import mineplex.core.gadget.types.Gadget; -/** - * An event called when a gadget used by a player collides with an entity. By default, only players are effected (event is cancelled). - */ -public class GadgetCollideEntityEvent extends Event implements Cancellable +public class GadgetCollideEntityEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - - private Player _gadgetHolder; - private Gadget _gadget; - private Entity _other; - - private boolean _cancelled = true; - public GadgetCollideEntityEvent(Player player, Gadget gadget, Entity other) - { - _gadgetHolder = player; - _gadget = gadget; - _other = other; - } - - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { - return handlers; - } - - public Player getPlayer() - { - return _gadgetHolder; - } + private static final HandlerList HANDLER_LIST = new HandlerList(); - public Gadget getGadget() + private final Gadget _gadget; + private boolean _cancelled; + + public GadgetCollideEntityEvent(Gadget gadget, Entity collided) + { + super(collided); + + _gadget = gadget; + } + + public HandlerList getHandlers() + { + return HANDLER_LIST; + } + + public static HandlerList getHandlerList() + { + return HANDLER_LIST; + } + + public Gadget getGadget() { return _gadget; } - public Entity getOther() - { - return _other; - } - public void setCancelled(boolean cancel) { _cancelled = cancel; } - + public boolean isCancelled() { return _cancelled; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetSelectLocationEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetSelectLocationEvent.java index fefbff7eb..f56d8cf82 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetSelectLocationEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/GadgetSelectLocationEvent.java @@ -1,40 +1,35 @@ package mineplex.core.gadget.event; import org.bukkit.Location; -import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import mineplex.core.gadget.types.Gadget; -/** - * This event is called when a gadget selects a location for a specific effect to be shown. - */ -public class GadgetSelectLocationEvent extends Event +public class GadgetSelectLocationEvent extends Event implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private Player _player; - private Gadget _gadget; - private Location _location; - private boolean _showMessage = true; - private boolean _cancelled = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); - public GadgetSelectLocationEvent(Player player, Gadget gadget, Location location) + private final Gadget _gadget; + private final Location _location; + private boolean _cancelled; + + public GadgetSelectLocationEvent(Gadget gadget, Location location) { - _player = player; _gadget = gadget; _location = location; } public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } public Gadget getGadget() @@ -42,43 +37,20 @@ public class GadgetSelectLocationEvent extends Event return _gadget; } - public Player getPlayer() - { - return _player; - } - public Location getLocation() { return _location; } + @Override public void setCancelled(boolean cancel) { _cancelled = cancel; } + @Override public boolean isCancelled() { return _cancelled; } - - /** - * Whether or not a cancellation message should be displayed. - * - * @param showMessage True for the message to be shown and false for the message to be hidden/ignored. - */ - public void setShowMessage(boolean showMessage) - { - _showMessage = showMessage; - } - - /** - * Returns whether or not a cancellation message can be shown. - * - * @return True if the message can be shown and false if the message should be hidden/ignored. - */ - public boolean canShowMessage() - { - return _showMessage; - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailBalance.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailBalance.java new file mode 100644 index 000000000..7c7ed3a6c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailBalance.java @@ -0,0 +1,45 @@ +package mineplex.core.gadget.gadgets.arrowtrail; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Arrow; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ArrowEffectGadget; +import mineplex.core.gadget.util.CostConstants; + +public class ArrowTrailBalance extends ArrowEffectGadget +{ + + public ArrowTrailBalance(GadgetManager manager) + { + super(manager, "Simple Geometry", + UtilText.splitLineToArray(C.cGray + "If you put water into a tea put, it becomes the tea pot. Be like water my friend.", LineFormat.LORE), + CostConstants.FOUND_IN_TREASURE_CHESTS, + Material.RECORD_9, (byte) 0); + } + + @Override + public void doTrail(Arrow arrow) + { + Location location = arrow.getLocation(); + + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, location, null, 0, 1, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, location, null, 0, 1, ViewDist.NORMAL); + } + + @Override + public void doHitEffect(Arrow arrow) + { + Location location = arrow.getLocation(); + + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, location, null, 0.2F, 10, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, location, null, 0.2F, 10, ViewDist.NORMAL); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailLegend.java new file mode 100644 index 000000000..c214184ea --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailLegend.java @@ -0,0 +1,58 @@ +package mineplex.core.gadget.gadgets.arrowtrail; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Arrow; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.set.SetLegend; +import mineplex.core.gadget.types.ArrowEffectGadget; +import mineplex.core.gadget.util.CostConstants; + +public class ArrowTrailLegend extends ArrowEffectGadget +{ + + public ArrowTrailLegend(GadgetManager manager) + { + super(manager, "Arrows of the Legends", + UtilText.splitLineToArray(C.cGray + "Pwaaaaa Legendary!", LineFormat.LORE), + CostConstants.UNLOCKED_WITH_LEGEND, + Material.ENDER_PORTAL_FRAME, (byte) 0); + } + + @Override + public void doTrail(Arrow arrow) + { + Location location = arrow.getLocation(); + + for (DustSpellColor color : SetLegend.SELECTABLE_COLORS) + { + new ColoredParticle(ParticleType.RED_DUST, color, location) + .display(); + } + } + + @Override + public void doHitEffect(Arrow arrow) + { + for (DustSpellColor color : SetLegend.SELECTABLE_COLORS) + { + Location location = UtilAlg.getRandomLocation(arrow.getLocation(), 0.8, 0.3, 0.8); + int i = 0; + + while (i++ < 15) + { + new ColoredParticle(ParticleType.RED_DUST, color, location.add(0, 0.1, 0)) + .display(); + } + } + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/balloons/BalloonEntity.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/balloons/BalloonEntity.java new file mode 100644 index 000000000..941921f6b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/balloons/BalloonEntity.java @@ -0,0 +1,84 @@ +package mineplex.core.gadget.gadgets.balloons; + +import net.minecraft.server.v1_8_R3.EntitySlime; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; + +public class BalloonEntity extends EntitySlime +{ + + public static BalloonEntity spawn(ArmorStand host, Player holder, boolean small) + { + BalloonEntity entity = new BalloonEntity(host, holder, small); + UtilEnt.spawnEntity(entity, host.getLocation()); + return entity; + } + + private final ArmorStand _host; + private final Player _holder; + private final boolean _small; + private final double _height; + + private BalloonEntity(ArmorStand host, Player holder, boolean small) + { + super(((CraftWorld) host.getWorld()).getHandle()); + + _host = host; + _holder = holder; + _small = small; + _height = small ? 0.2 : 1.5; + } + + @Override + public void t_() + { + Location host = _host.getLocation(), holder = _holder.getEyeLocation(), teleport = host.clone(); + double offsetXZ = UtilMath.offset2dSquared(holder, host), offsetY = host.getY() - holder.getY(); + + if (offsetY < 0.5) + { + teleport.add(0, 0.1, 0); + } + else if (offsetY > (_small ? 2 : 1)) + { + teleport.subtract(0, 0.1, 0); + } + + if (offsetXZ > 2) + { + teleport.add(UtilAlg.getTrajectory2d(host, holder).multiply(0.1 * offsetXZ)); + } + + teleport.add(UtilMath.random(-0.1, 0.1), UtilMath.random(-0.1, 0.1), UtilMath.random(-0.1, 0.1)); + teleport.setYaw((teleport.getYaw() + UtilMath.rRange(-2, 2)) % 360); + + ((CraftEntity) _host).getHandle().setPositionRotation(teleport.getX(), teleport.getY(), teleport.getZ(), teleport.getYaw(), 0); + setPosition(teleport.getX(), teleport.getY() + _height, teleport.getZ()); + + LivingEntity entity = (LivingEntity) getBukkitEntity(); + + entity.setLeashHolder(_holder); + entity.setShouldBreakLeash(false); + } + + public void remove() + { + _host.remove(); + getBukkitEntity().remove(); + } + + public boolean isPartOfEntity(Entity entity) + { + return entity.equals(this) || entity.equals(_host); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/balloons/BalloonItem.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/balloons/BalloonItem.java deleted file mode 100644 index 67ea7e618..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/balloons/BalloonItem.java +++ /dev/null @@ -1,103 +0,0 @@ -package mineplex.core.gadget.gadgets.balloons; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.bukkit.entity.Ageable; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.entity.Zombie; -import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilServer; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.BalloonGadget; - -public class BalloonItem extends BalloonGadget -{ - - private BalloonType _balloonType; - private Map> _entities = new HashMap<>(); - private Map _reverseEntityMap = new HashMap<>(); - - public BalloonItem(GadgetManager manager, BalloonType balloonType) - { - super(manager, balloonType.getName(), balloonType.getLore(), balloonType.getCost(), - balloonType.getDisplayItem().getType(), - balloonType.getDisplayItem().getData().getData(), balloonType, - balloonType.getEntityType()); - setDisplayItem(balloonType.getDisplayItem()); - _balloonType = balloonType; - } - - @Override - public Entity[] spawnEntity(Player player) - { - Entity[] ents = new Entity[2]; - if (_balloonType.getEntityType().equals(EntityType.ARMOR_STAND)) - { - Zombie zombie = player.getWorld().spawn(player.getLocation(), Zombie.class); - zombie.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false, false)); - zombie.getEquipment().setHelmet(_balloonType.getDisplayItem()); - UtilEnt.silence(zombie, true); - UtilEnt.vegetate(zombie); - addEntity(player, zombie); - - ents[0] = zombie; - - return ents; - } - else if (_balloonType.equals(BalloonType.BABY_ZOMBIE)) - { - Zombie zombie = player.getWorld().spawn(player.getLocation(), Zombie.class); - zombie.setBaby(true); - UtilEnt.vegetate(zombie); - UtilEnt.silence(zombie, true); - addEntity(player, zombie); - ents[0] = zombie; - return ents; - } - - - Entity entity = player.getWorld().spawnEntity(player.getLocation(), _balloonType.getEntityType()); - if (_balloonType.isBaby() && entity instanceof Ageable) - { - ((Ageable) entity).setBaby(); - ((Ageable) entity).setAgeLock(true); - } - UtilEnt.vegetate(entity); - UtilEnt.silence(entity, true); - addEntity(player, entity); - ents[0] = entity; - return ents; - } - - private void addEntity(Player player, Entity entity) - { - _entities.computeIfAbsent(player.getUniqueId(), list -> new ArrayList<>()); - List entities = _entities.get(player.getUniqueId()); - entities.add(entity); - _entities.put(player.getUniqueId(), entities); - _reverseEntityMap.put(entity, player); - entity.setMetadata("balloon", new FixedMetadataValue(UtilServer.getPlugin(), "true")); - } - - @Override - public void removeEntities(Player player) - { - for (Entity entity : _entities.get(player.getUniqueId())) - { - _reverseEntityMap.remove(entity); - entity.remove(); - } - _entities.remove(player.getUniqueId()); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/balloons/BalloonType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/balloons/BalloonType.java index 1fbf94fc2..15cbc2e49 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/balloons/BalloonType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/balloons/BalloonType.java @@ -5,70 +5,99 @@ import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseBat; +import mineplex.core.disguise.disguises.DisguiseCat; +import mineplex.core.disguise.disguises.DisguiseCow; +import mineplex.core.disguise.disguises.DisguiseGuardian; +import mineplex.core.disguise.disguises.DisguiseMooshroom; +import mineplex.core.disguise.disguises.DisguisePig; +import mineplex.core.disguise.disguises.DisguiseSheep; +import mineplex.core.disguise.disguises.DisguiseSilverFish; +import mineplex.core.disguise.disguises.DisguiseSlime; +import mineplex.core.disguise.disguises.DisguiseSquid; +import mineplex.core.disguise.disguises.DisguiseVillager; +import mineplex.core.disguise.disguises.DisguiseWolf; +import mineplex.core.disguise.disguises.DisguiseZombie; +import mineplex.core.gadget.util.CostConstants; +import mineplex.core.shop.item.IDisplayPackage; -public enum BalloonType +public enum BalloonType implements IDisplayPackage { - // BABY - BABY_COW (EntityType.COW, true, "Baby Cow Balloon", 0, new ItemStack(Material.COOKED_BEEF)), - BABY_PIG (EntityType.PIG, true, "Baby Pig Balloon", 0, new ItemStack(Material.GRILLED_PORK)), - BABY_ZOMBIE (EntityType.ZOMBIE, true, "Baby Zombie Balloon", 0, new ItemStack(Material.ROTTEN_FLESH)), - BABY_MUSHROOM(EntityType.MUSHROOM_COW, true, "Baby Mushroom Cow Balloon", 0, new ItemStack(Material.MUSHROOM_SOUP)), - BABY_OCELOT (EntityType.OCELOT, true, "Baby Ocelot Balloon", 0, new ItemStack(Material.COOKED_FISH)), - BABY_WOLF (EntityType.WOLF, true, "Baby Wolf Balloon", 0, new ItemStack(Material.BONE)), - BABY_SHEEP (EntityType.SHEEP, true, "Baby Sheep Balloon", 0, new ItemStack(Material.WOOL)), - BABY_VILLAGER(EntityType.VILLAGER, true, "Baby Villager Balloon", 0, new ItemStack(Material.EMERALD)), - BABY_SLIME (EntityType.SLIME, true, "Baby Slime Balloon", 0, new ItemStack(Material.SLIME_BALL)), + BABY_COW(DisguiseCow.class, "Baby Cow", Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.COW)), + BABY_PIG(DisguisePig.class, "Baby Pig", Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.PIG)), + BABY_ZOMBIE(DisguiseZombie.class, "Baby Zombie", Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.ZOMBIE)), + BABY_MUSHROOM(DisguiseMooshroom.class, "Baby Mushroom Cow", Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.MUSHROOM_COW)), + BABY_OCELOT(DisguiseCat.class, "Baby Ocelot", Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.OCELOT)), + BABY_WOLF(DisguiseWolf.class, "Baby Wolf", Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.WOLF)), + BABY_SHEEP(DisguiseSheep.class, "Baby Sheep", Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.SHEEP)), + BABY_VILLAGER(DisguiseVillager.class, "Baby Villager", Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.VILLAGER)), + BABY_SLIME(DisguiseSlime.class, "Baby Slime", Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.SLIME)), - // NOT BABY - SQUID (EntityType.SQUID, "Squid Balloon", 0, new ItemStack(Material.INK_SACK)), - BAT (EntityType.BAT, "Bat Balloon", 0, new ItemStack(Material.JACK_O_LANTERN)), - SILVERFISH(EntityType.SILVERFISH, "Silverfish Balloon", 0, new ItemStack(Material.getMaterial(97))), - GUARDIAN (EntityType.GUARDIAN, "Guardian Balloon", 0, new ItemStack(Material.PRISMARINE_SHARD)), + SQUID(DisguiseSquid.class, "Squid", Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.SQUID)), + BAT(DisguiseBat.class, "Bat", Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.BAT)), + SILVERFISH(DisguiseSilverFish.class, "Silverfish", Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.SILVERFISH)), + GUARDIAN(DisguiseGuardian.class, "Guardian", Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.GUARDIAN)), - // BLOCK - /*DRAGON_EGG (new ItemStack(Material.DRAGON_EGG), false, "Dragon Egg Balloon", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE), 0), - DIAMOND_BLOCK(new ItemStack(Material.DIAMOND_BLOCK), false, "Diamond Block Balloon", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE), 0), - IRON_BLOCK (new ItemStack(Material.IRON_BLOCK), false, "Iron Block Balloon", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE), 0), - GOLD_BLOCK (new ItemStack(Material.GOLD_BLOCK), false, "Gold Block Balloon", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE), 0),*/ - EMERALD_BLOCK(new ItemStack(Material.EMERALD_BLOCK), false, "Emerald Block Balloon", 0); + DRAGON_EGG(new ItemStack(Material.DRAGON_EGG), "Dragon Egg", Material.DRAGON_EGG, 0), + DIAMOND_BLOCK(new ItemStack(Material.DIAMOND_BLOCK), "Diamond Block", Material.DIAMOND_BLOCK, 0), + IRON_BLOCK(new ItemStack(Material.IRON_BLOCK), "Iron Block", Material.IRON_BLOCK, 0), + GOLD_BLOCK(new ItemStack(Material.GOLD_BLOCK), "Gold Block", Material.GOLD_BLOCK, 0), + EMERALD_BLOCK(new ItemStack(Material.EMERALD_BLOCK), "Emerald Block", Material.EMERALD_BLOCK, 0), + RED_BLOCK(new ItemStack(Material.STAINED_CLAY, 1, (short) 0, (byte) 14), "Red", Material.STAINED_CLAY, 14); - private EntityType _entityType; - private boolean _isBaby; - private String _name; - private String[] _lore; - private int _cost; - private ItemStack _displayItem; + private final Class _clazz; + private final ItemStack _helmet; + private final String _name; + private final String[] _description; + private final int _cost; + private final Material _material; + private final byte _materialData; - BalloonType(EntityType entityType, String name, int cost, ItemStack displayItem) + BalloonType(Class clazz, String name, Material material, int materialData) { - this(entityType, false, name, cost, displayItem); + this(clazz, null, name, null, CostConstants.FOUND_IN_TREASURE_CHESTS, material, materialData); } - BalloonType(EntityType entityType, boolean isBaby, String name, int cost, ItemStack displayItem) + BalloonType(Class clazz, String name, String[] description, int cost, Material material, int materialData) { - _entityType = entityType; - _isBaby = isBaby; + this(clazz, null, name, description, cost, material, materialData); + } + + BalloonType(ItemStack helmet, String name, Material material, int materialData) + { + this(null, helmet, name, null, CostConstants.FOUND_IN_TREASURE_CHESTS, material, materialData); + } + + BalloonType(ItemStack helmet, String name, String[] description, int cost, Material material, int materialData) + { + this(null, helmet, name, description, cost, material, materialData); + } + + BalloonType(Class clazz, ItemStack helmet, String name, String[] description, int cost, Material material, int materialData) + { + _clazz = clazz; + _helmet = helmet; _name = name; + _description = description == null ? UtilText.splitLineToArray(C.cGray + "A floating " + F.name(getName() + " Balloon") + " that appears above your head!", LineFormat.LORE) : description; _cost = cost; - _displayItem = displayItem; + _material = material; + _materialData = (byte) materialData; } - BalloonType(ItemStack block, boolean isBaby, String name, int cost) + public Class getClazz() { - this(EntityType.ARMOR_STAND, isBaby, name, cost, block); + return _clazz; } - public EntityType getEntityType() + public ItemStack getHelmet() { - return _entityType; - } - - public boolean isBaby() - { - return _isBaby; + return _helmet; } public String getName() @@ -76,11 +105,10 @@ public enum BalloonType return _name; } - public String[] getLore() + @Override + public String[] getDescription() { - return UtilText.splitLinesToArray(new String[]{C.cGray + "A floating " + getName() + " that appears above your head!", - "", - C.cWhite + "Click to activate, click again to remove. You can have up to 10 balloons active at a time."}, LineFormat.LORE); + return _description; } public int getCost() @@ -88,8 +116,15 @@ public enum BalloonType return _cost; } - public ItemStack getDisplayItem() + @Override + public Material getDisplayMaterial() { - return _displayItem; + return _material; + } + + @Override + public byte getDisplayData() + { + return _materialData; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/chat/LevelPrefixType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/chat/LevelPrefixType.java new file mode 100644 index 000000000..b6b8bcfe9 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/chat/LevelPrefixType.java @@ -0,0 +1,64 @@ +package mineplex.core.gadget.gadgets.chat; + +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; + +public enum LevelPrefixType +{ + + GRAY(ChatColor.GRAY, DyeColor.GRAY, "Gray", 0), + BLUE(ChatColor.BLUE, DyeColor.BLUE, "Blue", 20), + DARK_GREEN(ChatColor.DARK_GREEN, DyeColor.GREEN, "Dark Green", 40), + GOLD(ChatColor.GOLD, DyeColor.ORANGE, "Gold", 60), + RED(ChatColor.RED, DyeColor.RED, "Red", 80), + DARK_RED(ChatColor.DARK_RED, DyeColor.BROWN, "Dark Red"), + YELLOW(ChatColor.YELLOW, DyeColor.YELLOW, "Yellow"), + GREEN(ChatColor.GREEN, DyeColor.LIME, "Green"), + AQUA(ChatColor.AQUA, DyeColor.LIGHT_BLUE, "Aqua"), + CYAN(ChatColor.DARK_AQUA, DyeColor.CYAN, "Cyan"), + DARK_BLUE(ChatColor.DARK_BLUE, DyeColor.BLUE, "Dark Blue"), + PURPLE(ChatColor.DARK_PURPLE, DyeColor.PURPLE, "Purple"), + PINK(ChatColor.LIGHT_PURPLE, DyeColor.PINK, "Pink"), + WHITE(ChatColor.WHITE, DyeColor.WHITE, "White"), + BLACK(ChatColor.BLACK, DyeColor.BLACK, "Black") + + ; + + private final ChatColor _chatColor; + private final DyeColor _dyeColor; + private final String _name; + private int _unlockAt; + + LevelPrefixType(ChatColor chatColor, DyeColor dyeColor, String name) + { + this(chatColor, dyeColor, name, 100); + } + + LevelPrefixType(ChatColor chatColor, DyeColor dyeColor, String name, int unlockAt) + { + _chatColor = chatColor; + _dyeColor = dyeColor; + _name = name; + _unlockAt = unlockAt; + } + + public ChatColor getChatColor() + { + return _chatColor; + } + + public DyeColor getDyeColor() + { + return _dyeColor; + } + + public String getName() + { + return _name; + } + + public int getUnlockAt() + { + return _unlockAt; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathBalance.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathBalance.java new file mode 100644 index 000000000..b5c728d6a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathBalance.java @@ -0,0 +1,72 @@ +package mineplex.core.gadget.gadgets.death; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import mineplex.core.blood.BloodEvent; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.DeathEffectGadget; +import mineplex.core.gadget.util.CostConstants; + +public class DeathBalance extends DeathEffectGadget +{ + + private static final double DELTA_THETA = Math.PI / 10; + + public DeathBalance(GadgetManager manager) + { + super(manager, "Everlasting balance", + UtilText.splitLineToArray(C.cGray + "Mmmmm Challenge him you must.", LineFormat.LORE), + CostConstants.FOUND_IN_TREASURE_CHESTS, + Material.RECORD_9, (byte) 0); + } + + @Override + public void onBlood(Player player, BloodEvent event) + { + event.setCancelled(true); + event.setItem(Material.RECORD_9, (byte) 0); + + Location locationA = player.getLocation().add(0, 0.1, 0), locationB = locationA.clone(); + + Manager.runSyncTimer(new BukkitRunnable() + { + double theta = 0, radius = 2, y = 0; + + @Override + public void run() + { + double x = radius * Math.cos(theta), z = radius * Math.sin(theta); + + locationA.add(x, y, z); + locationB.add(-x, y, -z); + + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, locationA, null, 0, 1, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, locationB, null, 0, 1, ViewDist.NORMAL); + + locationA.subtract(x, y, z); + locationB.subtract(-x, y, -z); + + theta += DELTA_THETA; + radius -= 0.1; + y += 0.2; + + if (radius < 0) + { + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, locationA, null, 0.2F, 5, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, locationB, null, 0.5F, 5, ViewDist.NORMAL); + cancel(); + } + } + }, 0, 1); + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathLegend.java new file mode 100644 index 000000000..b38c802c3 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/DeathLegend.java @@ -0,0 +1,35 @@ +package mineplex.core.gadget.gadgets.death; + +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; + +import mineplex.core.blood.BloodEvent; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.DeathEffectGadget; +import mineplex.core.gadget.util.CostConstants; + +public class DeathLegend extends DeathEffectGadget +{ + + public DeathLegend(GadgetManager manager) + { + super(manager, "Legend's Legacy", + UtilText.splitLineToArray(C.cGray + "A story to be told for generations to come.", LineFormat.LORE), + CostConstants.UNLOCKED_WITH_LEGEND, + Material.ENDER_PORTAL_FRAME, (byte) 0); + } + + @Override + public void onBlood(Player player, BloodEvent event) + { + event.setItem(Material.ENDER_PEARL, (byte) 0); + event.getLocation().getWorld().playEffect(event.getLocation(), Effect.ENDER_SIGNAL, 0); + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpBalance.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpBalance.java new file mode 100644 index 000000000..3af83ac69 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpBalance.java @@ -0,0 +1,51 @@ +package mineplex.core.gadget.gadgets.doublejump; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.DoubleJumpEffectGadget; +import mineplex.core.gadget.util.CostConstants; + +public class DoubleJumpBalance extends DoubleJumpEffectGadget +{ + + public DoubleJumpBalance(GadgetManager manager) + { + super(manager, "Balanced Leap", + UtilText.splitLineToArray(C.cGray + "The richest in the world is not the one who has the most, but the one that needs the least.", LineFormat.LORE), + CostConstants.FOUND_IN_TREASURE_CHESTS, + Material.RECORD_9, (byte) 0); + } + + @Override + public void doEffect(Player player) + { + Manager.runSyncTimer(new BukkitRunnable() + { + int ticks = 0; + + @Override + public void run() + { + Location location = player.getLocation(); + + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, location, null, 0.05F, 1, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, location, null, 0.05F, 1, ViewDist.NORMAL); + + if (ticks++ > 15) + { + cancel(); + } + } + }, 0, 1); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpLegend.java new file mode 100644 index 000000000..1d23e6065 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpLegend.java @@ -0,0 +1,45 @@ +package mineplex.core.gadget.gadgets.doublejump; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.set.SetLegend; +import mineplex.core.gadget.types.DoubleJumpEffectGadget; +import mineplex.core.gadget.util.CostConstants; + +public class DoubleJumpLegend extends DoubleJumpEffectGadget +{ + + public DoubleJumpLegend(GadgetManager manager) + { + super(manager, "Legendary Leap", + UtilText.splitLineToArray(C.cGray + "Reach the height of legends.", LineFormat.LORE), + CostConstants.UNLOCKED_WITH_LEGEND, + Material.ENDER_PORTAL_FRAME, (byte) 0); + } + + @Override + public void doEffect(Player player) + { + int i = 0; + + Location center = player.getLocation().add(0, 0.3, 0); + + for (Location location : UtilShapes.getPointsInCircle(center, 50, 1)) + { + new ColoredParticle(ParticleType.RED_DUST, SetLegend.SELECTABLE_COLORS[i++ % SetLegend.SELECTABLE_COLORS.length], location) + .display(); + } + center.getWorld().playEffect(center, Effect.ENDER_SIGNAL, 0); + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java index eaa427604..860817235 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/flag/FlagType.java @@ -15,6 +15,7 @@ public enum FlagType PRESENT(CountryFlag.PRESENT, CostConstants.FOUND_IN_GINGERBREAD_CHESTS), WREATH(CountryFlag.WREATH, CostConstants.FOUND_IN_GINGERBREAD_CHESTS), SNOW_FLAKE(CountryFlag.SNOW_FLAKE, CostConstants.FOUND_IN_GINGERBREAD_CHESTS), + HEART(CountryFlag.HEART, CostConstants.FOUND_IN_TREASURE_CHESTS), // Country AFGHANISTAN(CountryFlag.AFGHANISTAN, -1), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/GameItemGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/GameItemGadget.java new file mode 100644 index 000000000..90927bc3c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/GameItemGadget.java @@ -0,0 +1,122 @@ +package mineplex.core.gadget.gadgets.item; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; + +import mineplex.core.common.Pair; +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.HoverEvent; +import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.Ammo; +import mineplex.core.gadget.types.ItemGadget; + +public abstract class GameItemGadget extends ItemGadget +{ + + private static final long COOLDOWN_INVITE = TimeUnit.SECONDS.toMillis(8); + + protected final Map> _invites; + private final String _command; + + public GameItemGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, Ammo ammo) + { + super(manager, name, desc, cost, mat, data, COOLDOWN_INVITE, ammo); + + _invites = new HashMap<>(3); + _command = "/play-" + name.toLowerCase().replace(" ", "-"); + } + + @Override + public void ActivateCustom(Player player) + { + for (Player nearby : UtilPlayer.getNearby(player.getLocation(), 3)) + { + if (player.equals(nearby)) + { + continue; + } + + sendGameInvite(nearby, player); + return; + } + } + + protected abstract void startGame(Player invitee, Player inviter); + + private void sendGameInvite(Player invitee, Player inviter) + { + inviter.sendMessage(F.main(Manager.getName(), "You challenged " + F.name(invitee.getName()) + " to play " + F.name(getName()) + "!")); + + new JsonMessage(F.main(Manager.getName(), F.color("CLICK HERE", C.cYellowB) + " to play " + F.name(getName()) + " with " + F.name(inviter.getName()) + "!")) + .hover(HoverEvent.SHOW_TEXT, C.cYellow + "Click to play " + F.name(getName()) + " with " + F.name(inviter.getName())) + .click(ClickEvent.RUN_COMMAND, _command + " " + inviter.getName()) + .sendToPlayer(invitee); + + invitee.playSound(invitee.getLocation(), Sound.NOTE_PIANO, 1, 1); + inviter.playSound(inviter.getLocation(), Sound.NOTE_PIANO, 1, 1); + + _invites.put(inviter.getName(), Pair.create(invitee.getName(), System.currentTimeMillis())); + } + + @EventHandler + public void commandProcess(PlayerCommandPreprocessEvent event) + { + String command = event.getMessage(); + String[] split = command.split(" "); + + if (split.length != 2 || !split[0].equals(_command)) + { + return; + } + + event.setCancelled(true); + + Player caller = event.getPlayer(); + String player = split[1]; + Pair pair = _invites.get(player); + + if (pair == null || !pair.getLeft().equals(caller.getName()) || UtilTime.elapsed(pair.getRight(), COOLDOWN_INVITE)) + { + return; + } + + Player inviter = UtilPlayer.searchExact(player); + + if (inviter == null) + { + caller.sendMessage(F.main(Manager.getName(), "Looks like the player who challenged you is no longer online.")); + return; + } + + _invites.remove(player); + caller.sendMessage(F.main(Manager.getName(), F.name(inviter.getName()) + " challenged you to a game of " + F.name(getName()) + "!")); + inviter.sendMessage(F.main(Manager.getName(), "You challenged " + F.name(caller.getName()) + " to a game of " + F.name(getName()) + "!")); + startGame(caller, inviter); + } + + protected void endGame(Player winner, Player loser) + { + UtilTextMiddle.display(C.cYellowB + "YOU WON", "", 10, 30, 10, winner); + UtilTextMiddle.display(C.cRedB + "YOU LOST", "", 10, 30, 10, loser); + winner.getWorld().playSound(winner.getLocation(), Sound.VILLAGER_YES, 1, 1); + loser.getWorld().playSound(winner.getLocation(), Sound.VILLAGER_NO, 1, 1); + } + + protected void drawGame(Player... players) + { + UtilTextMiddle.display(C.cRedB + "DRAW", "", 10, 30, 10, players); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBallCatch.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBallCatch.java index 3426ca6cf..1a01b7149 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBallCatch.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBallCatch.java @@ -38,7 +38,7 @@ public class ItemBallCatch extends ItemGadget private static final double VELOCITY_INCREASE_FACTOR = 1.05; private static final double VELOCITY_Y = 0.2; private static final double VELOCITY_Y_DECREASE = 0.005; - private static final long COOLDOWN = TimeUnit.SECONDS.toMillis(20); + private static final long COOLDOWN = TimeUnit.SECONDS.toMillis(10); private final Map _balls; @@ -46,8 +46,8 @@ public class ItemBallCatch extends ItemGadget { super(manager, "Play Catch", new String[] { - C.cWhite + "Play Catch", - C.cWhite + "with other players!", + C.cGray + "Play Catch", + C.cGray + "with other players!", C.blankLine, C.cWhite + "Left click hit the ball.", C.cWhite + "You cannot hit the ball twice", diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java index 49eb81e85..8d67a3cce 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java @@ -118,9 +118,11 @@ public class ItemBatGun extends ItemGadget if (UtilEnt.hitBox(bat.getLocation(), other, 2, null)) { - if (Manager.collideEvent(cur, this, other)) + if (!Manager.selectEntity(this, other)) + { continue; - + } + //Damage Event UtilAction.velocity(other, UtilAlg.getTrajectory(cur, other), 0.4, false, 0, 0.2, 10, true); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBubbleBlaster.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBubbleBlaster.java deleted file mode 100644 index 525cabf58..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBubbleBlaster.java +++ /dev/null @@ -1,121 +0,0 @@ -package mineplex.core.gadget.gadgets.item; - -import java.awt.Color; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.bukkit.Material; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.particles.ColoredParticle; -import mineplex.core.common.util.particles.DustSpellColor; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.Ammo; -import mineplex.core.gadget.types.ItemGadget; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - -public class ItemBubbleBlaster extends ItemGadget -{ - - private Map _armorStands = new HashMap<>(); - - public ItemBubbleBlaster(GadgetManager manager) - { - super(manager, "Bubble Blaster", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), - -14, Material.DIAMOND_BARDING, (byte) 0, 5000, new Ammo("Bubble", "Bubble", Material.DIAMOND_BARDING, (byte) 0, new String[]{C.cGray + "Placeholder"}, -5, 1)); - } - - @Override - public void disableCustom(Player player, boolean message) - { - super.disableCustom(player, message); - } - - @Override - public void ActivateCustom(Player player) - { - - } - - @Override - @EventHandler - public void Activate(PlayerInteractEvent event) - { - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; - - if (UtilBlock.usable(event.getClickedBlock())) - return; - - if (!UtilGear.isMat(event.getPlayer().getItemInHand(), this.getDisplayMaterial())) - return; - - Player player = event.getPlayer(); - - if (!isActive(player)) - return; - - event.setCancelled(true); - - player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(getDisplayMaterial(), getDisplayData(), 1, F.item(Manager.getInventoryManager().Get(player).getItemCount(getName()) + " " + getName()))); - - // TODO CHANGE COLOR IF RAINBOW - // TODO COOLDOWN AFTER MAX OF 5 SECONDS HOLDING - // TODO LAUNCH MULTIPLE WHILE HOLDING - - ArmorStand armorStand = player.getWorld().spawn(player.getLocation().add(0, 1, 0), ArmorStand.class); - armorStand.setItemInHand(new ItemStack(Material.STAINED_GLASS, 1, (byte) UtilMath.random.nextInt(15))); - armorStand.setSmall(true); - armorStand.setVisible(false); - - _armorStands.put(armorStand, player); - - double x = UtilMath.random(0.5, 1) - 1.25, z = UtilMath.random(0.5, 1) - 1.25; - double sub = UtilMath.random(0.5, 1); - if (sub > 0.75) - UtilAction.velocity(armorStand, player.getLocation().getDirection().add(new Vector(x, 0, z)), 0.25, false, 0, 0.5, 1, false); - else - UtilAction.velocity(armorStand, player.getLocation().getDirection().subtract(new Vector(x, 0, z)), 0.25, false, 0, 0.5, 1, false); - } - - @EventHandler - public void updateArmorStand(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - Iterator> iterator = _armorStands.entrySet().iterator(); - while (iterator.hasNext()) - { - Map.Entry entry = iterator.next(); - ArmorStand armorStand = entry.getKey(); - Player player = entry.getValue(); - if (armorStand.getTicksLived() >= 20) - { - ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(Color.WHITE), armorStand.getLocation()); - coloredParticle.display(); - armorStand.remove(); - iterator.remove(); - } - } - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemConnect4.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemConnect4.java new file mode 100644 index 000000000..6d492dd5d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemConnect4.java @@ -0,0 +1,416 @@ +package mineplex.core.gadget.gadgets.item; + +import java.time.Month; +import java.time.YearMonth; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.scheduler.BukkitRunnable; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetBlockEvent; +import mineplex.core.gadget.util.CostConstants; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class ItemConnect4 extends GameItemGadget +{ + + private static final long COOLDOWN_USE = TimeUnit.SECONDS.toMillis(20); + private static final long TIMEOUT = TimeUnit.MINUTES.toMillis(5); + + private static final int ROWS = 6; + private static final int COLUMNS = 7; + + private final Set _gameBoards; + + public ItemConnect4(GadgetManager manager) + { + super(manager, "Connect 4", new String[] + { + C.cGray + "Play Connect 4", + C.cGray + "with other players!", + C.blankLine, + C.cWhite + "Left click the quartz block", + C.cWhite + "to place a counter in that", + C.cWhite + "column", + C.cWhite + "First person to get 4", + C.cWhite + "in a row" + }, CostConstants.POWERPLAY_BONUS, Material.STAINED_CLAY, (byte) 4, null); + + setPPCYearMonth(YearMonth.of(2018, Month.MARCH)); + Free = false; + _gameBoards = new HashSet<>(); + } + + public boolean activatePreprocess(Player player) + { + for (GameBoard board : _gameBoards) + { + if (board.PlayerA.equals(player) || board.PlayerB.equals(player)) + { + return false; + } + } + + return true; + } + + @Override + public void disableCustom(Player player, boolean message) + { + super.disableCustom(player, message); + + remove(player); + } + + private void remove(Player player) + { + _gameBoards.removeIf(board -> + { + if (board.PlayerA.equals(player) || board.PlayerB.equals(player)) + { + cleanupBoard(board, false); + return true; + } + + return false; + }); + + _invites.remove(player.getName()); + } + + @EventHandler + public void updateTimeout(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOWER) + { + return; + } + + _gameBoards.removeIf(board -> + { + if (UtilTime.elapsed(board.StartTime, TIMEOUT)) + { + cleanupBoard(board, false); + return true; + } + + return false; + }); + } + + @Override + protected void startGame(Player invitee, Player inviter) + { + Location location = inviter.getLocation(); + GameBoard board = new GameBoard(inviter, invitee, location); + + if (!Manager.selectLocation(this, location) || !Manager.selectBlocks(this, board.Blocks) || board.Blocks.stream() + .anyMatch(block -> block.getType() != Material.AIR)) + { + String message = F.main(Manager.getName(), "You must find a more open area to play " + F.name(getName())); + invitee.sendMessage(message); + inviter.sendMessage(message); + return; + } + + board.Blocks.forEach(block -> Manager.getBlockRestore().restore(block)); + board.Ceiling.forEach(block -> MapUtil.QuickChangeBlockAt(block.getLocation(), Material.QUARTZ_BLOCK)); + board.Floor.forEach(block -> MapUtil.QuickChangeBlockAt(block.getLocation(), Material.QUARTZ_BLOCK)); + + location.setYaw(0); + + { + Location teleport = location.clone().add(0, 0, 2); + teleport.setYaw(180); + inviter.teleport(teleport); + } + { + Location teleport = location.clone().subtract(0, 0, 2); + teleport.setYaw(0); + invitee.teleport(teleport); + } + + _gameBoards.add(board); + } + + @EventHandler + public void blockInteract(PlayerInteractEvent evnet) + { + Block block = evnet.getClickedBlock(); + + if (block == null) + { + return; + } + + Player player = evnet.getPlayer(); + + for (GameBoard board : _gameBoards) + { + if (!board.AllowInteract) + { + continue; + } + + boolean playerA = board.PlayerA.equals(player); + boolean playerB = board.PlayerB.equals(player); + boolean playerATurn = board.Turn % 2 == 0; + int column = board.Floor.indexOf(block); + + if (!playerA && !playerB || column == -1) + { + continue; + } + else if (playerA && !playerATurn || playerB && playerATurn) + { + player.sendMessage(F.main(Manager.getName(), "It's not your turn.")); + continue; + } + + board.AllowInteract = false; + + Manager.runSyncTimer(new BukkitRunnable() + { + Block top = block.getRelative(0, ROWS + 1, 0); + int row = 0; + + @Override + public void run() + { + if (!isActive(board.PlayerA)) + { + cancel(); + return; + } + + if (row != 0) + { + MapUtil.QuickChangeBlockAt(top.getLocation(), Material.AIR); + } + + top = top.getRelative(BlockFace.DOWN); + Location location = top.getLocation().add(0.5, 0.5, 0.5); + + if (top.getType() != Material.AIR) + { + if (row == 0) + { + board.AllowInteract = true; + player.sendMessage(F.main("Game", "That column is full.")); + cancel(); + return; + } + + top = top.getRelative(BlockFace.UP); + location = top.getLocation().add(0.5, 0.5, 0.5); + board.OwnedTiles[--row][column] = playerATurn ? 1 : 2; + location.getWorld().playEffect(location, Effect.STEP_SOUND, playerATurn ? Material.REDSTONE_BLOCK : Material.GOLD_BLOCK); + cancel(); + + if (board.nextTurn()) + { + return; + } + } + + MapUtil.QuickChangeBlockAt(location, Material.STAINED_CLAY, (byte) (playerATurn ? 14 : 4)); + row++; + } + }, 0, 4); + } + } + + private void cleanupBoard(GameBoard board, boolean remove) + { + Recharge.Instance.use(board.PlayerA, getName(), COOLDOWN_USE, true, true); + board.Blocks.forEach(block -> + { + Manager.getBlockRestore().restore(block); + MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR); + }); + + if (remove) + { + _gameBoards.remove(board); + } + } + + @EventHandler + public void gadgetBlock(GadgetBlockEvent event) + { + for (GameBoard board : _gameBoards) + { + event.getBlocks().removeIf(board.Blocks::contains); + } + } + + private class GameBoard + { + + final Player PlayerA, PlayerB; + final int[][] OwnedTiles; + final Location TopLeft; + final List Blocks, Floor, Ceiling; + final long StartTime; + int Turn; + boolean First = true, AllowInteract; + + GameBoard(Player playerA, Player playerB, Location center) + { + PlayerA = playerA; + PlayerB = playerB; + + OwnedTiles = new int[ROWS][COLUMNS]; + for (int[] i : OwnedTiles) + { + Arrays.fill(i, 0); + } + + double xMod = Math.floor(COLUMNS / 2D), yMod = ROWS + 1; + TopLeft = center.clone().add(-xMod, ROWS, 0); + Blocks = UtilBlock.getInBoundingBox(center.clone().add(-xMod, 1, 0), center.clone().add(xMod, yMod, 0), false); + Floor = UtilBlock.getInBoundingBox(center.clone().add(-xMod, 0, 0), center.clone().add(xMod, 0, 0), false); + Ceiling = UtilBlock.getInBoundingBox(center.clone().add(-xMod, yMod, 0), center.clone().add(xMod, yMod, 0), false); + Blocks.addAll(Floor); + Blocks.addAll(Ceiling); + + StartTime = System.currentTimeMillis(); + + if (Math.random() > 0.5) + { + Turn = 1; + } + + nextTurn(); + } + + boolean nextTurn() + { + boolean playerATurn = Turn % 2 == 0; + + if (hasDrawn()) + { + drawGame(PlayerA, PlayerB); + cleanupBoard(this, true); + return true; + } + else if (hasWon(playerATurn ? 1 : 2)) + { + Player winner = playerATurn ? PlayerA : PlayerB; + Player loser = playerATurn ? PlayerB : PlayerA; + endGame(winner, loser); + Manager.runSyncLater(() -> cleanupBoard(this, true), 60); + return true; + } + else + { + Turn++; + playerATurn = !playerATurn; + } + + if (First) + { + boolean finalPlayerATurn = playerATurn; + Manager.runSyncLater(() -> informTurn(finalPlayerATurn), 20); + First = false; + } + else + { + informTurn(playerATurn); + } + + AllowInteract = true; + return false; + } + + private void informTurn(boolean playerATurn) + { + UtilTextMiddle.display("", C.cYellowB + "Your Turn", 5, 15, 5, playerATurn ? PlayerA : PlayerB); + } + + boolean hasDrawn() + { + for (int[] columns : OwnedTiles) + { + for (int column : columns) + { + if (column == 0) + { + return false; + } + } + } + + return true; + } + + boolean hasWon(int valueToCheck) + { + for (int j = 0; j < COLUMNS - 3; j++) + { + for (int i = 0; i < ROWS; i++) + { + if (OwnedTiles[i][j] == valueToCheck && OwnedTiles[i][j + 1] == valueToCheck && OwnedTiles[i][j + 2] == valueToCheck && OwnedTiles[i][j + 3] == valueToCheck) + { + return true; + } + } + } + + for (int i = 0; i < ROWS - 3; i++) + { + for (int j = 0; j < COLUMNS; j++) + { + if (OwnedTiles[i][j] == valueToCheck && OwnedTiles[i + 1][j] == valueToCheck && OwnedTiles[i + 2][j] == valueToCheck && OwnedTiles[i + 3][j] == valueToCheck) + { + return true; + } + } + } + + for (int i = 3; i < ROWS; i++) + { + for (int j = 0; j < COLUMNS - 3; j++) + { + if (OwnedTiles[i][j] == valueToCheck && OwnedTiles[i - 1][j + 1] == valueToCheck && OwnedTiles[i - 2][j + 2] == valueToCheck && OwnedTiles[i - 3][j + 3] == valueToCheck) + { + return true; + } + } + } + + for (int i = 3; i < ROWS; i++) + { + for (int j = 3; j < COLUMNS; j++) + { + if (OwnedTiles[i][j] == valueToCheck && OwnedTiles[i - 1][j - 1] == valueToCheck && OwnedTiles[i - 2][j - 2] == valueToCheck && OwnedTiles[i - 3][j - 3] == valueToCheck) + { + return true; + } + } + } + + return false; + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java index e15b66832..2576cbba4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java @@ -4,7 +4,6 @@ import org.bukkit.EntityEffect; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; -import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -64,14 +63,10 @@ public class ItemFleshHook extends ItemGadget implements IThrown Player player = (Player)data.getThrower(); - if (target == null) - return; - - if (Manager.collideEvent(player, this, target)) - return; - - if (target instanceof ArmorStand) + if (target == null || !Manager.selectEntity(this, target)) + { return; + } if (Manager.getCastleManager().isInsideCastle(target.getLocation())) return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFootball.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFootball.java deleted file mode 100644 index 06a4178ff..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFootball.java +++ /dev/null @@ -1,125 +0,0 @@ -package mineplex.core.gadget.gadgets.item; - -import java.util.HashSet; - -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftFallingSand; -import org.bukkit.entity.Bat; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerInteractEvent; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.Ammo; -import mineplex.core.gadget.types.ItemGadget; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - -public class ItemFootball extends ItemGadget -{ - private HashSet _active = new HashSet(); - - public ItemFootball(GadgetManager manager) - { - super(manager, "Football", new String[] - { - C.cWhite + "An amazing souvenier from the", - C.cWhite + "Mineplex World Cup in 2053!", - }, - -1, - Material.CLAY_BALL, (byte)3, - 1000, new Ammo("Melon Launcher", "10 Footballs", Material.CLAY_BALL, (byte)0, new String[] { C.cWhite + "10 Footballs to play with" }, 1000, 10)); - } - - @Override - public void ActivateCustom(Player player) - { - //Action - FallingBlock ball = player.getWorld().spawnFallingBlock(player.getLocation().add(0, 1, 0), Material.SKULL, (byte) 3); - - Bat bat = player.getWorld().spawn(player.getLocation(), Bat.class); - UtilEnt.vegetate(bat); - UtilEnt.ghost(bat, true, true); - UtilEnt.silence(bat, true); - - bat.setPassenger(ball); - - _active.add(bat); - - //Inform - UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(getName()) + ".")); - } - - @EventHandler - public void Collide(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - for (Bat ball : _active) - { - if (ball.getPassenger() != null) - { - ((CraftFallingSand)ball.getPassenger()).getHandle().ticksLived = 1; - ball.getPassenger().setTicksLived(1); - } - - for (Player other : UtilServer.getPlayers()) - { - if (UtilMath.offset(ball, other) > 1.5) - continue; - - if (!Recharge.Instance.use(other, getName() + " Bump", 200, false, false)) - continue; - - - double power = 0.4; - if (other.isSprinting()) - power = 0.7; - - //Velocity - UtilAction.velocity(ball, UtilAlg.getTrajectory2d(other, ball), power, false, 0, 0, 0, false); - - other.getWorld().playSound(other.getLocation(), Sound.ITEM_PICKUP, 0.2f, 0.2f); - } - } - } - - @EventHandler - public void Snort(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if (!UtilEvent.isAction(event, ActionType.L)) - return; - - for (Bat ball : _active) - { - if (UtilMath.offset(ball, player) > 2) - continue; - - if (!Recharge.Instance.use(player, getName() + " Kick", 1000, false, false)) - return; - - Recharge.Instance.useForce(player, getName() + " Bump", 1000); - - //Velocity - UtilAction.velocity(ball, UtilAlg.getTrajectory2d(player, ball), 2, false, 0, 0, 0, false); - - player.getWorld().playSound(player.getLocation(), Sound.ITEM_PICKUP, 1f, 0.1f); - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFreezeCannon.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFreezeCannon.java index 68a45639d..fd5be1981 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFreezeCannon.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFreezeCannon.java @@ -74,7 +74,7 @@ public class ItemFreezeCannon extends ItemGadget implements IThrown @Override public void Collide(LivingEntity target, Block block, ProjectileUser data) { - if (target instanceof Player) + if (target instanceof Player && Manager.selectEntity(this, target)) { Player p = (Player) target; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemLovePotion.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemLovePotion.java index f2246773c..8f2519ddc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemLovePotion.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemLovePotion.java @@ -114,19 +114,11 @@ public class ItemLovePotion extends ItemGadget return; } - if (!Recharge.Instance.usable(player, getName())) + if (!Recharge.Instance.usable(player, getName()) || !Manager.selectEntity(this, event.getRightClicked())) { UtilInv.Update(player); return; } - - GadgetCollideEntityEvent gadgetEvent = new GadgetCollideEntityEvent(player, this, event.getRightClicked()); - gadgetEvent.setCancelled(true); // Pre cancel - - Bukkit.getPluginManager().callEvent(gadgetEvent); - - if (gadgetEvent.isCancelled()) - return; Recharge.Instance.use(player, getName(), getName(), _recharge, _recharge > 1000, true, false, true, "Cosmetics"); // Cooldown diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemMelonLauncher.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemMelonLauncher.java index 67d15cb98..c56d596d3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemMelonLauncher.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemMelonLauncher.java @@ -2,13 +2,13 @@ package mineplex.core.gadget.gadgets.item; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.bukkit.Effect; import org.bukkit.EntityEffect; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; -import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; @@ -40,15 +40,16 @@ import mineplex.core.updater.event.UpdateEvent; public class ItemMelonLauncher extends ItemGadget implements IThrown { - private ArrayList _melon = new ArrayList(); - public ItemMelonLauncher(GadgetManager manager) + private final List _melon = new ArrayList<>(); + + public ItemMelonLauncher(GadgetManager manager) { - super(manager, "Melon Launcher", + super(manager, "Melon Launcher", UtilText.splitLineToArray(C.cWhite + "Because who doesn't want to shoot watermelons at people?!", LineFormat.LORE), -1, - Material.MELON_BLOCK, (byte)0, - 1000, new Ammo("Melon Launcher", "100 Melons", Material.MELON_BLOCK, (byte)0, new String[] { C.cWhite + "100 Melons for you to launch!" }, 500, 100)); + Material.MELON_BLOCK, (byte) 0, + 1000, new Ammo("Melon Launcher", "100 Melons", Material.MELON_BLOCK, (byte) 0, new String[] {C.cWhite + "100 Melons for you to launch!"}, 500, 100)); } @Override @@ -56,14 +57,10 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown { //Action Item item = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(Material.MELON_BLOCK)); - UtilAction.velocity(item, player.getLocation().getDirection(), + UtilAction.velocity(item, player.getLocation().getDirection(), 1, false, 0, 0.2, 10, false); - // Breakpoints for a sentry error - Manager - .getProjectileManager() - .AddThrow(item, player, this, -1, true, true, true, true, - null, 1f, 1f, null, null, 0, UpdateType.TICK, 0.5f); + Manager.getProjectileManager().AddThrow(item, player, this, 5000, true, true, true, true, 0.5f); //Inform UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(getName()) + ".")); @@ -77,18 +74,19 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown { if (target != null) { - if (!(target instanceof ArmorStand) && !Manager.getCastleManager().isInsideCastle(target.getLocation())) + if (!Manager.selectEntity(this, target)) { - //Push - UtilAction.velocity(target, - UtilAlg.getTrajectory2d(data.getThrown().getLocation(), target.getLocation()), - 1.4, false, 0, 0.8, 1.5, true); - - //Effect - target.playEffect(EntityEffect.HURT); + return; } + + //Push + UtilAction.velocity(target, + UtilAlg.getTrajectory2d(data.getThrown().getLocation(), target.getLocation()), + 1.4, false, 0, 0.8, 1.5, true); + + target.playEffect(EntityEffect.HURT); } - + smash(data.getThrown()); } @@ -103,27 +101,27 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown { smash(data.getThrown()); } - + @Override public void ChunkUnload(ProjectileUser data) { data.getThrown().remove(); } - + public void smash(Entity ent) - { + { //Effect ent.getWorld().playEffect(ent.getLocation(), Effect.STEP_SOUND, Material.MELON_BLOCK); - - for (int i=0 ; i<10 ; i++) + + for (int i = 0; i < 10; i++) { Item item = ent.getWorld().dropItem(ent.getLocation(), ItemStackFactory.Instance.CreateStack(Material.MELON)); item.setVelocity(new Vector(UtilMath.rr(0.5, true), UtilMath.rr(0.5, false), UtilMath.rr(0.5, true))); item.setPickupDelay(30); - + _melon.add(item); } - + //Remove ent.remove(); } @@ -152,7 +150,7 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown if (event.getType() != UpdateType.SLOW) return; - for (Iterator melonIterator = _melon.iterator(); melonIterator.hasNext();) + for (Iterator melonIterator = _melon.iterator(); melonIterator.hasNext(); ) { Item melon = melonIterator.next(); @@ -162,7 +160,7 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown melon.remove(); } } - + while (_melon.size() > 60) { Item item = _melon.remove(0); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemOAndX.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemOAndX.java index 8daf4bf35..f3d8c0e09 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemOAndX.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemOAndX.java @@ -3,9 +3,7 @@ package mineplex.core.gadget.gadgets.item; import java.time.Month; import java.time.YearMonth; import java.util.Arrays; -import java.util.HashMap; import java.util.HashSet; -import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -18,14 +16,9 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; -import mineplex.core.common.Pair; -import mineplex.core.common.jsonchat.ClickEvent; -import mineplex.core.common.jsonchat.HoverEvent; -import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; @@ -33,23 +26,19 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.ItemGadget; import mineplex.core.gadget.util.CostConstants; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -public class ItemOAndX extends ItemGadget +public class ItemOAndX extends GameItemGadget { - private static final long COOLDOWN_USE = TimeUnit.SECONDS.toMillis(30); - private static final long COOLDOWN_INVITE = TimeUnit.SECONDS.toMillis(8); - private static final String COMMAND = "/play-tic-tac-toe"; + private static final long COOLDOWN_USE = TimeUnit.SECONDS.toMillis(15); private static final int BOARD_SIZE = 9; private static final int[][] TILE_LOCATIONS = { @@ -85,23 +74,21 @@ public class ItemOAndX extends ItemGadget private static final ItemStack DEFAULT_TILE = new ItemStack(Material.WOOL, 1, (short) 0, (byte) 15); private static final long TIMEOUT = TimeUnit.MINUTES.toMillis(2); - private final Map> _invites; private final Set _gameBoards; public ItemOAndX(GadgetManager manager) { super(manager, "Tic Tac Toe", new String[] { - C.cWhite + "Play Tic Tac Toe", - C.cWhite + "with other players!", + C.cGray + "Play Tic Tac Toe", + C.cGray + "with other players!", C.blankLine, C.cWhite + "Left click the block", C.cWhite + "to claim it.", C.cWhite + "First person to get 3", C.cWhite + "in a row" - }, CostConstants.POWERPLAY_BONUS, Material.CARPET, (byte) 14, COOLDOWN_INVITE, null); + }, CostConstants.POWERPLAY_BONUS, Material.CARPET, (byte) 14, null); - _invites = new HashMap<>(3); _gameBoards = new HashSet<>(3); Free = false; @@ -123,36 +110,7 @@ public class ItemOAndX extends ItemGadget } @Override - public void ActivateCustom(Player player) - { - for (Player nearby : UtilPlayer.getNearby(player.getLocation(), 3)) - { - if (player.equals(nearby)) - { - continue; - } - - sendGameInvite(nearby, player); - return; - } - } - - private void sendGameInvite(Player invitee, Player inviter) - { - inviter.sendMessage(F.main(Manager.getName(), "You challenged " + F.name(invitee.getName()) + " to play " + F.name(getName()) + "!")); - - new JsonMessage(F.main(Manager.getName(), F.color("CLICK HERE", C.cYellowB) + " to play " + F.name(getName()) + " with " + F.name(inviter.getName()) + "!")) - .hover(HoverEvent.SHOW_TEXT, C.cYellow + "Click to play " + F.name(getName()) + " with " + F.name(inviter.getName())) - .click(ClickEvent.RUN_COMMAND, COMMAND + " " + inviter.getName()) - .sendToPlayer(invitee); - - invitee.playSound(invitee.getLocation(), Sound.NOTE_PIANO, 1, 1); - inviter.playSound(inviter.getLocation(), Sound.NOTE_PIANO, 1, 1); - - _invites.put(inviter.getName(), Pair.create(invitee.getName(), System.currentTimeMillis())); - } - - private void startGame(Player invitee, Player inviter) + protected void startGame(Player invitee, Player inviter) { Location location = inviter.getLocation(); @@ -199,40 +157,6 @@ public class ItemOAndX extends ItemGadget _gameBoards.add(new GameBoard(inviter, invitee, location.subtract(0, 1.4, 0))); } - @EventHandler - public void commandProcess(PlayerCommandPreprocessEvent event) - { - String command = event.getMessage(); - String[] split = command.split(" "); - - if (split.length != 2 || !split[0].equals(COMMAND)) - { - return; - } - - event.setCancelled(true); - - Player caller = event.getPlayer(); - String player = split[1]; - Pair pair = _invites.get(player); - - if (pair == null || !pair.getLeft().equals(caller.getName()) || UtilTime.elapsed(pair.getRight(), COOLDOWN_INVITE)) - { - return; - } - - Player inviter = UtilPlayer.searchExact(player); - - if (inviter == null) - { - caller.sendMessage(F.main(Manager.getName(), "Looks like the player who challenged you is no longer online.")); - return; - } - - _invites.remove(player); - startGame(caller, inviter); - } - @EventHandler public void armorStandInteract(EntityDamageByEntityEvent event) { @@ -424,7 +348,7 @@ public class ItemOAndX extends ItemGadget if (hasDrawn()) { - UtilTextMiddle.display(C.cRedB + "DRAW", "", 10, 30, 10, PlayerA, PlayerB); + drawGame(PlayerA, PlayerB); cleanupBoard(this, true); return; } @@ -433,10 +357,7 @@ public class ItemOAndX extends ItemGadget Player winner = playerATurn ? PlayerA : PlayerB; Player loser = playerATurn ? PlayerB : PlayerA; - UtilTextMiddle.display(C.cYellowB + "YOU WON", "", 10, 30, 10, winner); - UtilTextMiddle.display(C.cRedB + "YOU LOST", "", 10, 30, 10, loser); - winner.getWorld().playSound(winner.getLocation(), Sound.VILLAGER_YES, 1, 1); - loser.getWorld().playSound(winner.getLocation(), Sound.VILLAGER_NO, 1, 1); + endGame(winner, loser); cleanupBoard(this, true); return; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemSnowball.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemSnowball.java index 9865a4d48..c9e2cad30 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemSnowball.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemSnowball.java @@ -56,10 +56,10 @@ public class ItemSnowball extends ItemGadget if(!_snowballs.containsKey(ball)) return; - if(Manager.collideEvent(_snowballs.remove(ball), this, event.getEntity())) return; - - if (event.getEntity() instanceof ArmorStand) + if (!Manager.selectEntity(this, event.getEntity())) + { return; + } UtilAction.velocity(event.getEntity(), event.getDamager().getVelocity().normalize().add(new Vector(0,0.5,0)).multiply(0.5)); event.getDamager().getWorld().playSound(event.getDamager().getLocation(), Sound.STEP_SNOW, 1, 0.5f); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTNT.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTNT.java index 16abfccb9..7d0471071 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTNT.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTNT.java @@ -1,5 +1,16 @@ package mineplex.core.gadget.gadgets.item; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityExplodeEvent; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; @@ -16,16 +27,6 @@ import mineplex.core.gadget.gadgets.Ammo; import mineplex.core.gadget.types.ItemGadget; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityExplodeEvent; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; public class ItemTNT extends ItemGadget { @@ -57,13 +58,11 @@ public class ItemTNT extends ItemGadget return; } - Player killer = _tnt.get(event.getEntity()); - Map players = UtilPlayer.getInRadius(event.getLocation(), 8); for (Player player : players.keySet()) { - if (Manager.collideEvent(killer, this, player) || Manager.getCastleManager().isInsideCastle(player.getLocation())) + if (!Manager.selectEntity(this, player) || Manager.getCastleManager().isInsideCastle(player.getLocation())) { continue; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTrampoline.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTrampoline.java new file mode 100644 index 000000000..7947a3a8d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTrampoline.java @@ -0,0 +1,91 @@ +package mineplex.core.gadget.gadgets.item; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ItemGadget; +import mineplex.core.gadget.util.CostConstants; + +public class ItemTrampoline extends ItemGadget +{ + + private static final long DURATION = TimeUnit.SECONDS.toMillis(20); + + public ItemTrampoline(GadgetManager manager) + { + super(manager, "Trampoline", new String[] + { + C.cGray + "Create a trampoline for all", + C.cGray + "of your bouncing needs", + C.blankLine, + C.cWhite + "Sneak to go higher!" + }, CostConstants.NO_LORE, Material.SLIME_BLOCK, (byte) 0, TimeUnit.SECONDS.toMillis(30), null); + } + + @Override + public void ActivateCustom(Player player) + { + Block block = player.getLocation().getBlock(); + List blocks = new ArrayList<>(UtilBlock.getSurrounding(block, true)); + blocks.add(block); + + Manager.selectBlocks(this, blocks); + + for (Block nearby : blocks) + { + if (nearby.getY() != block.getY()) + { + continue; + } + + Manager.getBlockRestore().add(nearby, Material.SLIME_BLOCK.getId(), getDisplayData(), DURATION); + } + + player.teleport(player.getLocation().add(0, 1, 0)); + + Location location = block.getLocation().add(0.5, 1.25, 0.5); + + Manager.runSyncTimer(new BukkitRunnable() + { + long iterations = DURATION / 50 / 10; + + @Override + public void run() + { + for (Player nearby : block.getWorld().getPlayers()) + { + double y = nearby.getVelocity().getY(); + + if (y < 0.2 && y > -0.2 && blocks.contains(nearby.getLocation().getBlock().getRelative(BlockFace.DOWN))) + { + nearby.getWorld().playSound(nearby.getLocation(), Sound.FIREWORK_LAUNCH, 2, 1); + UtilAction.velocity(nearby, 0.1, 3, 4, true); + } + } + + UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, location, 1, 0.5F, 1, 0, 5, ViewDist.NORMAL); + + if (--iterations == 0) + { + cancel(); + } + } + }, 2, 10); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/BlockForm.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/BlockForm.java index 2b1c13ea3..10206098e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/BlockForm.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/BlockForm.java @@ -1,14 +1,10 @@ package mineplex.core.gadget.gadgets.morph; -import java.util.ArrayList; -import java.util.List; - import net.minecraft.server.v1_8_R3.Entity; import net.minecraft.server.v1_8_R3.EntityArmorStand; import net.minecraft.server.v1_8_R3.EntityPlayer; import net.minecraft.server.v1_8_R3.IBlockData; -import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; @@ -30,7 +26,6 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguiseBlock; import mineplex.core.disguise.disguises.DisguiseSlime; -import mineplex.core.gadget.event.GadgetBlockEvent; import mineplex.core.itemstack.ItemStackFactory; public class BlockForm @@ -190,16 +185,8 @@ public class BlockForm { Block block = _player.getLocation().getBlock(); - List blockList = new ArrayList<>(); - blockList.add(block); - - GadgetBlockEvent event = new GadgetBlockEvent(_host, blockList); - - Bukkit.getServer().getPluginManager().callEvent(event); - // Not Able - if (block.getType() != Material.AIR || !UtilBlock.solid(block.getRelative(BlockFace.DOWN)) - || event.getBlocks().isEmpty() || event.isCancelled()) + if (block.getType() != Material.AIR || !UtilBlock.solid(block.getRelative(BlockFace.DOWN)) || !_host.Manager.selectBlocks(_host, block)) { UtilPlayer.message(_player, F.main("Morph", "You cannot become a Solid Block here.")); _player.setExp(0f); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphAbilityGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphAbilityGadget.java new file mode 100644 index 000000000..8ed240dc5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphAbilityGadget.java @@ -0,0 +1,81 @@ +package mineplex.core.gadget.gadgets.morph; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.recharge.Recharge; + +public abstract class MorphAbilityGadget extends MorphGadget +{ + + private static final int ACTIVE_SLOT = 2; + + private final ItemStack _abilityItem; + private final String _abilityName; + private final long _recharge; + + public MorphAbilityGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, ItemStack abilityItem, String abilityName, long recharge) + { + super(manager, name, desc, cost, mat, data); + + _abilityName = abilityName; + _abilityItem = abilityItem; + _recharge = recharge; + } + + @Override + public void applyArmor(Player player, boolean message) + { + super.applyArmor(player, message); + + player.getInventory().setItem(ACTIVE_SLOT, _abilityItem); + } + + @Override + public void removeArmor(Player player) + { + super.removeArmor(player); + + player.getInventory().setItem(ACTIVE_SLOT, null); + } + + public abstract void onAbilityActivate(Player player); + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (event.getAction() == Action.PHYSICAL) + { + return; + } + + Player player = event.getPlayer(); + ItemStack itemStack = event.getItem(); + + if (!isActive(player) || itemStack == null || !itemStack.equals(_abilityItem)) + { + return; + } + + event.setCancelled(true); + + if (!Manager.selectLocation(this, player.getLocation())) + { + Manager.informNoUse(player); + return; + } + + if (!Recharge.Instance.use(player, _abilityName, _recharge, true, true, "Cosmetics")) + { + return; + } + + onAbilityActivate(player); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java index 880f8f3a1..3ea766e4a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBobRoss.java @@ -9,26 +9,12 @@ import java.util.Map; import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; -import mineplex.core.common.util.C; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilText; -import mineplex.core.hologram.Hologram; -import mineplex.core.hologram.HologramManager; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.recharge.Recharge; -import mineplex.core.treasure.event.TreasureFinishEvent; -import mineplex.core.treasure.event.TreasureStartEvent; import org.bukkit.Bukkit; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -37,10 +23,20 @@ import org.bukkit.inventory.ItemStack; import com.mojang.authlib.GameProfile; import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.HologramManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilGameProfile; @@ -198,9 +194,6 @@ public class MorphBobRoss extends MorphGadget /** Colors that are being used by painting players */ private final Map _paintColors = new HashMap<>(); - /** Locations at which treasure is currently being opened */ - private final Map _openingTreasure = new HashMap<>(); - private final HologramManager _holograms; public MorphBobRoss(GadgetManager manager, HologramManager holograms) @@ -374,14 +367,6 @@ public class MorphBobRoss extends MorphGadget return; } - for (Location location : _openingTreasure.values()) - { - if (location.toVector().isInSphere(event.getPlayer().getLocation().toVector(), TREASURE_RADIUS)) - { - return; - } - } - // check if the player has been issued a paintbrush if (_inventoryItems.containsKey(player.getUniqueId())) { @@ -401,7 +386,7 @@ public class MorphBobRoss extends MorphGadget if ((block.isEmpty() || carpet) && UtilBlock.fullSolid(down) && !UtilBlock.bottomSlab(down)) { // if the block is a non-paint carpet - if (carpet && !Manager.getBlockRestore().contains(block)) + if (carpet && !Manager.getBlockRestore().contains(block) || !Manager.selectBlocks(this, block)) { return; // don't paint } @@ -561,26 +546,4 @@ public class MorphBobRoss extends MorphGadget player.updateInventory(); } } - - /** - * Disable painting in the area around treasure being opened. - */ - @EventHandler(priority = EventPriority.LOW) - public void disableOnTreasureStart(TreasureStartEvent event) - { - _openingTreasure.put(event.getPlayer().getUniqueId(), event.getPlayer().getLocation()); - Manager.getBlockRestore().restoreBlockAround(Material.CARPET, event.getPlayer().getLocation(), TREASURE_RADIUS); - } - - /** - * Enable painting in the area around treasure no longer being opened. - */ - @EventHandler(priority = EventPriority.HIGH) - public void enableOnTreasureFinish(TreasureFinishEvent event) - { - if (_openingTreasure.containsKey(event.getPlayer().getUniqueId())) - { - _openingTreasure.remove(event.getPlayer().getUniqueId()); - } - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java index ef51b27f4..abfe038d1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphBunny.java @@ -10,6 +10,7 @@ import org.bukkit.Color; import org.bukkit.FireworkEffect.Type; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -62,7 +63,7 @@ public class MorphBunny extends MorphGadget "#" + C.cRed + C.Bold + "WARNING: " + ChatColor.RESET + "Hide Easter Egg uses 500 Shards", }, LineFormat.LORE), -5, - Material.MONSTER_EGG, (byte) 98); + Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.RABBIT)); } @Override @@ -163,8 +164,7 @@ public class MorphBunny extends MorphGadget //Item - ItemStack eggStack = ItemStackFactory.Instance.CreateStack(Material.MONSTER_EGG, (byte) 0, 1, "Hidden Egg" + System.currentTimeMillis()); - eggStack.setDurability((short) 98); + ItemStack eggStack = ItemStackFactory.Instance.CreateStack(getDisplayMaterial(), getDisplayData(), 1, "Hidden Egg" + System.currentTimeMillis()); Item egg = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), eggStack); UtilAction.velocity(egg, player.getLocation().getDirection(), 0.2, false, 0, 0.2, 1, false); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChristmasKing.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChristmasKing.java index 934ef1238..7e54ab4b8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChristmasKing.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphChristmasKing.java @@ -37,8 +37,8 @@ import mineplex.core.updater.event.UpdateEvent; public class MorphChristmasKing extends MorphGadget { - private Map _snowball = new WeakHashMap<>(); - + private final Map _snowball = new WeakHashMap<>(); + public MorphChristmasKing(GadgetManager manager) { super(manager, "Christmas Kings Head", UtilText.splitLinesToArray(new String[] @@ -155,12 +155,11 @@ public class MorphChristmasKing extends MorphGadget Snowball proj = (Snowball) event.getDamager(); - if (!_snowball.containsKey(proj)) + if (_snowball.remove(proj) == null || !Manager.selectEntity(this, event.getEntity())) + { return; - - if (Manager.collideEvent(_snowball.remove(proj), this, event.getEntity())) - return; - + } + UtilAction.velocity(event.getEntity(), proj.getVelocity().multiply(0.15).add(new Vector(0, 0.15, 0))); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java index 1dffb0098..b6b57b43c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphCreeper.java @@ -107,11 +107,10 @@ public class MorphCreeper extends MorphGadget HashMap players = UtilPlayer.getInRadius(player.getLocation(), 8); for (Player other : players.keySet()) { - if (other.equals(player)) - continue; - - if (Manager.collideEvent(player, this, other)) + if (other.equals(player) || !Manager.selectEntity(this, other)) + { continue; + } double mult = players.get(other); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFreedomFighter.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFreedomFighter.java index c995e2b9b..dc39baf7f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFreedomFighter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFreedomFighter.java @@ -1,6 +1,24 @@ package mineplex.core.gadget.gadgets.morph; +import java.time.Month; +import java.time.YearMonth; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.World; +import org.bukkit.block.Banner; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + import com.mojang.authlib.GameProfile; + import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; @@ -19,23 +37,6 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilGameProfile; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.World; -import org.bukkit.block.Banner; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -import java.time.Month; -import java.time.YearMonth; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ThreadLocalRandom; /** * Freedom fighter morph, capable of planting flags by crouching. @@ -90,7 +91,6 @@ public class MorphFreedomFighter extends MorphGadget DisguisePlayer disguisePlayer = new DisguisePlayer(player, profile); disguisePlayer.showInTabList(true, 0); UtilMorph.disguise(player, disguisePlayer, Manager); - } /** @@ -114,17 +114,7 @@ public class MorphFreedomFighter extends MorphGadget // Clear cooldown timers if (event.getType() == UpdateType.SEC) { - Iterator> itr = _flagCooldowns.entrySet().iterator(); - - while (itr.hasNext()) - { - Map.Entry entry = itr.next(); - - if (entry.getValue() + FLAG_COOLDOWN < System.currentTimeMillis()) - { - itr.remove(); - } - } + _flagCooldowns.entrySet().removeIf(entry -> entry.getValue() + FLAG_COOLDOWN < System.currentTimeMillis()); } // For all active cosmetics @@ -145,22 +135,7 @@ public class MorphFreedomFighter extends MorphGadget // If the players has waiting long enough to place the flag if (_flagTimers.get(uuid) + FLAG_DELAY < System.currentTimeMillis()) { - boolean flag = false; - Location location = player.getLocation().subtract(0, 0.5, 0); - - // Make sure the ground is flat enough to place the flag - for (int i = 0; i < BEACON_BASE.length; ++i) - { - Block b = location.clone().add(BEACON_BASE[i][0], 0, BEACON_BASE[i][2]).getBlock(); - - if (b.isEmpty()) - { - flag = true; - break; - } - } - - if (flag) + if (!Manager.selectLocation(this, player.getLocation())) { _flagTimers.remove(uuid); player.sendMessage(F.main("Morphs", C.cRed + "You must plant your flag on flatter ground.")); @@ -255,9 +230,9 @@ public class MorphFreedomFighter extends MorphGadget restore.add(point.getBlock().getRelative(BlockFace.DOWN), Material.BEACON.getId(), (byte) 0, FLAG_COOLDOWN); - for (int i = 0; i < BEACON_BASE.length; ++i) + for (int[] beaconBase : BEACON_BASE) { - restore.add(world.getBlockAt(point.clone().add(BEACON_BASE[i][0], BEACON_BASE[i][1], BEACON_BASE[i][2])), + restore.add(world.getBlockAt(point.clone().add(beaconBase[0], beaconBase[1], beaconBase[2])), Material.IRON_BLOCK.getId(), (byte) 0, FLAG_COOLDOWN); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFrostGolem.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFrostGolem.java index 3b2de18e1..9eec68b8f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFrostGolem.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphFrostGolem.java @@ -7,6 +7,7 @@ import java.util.concurrent.TimeUnit; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -110,7 +111,11 @@ public class MorphFrostGolem extends MorphGadget player.teleport(location.add(0, 1, 0)); _ability.put(location.clone().add(0, 3, 0), System.currentTimeMillis()); - UtilBlock.getInRadius(location, RADIUS).forEach((block, scale) -> + Map blocks = UtilBlock.getInRadius(location, RADIUS); + + Manager.selectBlocks(this, blocks.keySet()); + + blocks.forEach((block, scale) -> { if (block.getType() != Material.AIR || block.getRelative(BlockFace.DOWN).getType() == Material.AIR) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGhast.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGhast.java index 4ee85246a..4b9e5be23 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGhast.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGhast.java @@ -5,6 +5,7 @@ import java.time.YearMonth; import java.util.HashSet; import java.util.Set; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.LargeFireball; @@ -148,12 +149,17 @@ public class MorphGhast extends MorphGadget return; } - for (Player player : UtilPlayer.getNearby(event.getEntity().getLocation(), 5)) + Location location = event.getEntity().getLocation(); + + for (Player player : UtilPlayer.getNearby(location, 5)) { - player.setVelocity(UP); + if (Manager.selectEntity(this, player)) + { + player.setVelocity(UP); + } } - UtilParticle.PlayParticleToAll(ParticleType.LAVA, event.getEntity().getLocation().add(0, 0.8, 0), 0.5F, 0.5F, 0.5F, 0.01F, 6, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.LAVA, location.add(0, 0.8, 0), 0.5F, 0.5F, 0.5F, 0.01F, 6, ViewDist.NORMAL); event.getEntity().remove(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGoldPot.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGoldPot.java index 90a046239..4f13f2c91 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGoldPot.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGoldPot.java @@ -72,7 +72,8 @@ public class MorphGoldPot extends MorphGadget @EventHandler public void onUpdate(UpdateEvent event) - { for (GoldPotHelper goldPotHelper : _helpers.values()) + { + for (GoldPotHelper goldPotHelper : _helpers.values()) { boolean solid = goldPotHelper.updatePlayer(event.getType() == UpdateType.SEC, event.getType() == UpdateType.TICK); if (solid) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGrimReaper.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGrimReaper.java index 44c761772..a43f3d903 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGrimReaper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphGrimReaper.java @@ -42,16 +42,16 @@ import mineplex.core.updater.event.UpdateEvent; public class MorphGrimReaper extends MorphGadget { - private Map _flying = new HashMap<>(); - private List _flyReady = new ArrayList<>(); + private final Map _flying = new HashMap<>(); + private final List _flyReady = new ArrayList<>(); - private SoulManager _soulManager; + private final SoulManager _soulManager; private ItemStack _hoe; private static final int FLY_DELAY = 15000; - private ShapeWings _wings = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0.2,0.2,0.2), 1, 0, false, ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_ANGEL_WING_PATTERN); - private ShapeWings _wingsEdge = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0.1,0.1,0.1), 1, 0, true, ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_ANGEL_WING_PATTERN); + private final ShapeWings _wings = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0.2,0.2,0.2), 1, 0, false, ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_ANGEL_WING_PATTERN); + private final ShapeWings _wingsEdge = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0.1,0.1,0.1), 1, 0, true, ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_ANGEL_WING_PATTERN); public MorphGrimReaper(GadgetManager manager) { @@ -178,7 +178,8 @@ public class MorphGrimReaper extends MorphGadget setFlying(player, true, event.getType()==UpdateType.FAST); } } - stopFlying.forEach(p -> _flying.remove(p)); + + stopFlying.forEach(_flying::remove); if (event.getType() != UpdateType.SEC) return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphLoveDoctor.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphLoveDoctor.java index 1a96f75d1..dc5f8f7a9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphLoveDoctor.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphLoveDoctor.java @@ -73,19 +73,12 @@ public class MorphLoveDoctor extends MorphGadget ignore.add(Material.AIR); Location loc = player.getTargetBlock(ignore, 64).getLocation().add(0.5, 0.5, 0.5); - GadgetSelectLocationEvent gadgetSelectLocationEvent = new GadgetSelectLocationEvent(player, this, loc); - Bukkit.getServer().getPluginManager().callEvent(gadgetSelectLocationEvent); - - // Checks to see if it's a valid location - if (gadgetSelectLocationEvent.isCancelled()) + if (!Manager.selectLocation(this, loc)) { - if (gadgetSelectLocationEvent.canShowMessage()) - { - UtilPlayer.message(player, F.main("Gadget", "You cannot use the laser on this area!")); - } - + Manager.informNoUse(player); return; } + LoveDoctorEffect loveDoctorEffect = new LoveDoctorEffect(player, loc, this); loveDoctorEffect.start(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java index b558dee67..c0f7cfadf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMelonHead.java @@ -1,18 +1,12 @@ package mineplex.core.gadget.gadgets.morph; -import com.mojang.authlib.GameProfile; -import mineplex.core.common.skin.SkinData; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilText; -import mineplex.core.disguise.disguises.DisguisePlayer; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; -import mineplex.core.gadget.types.MorphGadget; -import mineplex.core.utils.UtilGameProfile; -import org.apache.commons.lang3.tuple.Pair; +import java.time.Month; +import java.time.YearMonth; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -24,13 +18,21 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; -import java.time.Month; -import java.time.YearMonth; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ThreadLocalRandom; +import com.mojang.authlib.GameProfile; + +import mineplex.core.common.Pair; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.utils.UtilGameProfile; /** * PPC Reward for month of August 2017. Allows users to turn other player's heads into various fruits. @@ -39,13 +41,13 @@ public class MorphMelonHead extends MorphGadget { /** Fruit head texture options */ private static final Pair[] TEXTURES = { - Pair.of(SkinData.APPLE, C.cDRedB + "Apple Head"), - Pair.of(SkinData.MELON, C.cDGreenB + "Melon Head"), - Pair.of(SkinData.ORANGE, C.cGoldB + "Orange Head"), - Pair.of(SkinData.STRAWBERRY, C.cRedB + "Berry Head"), - Pair.of(SkinData.PINEAPPLE, C.cYellowB + "Pineapple Head"), - Pair.of(SkinData.GREEN_APPLE, C.cGreenB + "Apple Head"), - Pair.of(SkinData.PLUM, C.cPurpleB + "Plum Head") + Pair.create(SkinData.APPLE, C.cDRedB + "Apple Head"), + Pair.create(SkinData.MELON, C.cDGreenB + "Melon Head"), + Pair.create(SkinData.ORANGE, C.cGoldB + "Orange Head"), + Pair.create(SkinData.STRAWBERRY, C.cRedB + "Berry Head"), + Pair.create(SkinData.PINEAPPLE, C.cYellowB + "Pineapple Head"), + Pair.create(SkinData.GREEN_APPLE, C.cGreenB + "Apple Head"), + Pair.create(SkinData.PLUM, C.cPurpleB + "Plum Head") }; /** Ticks that a fruit head change lasts */ @@ -122,7 +124,7 @@ public class MorphMelonHead extends MorphGadget } // select a head skin and name it - Pair data = TEXTURES[ThreadLocalRandom.current().nextInt(TEXTURES.length)]; + Pair data = UtilMath.randomElement(TEXTURES); ItemStack head = data.getLeft().getSkull(data.getRight(), new ArrayList<>()); // equip the head and notify the player of the action diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java index 06838168e..07d16cdab 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java @@ -122,17 +122,9 @@ public class MorphMetalMan extends MorphGadget ignore.add(Material.AIR); Location loc = player.getTargetBlock(ignore, 64).getLocation().add(0.5, 0.5, 0.5); - GadgetSelectLocationEvent gadgetSelectLocationEvent = new GadgetSelectLocationEvent(player, this, loc); - Bukkit.getServer().getPluginManager().callEvent(gadgetSelectLocationEvent); - - // Checks to see if it's a valid location - if (gadgetSelectLocationEvent.isCancelled()) + if (!Manager.selectLocation(this, loc)) { - if (gadgetSelectLocationEvent.canShowMessage()) - { - UtilPlayer.message(player, F.main("Gadget", "You cannot use the laser on this area!")); - } - + Manager.informNoUse(player); return; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphOcelot.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphOcelot.java new file mode 100644 index 000000000..e2d644505 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphOcelot.java @@ -0,0 +1,49 @@ +package mineplex.core.gadget.gadgets.morph; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.disguise.disguises.DisguiseCat; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.gadget.util.CostConstants; + +public class MorphOcelot extends MorphGadget +{ + + private static final PotionEffect POTION_EFFECT = new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1, false, false); + + public MorphOcelot(GadgetManager manager) + { + super(manager, "Ocelot Morph", new String[] + { + C.cGray + "Meeeeeeeeeeoooooooowwwwww", + }, CostConstants.LEVEL_REWARDS, Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.OCELOT)); + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + DisguiseCat disguise = new DisguiseCat(player); + UtilMorph.disguise(player, disguise, Manager); + + player.addPotionEffect(POTION_EFFECT); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + player.removePotionEffect(PotionEffectType.SPEED); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java index 913c26fb2..2841a7875 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPig.java @@ -8,7 +8,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerToggleFlightEvent; import mineplex.core.common.util.C; @@ -30,20 +29,20 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; public class MorphPig extends MorphGadget -{ +{ private HashSet _double = new HashSet(); - + public MorphPig(GadgetManager manager) { - super(manager, "Pig Morph", UtilText.splitLinesToArray(new String[] - { - C.cGray + "Oink. Oink. Oink.... Oink?", - C.blankLine, - "#" + C.cWhite + "Left Click to use Oink", - "#" + C.cWhite + "Collide to use Pig Bounce", - }, LineFormat.LORE), + super(manager, "Pig Morph", UtilText.splitLinesToArray(new String[] + { + C.cGray + "Oink. Oink. Oink.... Oink?", + C.blankLine, + "#" + C.cWhite + "Left Click to use Oink", + "#" + C.cWhite + "Collide to use Pig Bounce", + }, LineFormat.LORE), -10, - Material.PORK, (byte)0); + Material.PORK, (byte) 0); } @Override @@ -60,6 +59,7 @@ public class MorphPig extends MorphGadget { this.removeArmor(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); + _double.remove(player); } @EventHandler @@ -72,36 +72,36 @@ public class MorphPig extends MorphGadget if (!UtilEvent.isAction(event, ActionType.L)) return; - + if (!Recharge.Instance.use(player, getName(), 400, false, false, "Cosmetics")) return; - - player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, 1f, (float)(0.75 + Math.random() * 0.5)); - + + player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, 1f, (float) (0.75 + Math.random() * 0.5)); + } - + @EventHandler public void UltraOwner(PlayerJoinEvent event) { if (Manager.getClientManager().Get(event.getPlayer()).hasPermission(GadgetManager.Perm.ULTRA_MORPH)) { Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); - } + } } - + @EventHandler public void Collide(PlayerToggleFlightEvent event) { _double.add(event.getPlayer()); Recharge.Instance.useForce(event.getPlayer(), getName() + " Double Jump", 200); } - + @EventHandler public void Collide(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; - + for (Player player : getActive()) { //Grounded @@ -109,39 +109,41 @@ public class MorphPig extends MorphGadget if (UtilEnt.isGrounded(player)) if (Recharge.Instance.usable(player, getName() + " Double Jump")) _double.remove(player); - + double range = 1; - + if (_double.contains(player)) range += 0.5; - + if (player.getVehicle() != null) continue; - + if (!Recharge.Instance.usable(player, getName() + " Collide")) continue; - + for (Player other : UtilServer.getPlayers()) { if (other.equals(player)) continue; - + if (other.getVehicle() != null) continue; - + if (!Recharge.Instance.usable(other, getName() + " Collide")) continue; if (UtilMath.offset(player, other) > range) continue; - - if (Manager.collideEvent(player, this, other)) - continue; - + + if (!Manager.selectEntity(this, other)) + { + continue; + } + //Cooldown Recharge.Instance.useForce(other, getName() + " Collide", 200); Recharge.Instance.useForce(player, getName() + " Collide", 200); - + double power = 0.4; double height = 0.1; if (player.isSprinting()) @@ -149,34 +151,28 @@ public class MorphPig extends MorphGadget power = 0.6; height = 0.2; } - + if (_double.contains(player)) { power = 1; height = 0.3; } - - + + //Velocity UtilAction.velocity(player, UtilAlg.getTrajectory2d(other, player), power, false, 0, height, 1, true); UtilAction.velocity(other, UtilAlg.getTrajectory2d(player, other), power, false, 0, height, 1, true); - + //Sound if (_double.contains(player)) { - player.getWorld().playSound(player.getLocation(), Sound.PIG_DEATH, (float)(0.8 + Math.random() * 0.4), (float)(0.8 + Math.random() * 0.4)); + player.getWorld().playSound(player.getLocation(), Sound.PIG_DEATH, (float) (0.8 + Math.random() * 0.4), (float) (0.8 + Math.random() * 0.4)); } else { - player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, 1f, (float)(1.5 + Math.random() * 0.5)); + player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, 1f, (float) (1.5 + Math.random() * 0.5)); } } } } - - @EventHandler - public void Clean(PlayerQuitEvent event) - { - _double.remove(event.getPlayer()); - } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java index c161f84ee..be3ef9d22 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java @@ -118,7 +118,7 @@ public class MorphPumpkinKing extends MorphGadget implements IPacketHandler } } - _bombs.removeIf(bomb -> bomb.update()); + _bombs.removeIf(JackOBomb::update); } } @@ -174,9 +174,11 @@ public class MorphPumpkinKing extends MorphGadget implements IPacketHandler Map players = UtilPlayer.getInRadius(_ent.getLocation(), 8); for (Player player : players.keySet()) { - if (Manager.collideEvent(_user, MorphPumpkinKing.this, player)) + if (!Manager.selectEntity(MorphPumpkinKing.this, player)) + { continue; - + } + double mult = players.get(player); //Knockback diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSkeleton.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSkeleton.java new file mode 100644 index 000000000..87fdb2bb1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSkeleton.java @@ -0,0 +1,74 @@ +package mineplex.core.gadget.gadgets.morph; + +import java.util.concurrent.TimeUnit; + +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; + +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguiseSkeleton; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.util.CostConstants; +import mineplex.core.itemstack.ItemBuilder; + +public class MorphSkeleton extends MorphAbilityGadget +{ + + private static final ItemStack ACTIVE_ITEM = new ItemBuilder(Material.BOW) + .setTitle(C.cGreenB + "Arrow Storm") + .addLore("Clicking this fires out lots of high powered arrows!") + .setUnbreakable(true) + .build(); + + public MorphSkeleton(GadgetManager manager) + { + super(manager, "Skeleton Morph", new String[] + { + C.cGray + "I have a bone to pick with you", + C.blankLine, + C.cGreen + "Shoot" + C.cWhite + " your " + C.cYellow + "Bow" + C.cWhite + " to fire", + C.cGreen + "Arrow Storm" + }, CostConstants.FOUND_IN_TREASURE_CHESTS, Material.SKULL_ITEM, (byte) 0, ACTIVE_ITEM, "Arrow Storm", TimeUnit.SECONDS.toMillis(8)); + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + DisguiseSkeleton disguise = new DisguiseSkeleton(player); + UtilMorph.disguise(player, disguise, Manager); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + } + @Override + public void onAbilityActivate(Player player) + { + Manager.runSyncTimer(new BukkitRunnable() + { + int arrows = 0; + + @Override + public void run() + { + if (arrows++ == 10) + { + cancel(); + return; + } + + player.launchProjectile(Arrow.class); + } + }, 0, 2); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java index 25326feff..d41e30412 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSnowman.java @@ -1,5 +1,6 @@ package mineplex.core.gadget.gadgets.morph; +import java.util.Map; import java.util.WeakHashMap; import org.bukkit.Material; @@ -36,22 +37,22 @@ import mineplex.core.updater.event.UpdateEvent; public class MorphSnowman extends MorphGadget { - - private WeakHashMap _snowball = new WeakHashMap(); + + private final Map _snowball = new WeakHashMap<>(); public MorphSnowman(GadgetManager manager) { super(manager, "Olaf Morph", - UtilText.splitLinesToArray(new String[] - { - C.cGray + "Do you wanna build a snowman?", - C.cGray + "It doesn't have to be a snowman...", - C.cGray + "Or... it kind of does...", - C.blankLine, - "#" + C.cWhite + "Left-Click to use Blizzard", - "#" + C.cWhite + "Sneak to use Snow Slide", - }, LineFormat.LORE), - -3, Material.SNOW_BALL, (byte) 0); + UtilText.splitLinesToArray(new String[] + { + C.cGray + "Do you wanna build a snowman?", + C.cGray + "It doesn't have to be a snowman...", + C.cGray + "Or... it kind of does...", + C.blankLine, + "#" + C.cWhite + "Left-Click to use Blizzard", + "#" + C.cWhite + "Sneak to use Snow Slide", + }, LineFormat.LORE), + -3, Material.SNOW_BALL, (byte) 0); } @Override @@ -69,58 +70,58 @@ public class MorphSnowman extends MorphGadget this.removeArmor(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); } - + @EventHandler public void onInteract(PlayerInteractEvent event) { - if(!isActive(event.getPlayer())) return; - - if(!UtilEvent.isAction(event, ActionType.L)) return; - - if(event.getItem() != null && event.getItem().getType() != Material.AIR) return; - - if(Recharge.Instance.use(event.getPlayer(), "Blizzard", 12000, true, true)) + if (!isActive(event.getPlayer())) return; + + if (!UtilEvent.isAction(event, ActionType.L)) return; + + if (event.getItem() != null && event.getItem().getType() != Material.AIR) return; + + if (Recharge.Instance.use(event.getPlayer(), "Blizzard", 12000, true, true)) { event.getPlayer().sendMessage(F.main("Recharge", "You used " + F.skill("Blizzard") + ".")); } } - + @EventHandler - public void Snow(UpdateEvent event) - { + public void Snow(UpdateEvent event) + { if (event.getType() == UpdateType.FASTEST) { for (Player player : getActive()) { NautHashMap map = Recharge.Instance.Get(player); - if(map == null) continue; - + if (map == null) continue; + RechargeData data = map.get("Blizzard"); - if(data == null) continue; - if(data.GetRemaining() < 10000) continue; - - for (int i=0 ; i<4 ; i++) + if (data == null) continue; + if (data.GetRemaining() < 10000) continue; + + for (int i = 0; i < 4; i++) { Snowball snow = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), Snowball.class); - double x = 0.1 - (UtilMath.r(20)/100d); - double y = UtilMath.r(20)/100d; - double z = 0.1 - (UtilMath.r(20)/100d); + double x = 0.1 - (UtilMath.r(20) / 100d); + double y = UtilMath.r(20) / 100d; + double z = 0.1 - (UtilMath.r(20) / 100d); snow.setShooter(player); - snow.setVelocity(player.getLocation().getDirection().add(new Vector(x,y,z)).multiply(2)); + snow.setVelocity(player.getLocation().getDirection().add(new Vector(x, y, z)).multiply(2)); _snowball.put(snow, player); } - + //Effect player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 0.2f, 0.5f); } } - - if(event.getType() == UpdateType.TICK) + + if (event.getType() == UpdateType.TICK) { for (Player player : getActive()) { - if(player.isSneaking() && UtilEnt.isGrounded(player)) + if (player.isSneaking() && UtilEnt.isGrounded(player)) { player.setVelocity(player.getLocation().getDirection().setY(0).normalize()); UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, player.getLocation(), 0.3f, 0.1f, 0.3f, 0, 10, ViewDist.NORMAL); @@ -135,16 +136,16 @@ public class MorphSnowman extends MorphGadget { if (!(event.getDamager() instanceof Snowball)) return; - + Snowball proj = (Snowball) event.getDamager(); - if (!_snowball.containsKey(proj)) + if (_snowball.remove(proj) == null || Manager.selectEntity(this, event.getEntity())) + { return; - - if(Manager.collideEvent(_snowball.remove(proj), this, event.getEntity())) return; - + } + UtilAction.velocity(event.getEntity(), proj.getVelocity().multiply(0.15).add(new Vector(0, 0.15, 0))); } - + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphStray.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphStray.java deleted file mode 100644 index 8a6571d36..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphStray.java +++ /dev/null @@ -1,128 +0,0 @@ -package mineplex.core.gadget.gadgets.morph; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilText; -import mineplex.core.disguise.disguises.DisguiseSquid; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; -import mineplex.core.gadget.types.MorphGadget; -import mineplex.core.itemstack.ItemStackFactory; - -/** - * THIS MORPH IS 1.9+ ONLY - */ -public class MorphStray extends MorphGadget -{ - - private List _strayArrows = new ArrayList<>(); - private ItemStack _arrow; - - public MorphStray(GadgetManager manager) - { - super(manager, "Stray Morph", UtilText.splitLinesToArray(new String[]{ - C.cGray + "Even though it's a stray your mom probably won't let you keep this puppy.", - "", - C.cWhite + "Gains an arrow every 5 seconds with EXTREME knockback." - }, LineFormat.LORE), - 0, Material.BARRIER, (byte) 0); - _arrow = ItemStackFactory.Instance.CreateStack(Material.ARROW, (byte) 0, 1, C.cGreen + "Stray Arrow", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE)); - } - - @Override - public void enableCustom(Player player, boolean message) - { - // TODO CHECK IF LOBBY IS 1.9+ - applyArmor(player, message); - DisguiseSquid disguiseSquid = new DisguiseSquid(player); - UtilMorph.disguise(player, disguiseSquid, Manager); - - // Gives bow and arrow - ItemStack bow = ItemStackFactory.Instance.CreateStack(Material.BOW, (byte) 0, 1, C.cGreen + "Stray Bow", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE)); - player.getInventory().setItem(2, bow); - player.getInventory().setItem(17, _arrow); - } - - @Override - public void disableCustom(Player player, boolean message) - { - removeArmor(player); - UtilMorph.undisguise(player, Manager.getDisguiseManager()); - - // Removes bow and arrow - player.getInventory().setItem(2, new ItemStack(Material.AIR)); - player.getInventory().setItem(17, new ItemStack(Material.AIR)); - } - - @EventHandler - public void onShoot(EntityShootBowEvent event) - { - if (!(event.getEntity() instanceof Player)) - return; - - if (!(event.getProjectile() instanceof Arrow)) - return; - - Player player = (Player) event.getEntity(); - - if (!isActive(player)) - return; - - _strayArrows.add((Arrow) event.getProjectile()); - - Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() - { - @Override - public void run() - { - player.getInventory().setItem(17, _arrow); - } - }, 3 * 20L); - } - - @EventHandler - public void onArrowHitPlayer(EntityDamageByEntityEvent event) - { - if (!(event.getDamager() instanceof Arrow)) - return; - - if (!(event.getEntity() instanceof Player)) - return; - - if (!(((Arrow) event.getDamager()).getShooter() instanceof Player)) - return; - - Arrow arrow = (Arrow) event.getDamager(); - Player player = (Player) event.getEntity(); - - if (!_strayArrows.contains(arrow)) - return; - - _strayArrows.remove(arrow); - - Player shooter = (Player) arrow.getShooter(); - arrow.remove(); - - if (shooter.getUniqueId().equals(player.getUniqueId())) - return; - - player.setVelocity(player.getVelocity().multiply(-15).setY(15)); - UtilPlayer.message(player, F.main("Stray Arrow", "You were hit with a " + F.greenElem("Stray Arrow") + " from " + F.name(shooter.getName()) + " and got knocked back!")); - UtilPlayer.message(shooter, F.main("Stray Arrow", "You hit " + F.name(player.getName()) + " with the " + F.greenElem("Stray Arrow") + " and they got knocked back!")); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java index 632d798cd..480ed4557 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphTitan.java @@ -3,8 +3,8 @@ package mineplex.core.gadget.gadgets.morph; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.Map; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -17,7 +17,6 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.util.Vector; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; @@ -33,7 +32,6 @@ import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseGuardian; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.GadgetSelectLocationEvent; import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.recharge.Recharge; @@ -43,7 +41,8 @@ import mineplex.core.updater.event.UpdateEvent; public class MorphTitan extends MorphGadget { - private HashMap _targets = new HashMap(); + + private final Map _targets = new HashMap<>(); public MorphTitan(GadgetManager manager) { @@ -106,16 +105,9 @@ public class MorphTitan extends MorphGadget Location loc = player.getTargetBlock(ignore, 64).getLocation().add(0.5, 0.5, 0.5); - GadgetSelectLocationEvent gadgetSelectLocationEvent = new GadgetSelectLocationEvent(player, this, loc); - Bukkit.getServer().getPluginManager().callEvent(gadgetSelectLocationEvent); - - if (gadgetSelectLocationEvent.isCancelled()) + if (!Manager.selectLocation(this, loc)) { - if (gadgetSelectLocationEvent.canShowMessage()) - { - UtilPlayer.message(player, F.main("Gadget", "You cannot use the laser on this area!")); - } - + Manager.informNoUse(player); return; } @@ -152,9 +144,10 @@ public class MorphTitan extends MorphGadget HashMap players = UtilPlayer.getInRadius(stand.getLocation(), 12d); for (Player ent : players.keySet()) { - if (ent instanceof Player) - if (Manager.collideEvent(event.GetPlayer(), this, (Player)ent)) - continue; + if (!Manager.selectEntity(this, ent)) + { + continue; + } double mult = players.get(ent); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java index e5406a120..261d0590a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphVillager.java @@ -2,6 +2,7 @@ package mineplex.core.gadget.gadgets.morph; import java.util.HashSet; import java.util.Iterator; +import java.util.Set; import org.bukkit.ChatColor; import org.bukkit.EntityEffect; @@ -38,7 +39,8 @@ import mineplex.core.updater.event.UpdateEvent; public class MorphVillager extends MorphGadget implements IThrown { - private HashSet _gems = new HashSet(); + + private final Set _gems = new HashSet<>(); public MorphVillager(GadgetManager manager) { @@ -110,12 +112,10 @@ public class MorphVillager extends MorphGadget implements IThrown @Override public void Collide(LivingEntity target, Block block, ProjectileUser data) { - if (target == null) + if (target == null || !Manager.selectEntity(this, target)) + { return; - - if (target instanceof Player) - if (Manager.collideEvent((Player) data.getThrower(), this, (Player) target)) - return; + } //Pull UtilAction.velocity(target, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWitch.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWitch.java index 93555c66b..f3c144ae2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWitch.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWitch.java @@ -3,13 +3,11 @@ package mineplex.core.gadget.gadgets.morph; import java.time.Month; import java.time.YearMonth; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.inventory.ItemStack; import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; @@ -19,7 +17,6 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguiseWitch; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.GadgetSelectLocationEvent; import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.recharge.Recharge; @@ -60,11 +57,6 @@ public class MorphWitch extends MorphGadget UtilMorph.undisguise(player, Manager.getDisguiseManager()); } - public ItemStack getWitchItem() - { - return SkinData.WITCH.getSkull(); - } - @EventHandler public void onSneak(PlayerToggleSneakEvent event) { @@ -102,24 +94,6 @@ public class MorphWitch extends MorphGadget return; } -// // Checks if player is opening a treasure chest/close to a treasure area -// if (Manager.getTreasureManager() != null) -// { -// if (Manager.getTreasureManager().isOpening(event.getPlayer())) -// { -// UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!")); -// return; -// } -// for (Location blockLocation : Manager.getTreasureManager().getBlockLocations()) -// { -// if (blockLocation.distanceSquared(cauldronLocation) <= 25) -// { -// UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!")); -// return; -// } -// } -// } - // Checks if the player is close to a cactus for (int x = -3; x < 3; x++) { @@ -134,14 +108,9 @@ public class MorphWitch extends MorphGadget } } - // Checks if the player is in a Soccer area - GadgetSelectLocationEvent gadgetSelectLocationEvent = new GadgetSelectLocationEvent(event.getPlayer(), this, cauldronLocation.clone().subtract(0, 1, 0)); - gadgetSelectLocationEvent.setShowMessage(true); - Bukkit.getServer().getPluginManager().callEvent(gadgetSelectLocationEvent); - - if (gadgetSelectLocationEvent.isCancelled()) + if (!Manager.selectLocation(this, cauldronLocation)) { - UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!")); + Manager.informNoUse(event.getPlayer()); return; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java index 639ba5d95..84396d549 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWither.java @@ -136,9 +136,11 @@ public class MorphWither extends MorphGadget HashMap players = UtilPlayer.getInRadius(event.getLocation(), 6); for (Player player : players.keySet()) { - if (Manager.collideEvent((Player) skull.getShooter(), this, player)) + if (!Manager.selectEntity(this, player)) + { continue; - + } + double mult = players.get(player); //Knockback diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWolf.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWolf.java new file mode 100644 index 000000000..3345b6732 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWolf.java @@ -0,0 +1,81 @@ +package mineplex.core.gadget.gadgets.morph; + +import java.util.concurrent.TimeUnit; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +import mineplex.core.disguise.disguises.DisguiseWolf; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.util.CostConstants; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; + +public class MorphWolf extends MorphAbilityGadget +{ + + private static final ItemStack ACTIVE_ITEM = new ItemBuilder(Material.BONE) + .setTitle(C.cGreenB + "Pounce") + .addLore("Clicking this causes you to pounce.") + .setUnbreakable(true) + .build(); + + public MorphWolf(GadgetManager manager) + { + super(manager, "Wolf Morph", new String[] + { + C.cGray + "Arf", + C.blankLine, + C.cGreen + "Click" + C.cWhite + " your " + C.cYellow + "Bone" + C.cWhite + " to " + C.cGreen + "Pounce" + }, CostConstants.LEVEL_REWARDS, Material.BONE, (byte) 0, ACTIVE_ITEM, "Pounce", TimeUnit.SECONDS.toMillis(2)); + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + DisguiseWolf disguise = new DisguiseWolf(player); + UtilMorph.disguise(player, disguise, Manager); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + } + + @Override + public void onAbilityActivate(Player player) + { + player.getWorld().playSound(player.getLocation(), Sound.WOLF_BARK, 1, 0.8F); + UtilAction.velocity(player, 1.6, 0.2, 1, true); + } + + @EventHandler + public void playerSneak(PlayerToggleSneakEvent event) + { + if (!event.isSneaking()) + { + return; + } + + Player player = event.getPlayer(); + + if (!isActive(player) || !Recharge.Instance.use(player, "Wolf Howl", 8000, true, false)) + { + return; + } + + player.getWorld().playSound(player.getLocation(), Sound.WOLF_HOWL, 1, (float) (0.4 + Math.random() / 2)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/WitchEffectManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/WitchEffectManager.java index 98b06e6d1..ee59fc4f9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/WitchEffectManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/WitchEffectManager.java @@ -35,7 +35,7 @@ public class WitchEffectManager _location.getBlock().setType(Material.CAULDRON); _location.getBlock().setData((byte) 3); - _location.getWorld().strikeLightning(_location); + _location.getWorld().strikeLightningEffect(_location); Bat bat = _location.getWorld().spawn(_location.clone().add(0, 1, 0), Bat.class); bat.setCustomName(_player.getName() + "'s Magical Bat"); bat.setCustomNameVisible(true); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/GoldPotHelper.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/GoldPotHelper.java index bd4f43c48..7d6ed3a3d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/GoldPotHelper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/managers/GoldPotHelper.java @@ -1,6 +1,5 @@ package mineplex.core.gadget.gadgets.morph.managers; -import java.util.Collections; import java.util.HashSet; import java.util.Iterator; @@ -22,7 +21,6 @@ import mineplex.core.disguise.disguises.DisguiseBlock; import mineplex.core.disguise.disguises.DisguiseCat; import mineplex.core.disguise.disguises.DisguiseChicken; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.GadgetBlockEvent; import mineplex.core.gadget.types.Gadget; import mineplex.core.recharge.Recharge; @@ -34,9 +32,9 @@ public class GoldPotHelper private static final int SHARDS = 250; private static final int GEMS = 60; - private Player _player; - private GadgetManager _manager; - private Gadget _gadget; + private final Player _player; + private final GadgetManager _manager; + private final Gadget _gadget; private GoldPotStands _goldPotStands; private Block _block; private boolean _solid = false; @@ -59,13 +57,9 @@ public class GoldPotHelper Block block = _player.getLocation().getBlock(); - GadgetBlockEvent event = new GadgetBlockEvent(_gadget, Collections.singletonList(block)); - - Bukkit.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled() || block.getType() != Material.AIR) + if (!_manager.selectBlocks(_gadget, block) || block.getType() != Material.AIR) { - UtilPlayer.message(_player, F.main("Morph", "You cannot become a gold pot here!")); + _manager.informNoUse(_player); return; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphAnath.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphAnath.java index 8316ea408..2647564fa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphAnath.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphAnath.java @@ -188,6 +188,11 @@ public class MorphAnath extends MorphGadget block = block.getRelative(BlockFace.DOWN); } + if (!Manager.selectBlocks(this, block)) + { + return false; + } + Block fBlock = block; Manager.runSyncLater(() -> Manager.getBlockRestore().add(fBlock.getRelative(BlockFace.UP), Material.FIRE.getId(), (byte) 0, 5000), 10); return false; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphBiff.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphBiff.java index ed549ed24..fd2855532 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphBiff.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphBiff.java @@ -104,6 +104,12 @@ public class MorphBiff extends MorphGadget event.setCancelled(true); + if (!Manager.selectLocation(this, player.getLocation())) + { + Manager.informNoUse(player); + return; + } + if (!Recharge.Instance.use(player, "Cavalry Charge", 30000,true, true, "Cosmetics")) { return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphDana.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphDana.java index 6d13b3ea3..f49d6b5b8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphDana.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphDana.java @@ -1,5 +1,6 @@ package mineplex.core.gadget.gadgets.morph.moba; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -39,12 +40,10 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.GadgetSelectLocationEvent; import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.itemstack.ItemBuilder; @@ -122,6 +121,12 @@ public class MorphDana extends MorphGadget event.setCancelled(true); + if (!Manager.selectLocation(this, player.getLocation())) + { + Manager.informNoUse(player); + return; + } + if (!Recharge.Instance.use(player, "Rally", 30000, false, true, "Cosmetics")) { return; @@ -148,7 +153,6 @@ public class MorphDana extends MorphGadget while (iterator.hasNext()) { RallyData data = iterator.next(); - Player player = data.Owner; if (data.Landed && UtilTime.elapsed(data.LandTime, 7000)) { @@ -172,21 +176,16 @@ public class MorphDana extends MorphGadget banner.addPattern(getPattern(red)); banner.update(); - for (Block nearby : UtilBlock.getBlocksInRadius(banner.getLocation(), 5)) + Collection blocks = UtilBlock.getBlocksInRadius(banner.getLocation(), 5); + Manager.selectBlocks(this, blocks); + + for (Block nearby : blocks) { if (UtilBlock.airFoliage(nearby) || !UtilBlock.airFoliage(nearby.getRelative(BlockFace.UP))) { continue; } - GadgetSelectLocationEvent selectLocationEvent = new GadgetSelectLocationEvent(player, this, nearby.getLocation()); - UtilServer.CallEvent(selectLocationEvent); - - if (selectLocationEvent.isCancelled()) - { - continue; - } - Manager.getBlockRestore().add(nearby, Material.STAINED_CLAY.getId(), colorData, (long) (7000 + (Math.random() * 500))); if (Math.random() > 0.9) { @@ -313,7 +312,7 @@ public class MorphDana extends MorphGadget continue; } - if (!Manager.collideEvent(player, this, nearby) && Recharge.Instance.use(nearby, "Knock up " + player.getUniqueId(), 1000, false, false, "Cosmetics")) + if (Manager.selectEntity(this, nearby) && Recharge.Instance.use(nearby, "Knock up " + player.getUniqueId(), 1000, false, false, "Cosmetics")) { nearby.getWorld().playSound(nearby.getLocation(), Sound.IRONGOLEM_HIT, 1, 0.5F); UtilAction.velocity(nearby, new Vector(Math.random() / 2 - 0.25, 1, Math.random() / 2 - 0.25)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphDevon.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphDevon.java index a3ba435b5..2e7093f87 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphDevon.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphDevon.java @@ -1,6 +1,20 @@ package mineplex.core.gadget.gadgets.morph.moba; +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.ItemStack; + import com.mojang.authlib.GameProfile; + import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -10,27 +24,12 @@ import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.item.ItemTNT; import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; -import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilGameProfile; -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.inventory.ItemStack; - -import java.util.HashMap; -import java.util.Map; public class MorphDevon extends MorphGadget { @@ -108,6 +107,13 @@ public class MorphDevon extends MorphGadget return; } + if (!Manager.selectLocation(this, player.getLocation())) + { + event.setCancelled(true); + Manager.informNoUse(player); + return; + } + if (!Recharge.Instance.use(player, "TNT Infusion", 2000, false, true, "Cosmetics")) { event.setCancelled(true); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphHattori.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphHattori.java index 62a4c46f4..4a1cc5d7c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphHattori.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphHattori.java @@ -137,17 +137,10 @@ public class MorphHattori extends MorphGadget } Location start = player.getEyeLocation(); - GadgetSelectLocationEvent gadgetSelectLocationEvent = new GadgetSelectLocationEvent(player, this, start); - UtilServer.CallEvent(gadgetSelectLocationEvent); - // Checks to see if it's a valid location - if (gadgetSelectLocationEvent.isCancelled()) + if (!Manager.selectLocation(this, start)) { - if (gadgetSelectLocationEvent.canShowMessage()) - { - UtilPlayer.message(player, F.main("Gadget", "You cannot use the laser on this area!")); - } - + Manager.informNoUse(player); return; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphIvy.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphIvy.java index 343ab1144..acbc215df 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphIvy.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphIvy.java @@ -1,5 +1,6 @@ package mineplex.core.gadget.gadgets.morph.moba; +import java.util.Collection; import java.util.concurrent.TimeUnit; import org.bukkit.Effect; @@ -97,14 +98,23 @@ public class MorphIvy extends MorphGadget event.setCancelled(true); + Location location = player.getLocation(); + + if (!Manager.selectLocation(this, location)) + { + Manager.informNoUse(player); + return; + } + if (!Recharge.Instance.use(player, "Floral Display", 16000, true, true, "Cosmetics")) { return; } - Location location = player.getLocation(); + Collection blocks = UtilBlock.getInRadius(location, RADIUS).keySet(); + Manager.selectBlocks(this, blocks); - for (Block block : UtilBlock.getInRadius(location, RADIUS).keySet()) + for (Block block : blocks) { if (block.getType() != Material.AIR || UtilBlock.airFoliage(block.getRelative(BlockFace.DOWN))) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphLarissa.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphLarissa.java index 7806954e0..481848023 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphLarissa.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphLarissa.java @@ -96,12 +96,19 @@ public class MorphLarissa extends MorphGadget event.setCancelled(true); + Location location = player.getEyeLocation(); + + if (!Manager.selectLocation(this, location)) + { + Manager.informNoUse(player); + return; + } + if (!Recharge.Instance.use(player, "Aqua Cannon", 4000, true, true, "Cosmetics")) { return; } - Location location = player.getEyeLocation(); LineParticle lineParticle = new LineParticle(player.getEyeLocation(), location.getDirection(), 0.2, 10, ParticleType.DRIP_WATER, UtilServer.getPlayers()); while (!lineParticle.update()) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphRowena.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphRowena.java index f3607885d..11dd4d8e0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphRowena.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphRowena.java @@ -99,12 +99,19 @@ public class MorphRowena extends MorphGadget event.setCancelled(true); + Location location = player.getEyeLocation(); + + if (!Manager.selectLocation(this, location)) + { + Manager.informNoUse(player); + return; + } + if (!Recharge.Instance.use(player, "Light Arrows", 500, false, true, "Cosmetics")) { return; } - Location location = player.getEyeLocation(); LineParticle lineParticle = new LineParticle(location, location.getDirection(), 0.4, 40, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); lineParticle.setIgnoreAllBlocks(true); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/mount/types/MountDragon.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/mount/types/MountDragon.java index fd3ec4459..4f1a45421 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/mount/types/MountDragon.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/mount/types/MountDragon.java @@ -34,6 +34,8 @@ public class MountDragon extends DragonMount Material.DRAGON_EGG, (byte) 0 ); + + setMaxActive(4); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/mount/types/MountTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/mount/types/MountTitan.java index 31e3d30fe..0bb8e1fce 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/mount/types/MountTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/mount/types/MountTitan.java @@ -6,9 +6,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.GadgetManager.Perm; @@ -29,6 +27,8 @@ public class MountTitan extends Mount Material.MAGMA_CREAM, (byte) 0 ); + + setMaxActive(3); } @Override @@ -37,18 +37,6 @@ public class MountTitan extends Mount return new MountTitanData(player, getName()); } - @Override - public void enableCustom(Player player, boolean message) - { - if (getActiveMounts().size() >= 3) - { - UtilPlayer.message(player, F.main(Manager.getName(), "The maximum amount of simultaneous " + F.elem(getName()) + " in this lobby has been reached.")); - return; - } - - super.enableCustom(player, message); - } - @EventHandler public void update(UpdateEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/mount/types/MountTitanData.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/mount/types/MountTitanData.java index ae2dd6898..a17fcc4e9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/mount/types/MountTitanData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/mount/types/MountTitanData.java @@ -26,7 +26,7 @@ public class MountTitanData extends MountData private List _nodes; - public MountTitanData(Player player, String name) + MountTitanData(Player player, String name) { super(player); @@ -95,6 +95,7 @@ public class MountTitanData extends MountData Math.toRadians(UtilAlg.GetPitch(vector)), Math.toRadians(UtilAlg.GetYaw(vector)), 0)); + node.setFireTicks(0); inFront = node.getLocation(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/freezesuit/OutfitFreezeSuit.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/freezesuit/OutfitFreezeSuit.java index 71f0b03e3..389482ca8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/freezesuit/OutfitFreezeSuit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/freezesuit/OutfitFreezeSuit.java @@ -1,11 +1,9 @@ package mineplex.core.gadget.gadgets.outfit.freezesuit; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; -import java.util.UUID; import org.bukkit.Color; import org.bukkit.Effect; @@ -34,8 +32,7 @@ import mineplex.core.updater.event.UpdateEvent; public class OutfitFreezeSuit extends OutfitGadget { - private Set _data = new HashSet<>(); - private Map _failedAttempts = new HashMap<>(); + private final Set _data = new HashSet<>(); private static final int DURATION = 2000; private static final int RANGE = 3; @@ -113,30 +110,10 @@ public class OutfitFreezeSuit extends OutfitGadget Map blocks = UtilBlock.getInRadius(player.getLocation(), RANGE); - //boolean setBlocks = true, forceBreak = false; + Manager.selectBlocks(this, blocks.keySet()); for (Block block : blocks.keySet()) { -// if (Manager.getTreasureManager() != null) -// { -// if (Manager.getTreasureManager().isOpening(player)) -// { -// forceBreak= true; -// } -// for (Location blockLocation : Manager.getTreasureManager().getBlockLocations()) -// { -// if (blockLocation.distanceSquared(block.getLocation()) <= 25) -// { -// setBlocks = false; -// } -// } -// } -// if (forceBreak) -// break; -// -// if (!setBlocks) -// continue; - Manager.getBlockRestore().snow(block, (byte) 1, (byte) 1, (int) (DURATION * (1 + blocks.get(block))), 250, 0); } } @@ -164,7 +141,7 @@ public class OutfitFreezeSuit extends OutfitGadget { dataIterator.remove(); } - else + else if (Manager.selectBlocks(this, block)) { block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 79); Manager.getBlockRestore().add(block, 79, (byte) 0, MELT_TIME); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuit.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuit.java deleted file mode 100644 index 202ca0024..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuit.java +++ /dev/null @@ -1,289 +0,0 @@ -package mineplex.core.gadget.gadgets.outfit.windupsuit; - -import java.util.HashMap; -import java.util.Iterator; - -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffectType; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilColor; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilTextBottom; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.OutfitGadget; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - -public class OutfitWindUpSuit extends OutfitGadget -{ - - private HashMap _colorPhase = new HashMap<>(); - private HashMap _percentage = new HashMap<>(); - - private OutfitWindUpSuitBoosterManager _boosterManager; - - public OutfitWindUpSuit(GadgetManager manager, String name, int cost, ArmorSlot slot, Material mat, byte data, OutfitWindUpSuitBoosterManager boosterManager) - { - super(manager, name, - UtilText.splitLineToArray(C.cGray + "Placeholder", LineFormat.LORE), - cost, slot, mat, data); - _boosterManager = boosterManager; - } - - @Override - public void enableCustom(Player player, boolean message) - { - super.enableCustom(player, message); - - _colorPhase.put(player, 0); - _percentage.put(player, 0); - } - - @Override - public void disableCustom(Player player, boolean message) - { - super.disableCustom(player, message); - - _colorPhase.remove(player); - _percentage.remove(player); - - if (_boosterManager.hasEffects(player)) - _boosterManager.removeEffects(player); - - if (UtilPlayer.hasWorldBorder(player)) - UtilPlayer.removeWorldBorder(player); - - player.removePotionEffect(PotionEffectType.SPEED); - player.removePotionEffect(PotionEffectType.JUMP); - } - - // Updates color - @EventHandler - public void playerMove(PlayerMoveEvent event) - { - // Only updates when player really moves, not jumps - if (event.getFrom().getBlockX() == event.getTo().getBlockX() && event.getFrom().getBlockZ() == event.getTo().getBlockZ()) - return; - - Player player = event.getPlayer(); - - // Checks if player is wearing suit - if (!isActive(player)) - return; - - if (!getSet().isActive(player)) - return; - - // Checks if player has effects - if (_boosterManager.hasEffects(player)) - return; - - int phase = _colorPhase.get(player); - int percentage = _percentage.get(player); - - if (phase == 4 || percentage == 888) - return; - - Color color = getColor(player); - - if (color == null) - return; - - Color[] colors = new Color[] {Color.fromRGB(0, 255, 0), Color.fromRGB(255, 255, 0), Color.fromRGB(255, 0, 0)}; - - if (phase == 0) - { - updateNextColor(color, colors[phase], player, phase); - percentage += 1; - } - else if (phase == 1) - { - updateNextColor(color, colors[phase], player, phase); - percentage += 1; - } - else if (phase == 2) - { - updateNextColor(color, colors[phase], player, phase); - percentage += 1; - } - else if (phase == 3) - { - UtilPlayer.sendRedScreen(player, 100000); - percentage = 888; - _colorPhase.put(player, phase + 1); - } - _percentage.put(player, percentage); - sendPercentageChange(player); - } - - // Activates boost (Jump + Speed 3 for 90 seconds) - @EventHandler - public void activateBoost(PlayerToggleSneakEvent event) - { - Player player = event.getPlayer(); - - // Checks if effect is active - if (!isActive(player)) - return; - - int phase = _colorPhase.get(player); - - if(phase != 4) - return; - - _colorPhase.put(player, 0); - _percentage.put(player, 0); - sendPercentageChange(player); - updateColor(player, UtilColor.DEFAULT_LEATHER_COLOR); - - _boosterManager.applyEffects(player); - } - - // Plays fast music when player is red - @EventHandler - public void onUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - for (Iterator i = _boosterManager.getPlayers().iterator(); i.hasNext();) - { - Player player = i.next(); - // Checks if effects are over - if (_boosterManager.getTicks(player) >= 1800) - { - _boosterManager.removeEffects(player); - for (ItemStack itemStack : player.getEquipment().getArmorContents()) - { - UtilColor.applyColor(itemStack, UtilColor.DEFAULT_LEATHER_COLOR); - } - } - else - { - _boosterManager.incrementTicks(player); - } - } - - for (Player player : _colorPhase.keySet()) - { - int phase = _colorPhase.get(player); - if (phase == 4) - { - if (event.getTick() % 5 == 0) - { - player.playSound(player.getLocation(), Sound.NOTE_BASS_DRUM, 1f, 1f); - UtilTextBottom.display(C.cRedB + "Wind Up booster is ready! Sneak to activate!" + ChatColor.RESET, player); - } - } - } - } - - private Color getColor(Player player) - { - ItemStack stack = getStack(player); - - if (stack == null) - return UtilColor.DEFAULT_LEATHER_COLOR; - - return UtilColor.getItemColor(stack); - } - - private void updateColor(Player player, Color color) - { - ItemStack stack = getStack(player); - - if (stack == null) - return; - - // Checks if material is the same - if(!UtilGear.isMat(stack, getDisplayMaterial())) - { - disable(player); - return; - } - - UtilColor.applyColor(stack, color); - } - - private void updateNextColor(Color original, Color finalColor, Player player, int phase) - { - // Makes a really smooth transition between colors - Color nextColor = UtilColor.getNextColor(original, finalColor, 1); - - if (compareColors(finalColor, nextColor)) - _colorPhase.put(player, phase + 1); - - updateColor(player, nextColor); - } - - private ItemStack getStack(Player player) - { - ItemStack stack; - - if(getSlot() == ArmorSlot.HELMET) - { - stack = player.getInventory().getHelmet(); - } - else if (getSlot() == ArmorSlot.CHEST) - { - stack = player.getInventory().getChestplate(); - } - else if (getSlot() == ArmorSlot.LEGS) - { - stack = player.getInventory().getLeggings(); - } - else if (getSlot() == ArmorSlot.BOOTS) - { - stack = player.getInventory().getBoots(); - } - else - stack = null; - - return stack; - } - - private void sendPercentageChange(Player player) - { - if (!_percentage.containsKey(player)) - return; - - // 888 = Max number of color changes (100%) - double percent = ((_percentage.get(player) * 100d) / 888d) / 100d; - UtilTextBottom.displayProgress(C.Bold + getSet().getName(), percent, "", player); - } - - private boolean compareColors(Color colorA, Color colorB) - { - int rA = colorA.getRed(), rB = colorB.getRed(); - int gA = colorA.getGreen(), gB = colorB.getGreen(); - int bA = colorA.getBlue(), bB = colorB.getBlue(); - int minR = Math.min(rA, rB), maxR = Math.max(rA, rB); - int minG = Math.min(gA, gB), maxG = Math.max(gA, gB); - int minB = Math.min(bA, bB), maxB = Math.max(bA, bB); - if (maxR - minR > 2) - { - return false; - } - if (maxG - minG > 2) - { - return false; - } - if (maxB - minB > 2) - { - return false; - } - return true; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitBoosterManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitBoosterManager.java deleted file mode 100644 index abf360737..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitBoosterManager.java +++ /dev/null @@ -1,164 +0,0 @@ -package mineplex.core.gadget.gadgets.outfit.windupsuit; - -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.HashMap; -import java.util.Set; - -import org.bukkit.Bukkit; -import org.bukkit.Color; -import org.bukkit.FireworkEffect; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -import mineplex.core.common.util.UtilColor; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.noteblock.NBSReader; -import mineplex.core.noteblock.NotePlayer; -import mineplex.core.noteblock.NoteSong; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - -public class OutfitWindUpSuitBoosterManager implements Listener -{ - - private GadgetManager _gadget; - - private HashMap _players = new HashMap(); - private HashMap _notePlayers = new HashMap(); - - public OutfitWindUpSuitBoosterManager(GadgetManager gadget) - { - _gadget = gadget; - Bukkit.getPluginManager().registerEvents(this, gadget.getPlugin()); - } - - public void applyEffects(Player player) - { - if (hasEffects(player)) - return; - - _players.put(player, 0); - - // Applies potion effects - PotionEffect speed = new PotionEffect(PotionEffectType.SPEED, 1800, 2, false); - PotionEffect jump = new PotionEffect(PotionEffectType.JUMP, 1800, 2, false); - player.addPotionEffect(speed); - player.addPotionEffect(jump); - - // Resets red screen - UtilPlayer.sendRedScreen(player, 0); - - // Plays firework effect - UtilFirework.playFirework(player.getLocation(), FireworkEffect.builder().withColor(Color.RED).withFade(Color.BLACK).flicker(true).build()); - - // Starts the song - playSong(player); - } - - public void removeEffects(Player player) - { - if (!hasEffects(player)) - return; - - _players.remove(player); - - // Removes potion effetcs - player.removePotionEffect(PotionEffectType.JUMP); - player.removePotionEffect(PotionEffectType.SPEED); - - // Stops song - if (_notePlayers.containsKey(player)) - { - NotePlayer notePlayer = _notePlayers.get(player); - notePlayer.cancel(); - _notePlayers.remove(player); - } - } - - public boolean hasEffects(Player player) - { - return _players.containsKey(player); - } - - public Set getPlayers() - { - return _players.keySet(); - } - - public int getTicks(Player player) - { - if (!hasEffects(player)) - return -1; - return _players.get(player); - } - - public void incrementTicks(Player player) - { - _players.put(player, getTicks(player) + 1); - } - - private void playSong(Player player) - { - String songName = "tetris.nbs"; - try - { - File songFile = new File("../../update/songs/" + songName); - if (songFile.exists()) - { - NoteSong song = NBSReader.loadSong(new DataInputStream(new FileInputStream(songFile)), songFile.getName().replace("_", " ").replace(".nbs", "")); - if (song != null) - { - NotePlayer notePlayer = new NotePlayer(_gadget.getPlugin(), song, p -> true, 0.5F, true, player); - _notePlayers.put(player, notePlayer); - } - } - } - catch (FileNotFoundException e) - { - e.printStackTrace(); - } - } - - /** - * Flickers colors between yellow and red to mimic the invulnerability star from mario - */ - @EventHandler - public void onUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - _notePlayers.keySet().forEach(player -> flickerColor(player)); - } - - private void flickerColor(Player player) - { - ItemStack[] playerArmor = player.getEquipment().getArmorContents(); - for (ItemStack item : playerArmor) - { - if (item != null) - { - LeatherArmorMeta leatherMeta = (LeatherArmorMeta) item.getItemMeta(); - if (leatherMeta.getColor().getRed() == 255 && leatherMeta.getColor().getGreen() == 255) - { - UtilColor.applyColor(item, Color.fromRGB(255, 0, 0)); - } - else - { - UtilColor.applyColor(item, Color.fromRGB(255, 255, 0)); - } - } - } - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitBoots.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitBoots.java deleted file mode 100644 index 55448de2d..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitBoots.java +++ /dev/null @@ -1,14 +0,0 @@ -package mineplex.core.gadget.gadgets.outfit.windupsuit; - -import mineplex.core.gadget.GadgetManager; -import org.bukkit.Material; - -public class OutfitWindUpSuitBoots extends OutfitWindUpSuit -{ - - public OutfitWindUpSuitBoots(GadgetManager manager) - { - super(manager, "Wind Up Boots", -2, ArmorSlot.BOOTS, Material.LEATHER_BOOTS, (byte)0, manager.getBoosterManager()); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitChestplate.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitChestplate.java deleted file mode 100644 index bc64a4bd5..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitChestplate.java +++ /dev/null @@ -1,14 +0,0 @@ -package mineplex.core.gadget.gadgets.outfit.windupsuit; - -import mineplex.core.gadget.GadgetManager; -import org.bukkit.Material; - -public class OutfitWindUpSuitChestplate extends OutfitWindUpSuit -{ - - public OutfitWindUpSuitChestplate(GadgetManager manager) - { - super(manager, "Wind Up Shirt", -2, ArmorSlot.CHEST, Material.LEATHER_CHESTPLATE, (byte)0, manager.getBoosterManager()); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitHelmet.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitHelmet.java deleted file mode 100644 index 23d19d334..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitHelmet.java +++ /dev/null @@ -1,14 +0,0 @@ -package mineplex.core.gadget.gadgets.outfit.windupsuit; - -import mineplex.core.gadget.GadgetManager; -import org.bukkit.Material; - -public class OutfitWindUpSuitHelmet extends OutfitWindUpSuit -{ - - public OutfitWindUpSuitHelmet(GadgetManager manager) - { - super(manager, "Wind Up Hat", -2, ArmorSlot.HELMET, Material.LEATHER_HELMET, (byte)0, manager.getBoosterManager()); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitLeggings.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitLeggings.java deleted file mode 100644 index c7b094e32..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/windupsuit/OutfitWindUpSuitLeggings.java +++ /dev/null @@ -1,14 +0,0 @@ -package mineplex.core.gadget.gadgets.outfit.windupsuit; - -import mineplex.core.gadget.GadgetManager; -import org.bukkit.Material; - -public class OutfitWindUpSuitLeggings extends OutfitWindUpSuit -{ - - public OutfitWindUpSuitLeggings(GadgetManager manager) - { - super(manager, "Wind Up Pants", -2, ArmorSlot.LEGS, Material.LEATHER_LEGGINGS, (byte)0, manager.getBoosterManager()); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCape.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCape.java new file mode 100644 index 000000000..6fc888e81 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCape.java @@ -0,0 +1,31 @@ +package mineplex.core.gadget.gadgets.particle; + +import org.bukkit.Material; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.banner.CountryFlag; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.util.CostConstants; + +public class ParticleCape extends ParticleImageGadget +{ + + private static final String[] PARTICLE = + { + "175,175,175/155,155,155/255,156,0/255,156,0/255,156,0/255,156,0/53,53,53/91,91,91/79,79,79/69,69,69/", + "175,175,175/155,155,155/255,156,0/255,138,0/255,138,0/255,138,0/53,53,53/91,91,91/79,79,79/69,69,69/", + "175,175,175/155,155,155/255,156,0/255,138,0/53,53,53/121,121,121/105,105,105/91,91,91/79,79,79/69,69,69/", + "175,175,175/155,155,155/137,137,137/255,138,0/255,138,0/53,53,53/105,105,105/91,91,91/79,79,79/69,69,69/", + "255,156,0/53,53,53/255,156,0/255,138,0/53,53,53/121,121,121/105,105,105/91,91,91/79,79,79/69,69,69/", + "255,138,0/53,53,53/255,138,0/255,138,0/255,138,0/255,138,0/53,53,53/91,91,91/79,79,79/69,69,69/", + }; + + public ParticleCape(GadgetManager manager) + { + super(manager, "Mineplex Cape", UtilText.splitLineToArray(C.cGray + "This is a real super hero cape!", LineFormat.LORE), PARTICLE, CostConstants.NO_LORE, Material.GLASS, (byte) 0); + + setDisplayItem(CountryFlag.MINEPLEX.getBanner()); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleChickenWings.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleChickenWings.java new file mode 100644 index 000000000..e028613e2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleChickenWings.java @@ -0,0 +1,50 @@ +package mineplex.core.gadget.gadgets.particle; + +import org.bukkit.Material; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.util.CostConstants; + +public class ParticleChickenWings extends ParticleImageGadget +{ + + private static final String[] PARTICLE = + { + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/106,44,0/106,44,0/106,44,0/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/140,59,0/122,51,0/106,44,0/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/122,51,0/140,59,0/140,59,0/122,51,0/106,44,0/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/140,59,0/106,44,0/122,51,0/122,51,0/106,44,0/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/140,59,0/140,59,0/140,59,0/140,59,0/106,44,0/92,38,0/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/158,67,0/140,59,0/140,59,0/122,51,0/106,44,0/92,38,0/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/179,76,0/158,67,0/140,59,0/122,51,0/106,44,0/92,38,0/92,38,0/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/179,76,0/158,67,0/158,67,0/122,51,0/106,44,0/106,44,0/92,38,0/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/179,76,0/158,67,0/140,59,0/122,51,0/106,44,0/92,38,0/92,38,0/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/179,76,0/179,76,0/158,67,0/158,67,0/140,59,0/140,59,0/122,51,0/106,44,0/106,44,0/106,44,0/-1,-1,-1/", + "179,76,0/158,67,0/140,59,0/140,59,0/140,59,0/140,59,0/140,59,0/140,59,0/140,59,0/140,59,0/122,51,0/106,44,0/", + "179,76,0/158,67,0/140,59,0/140,59,0/140,59,0/158,67,0/158,67,0/158,67,0/140,59,0/140,59,0/122,51,0/106,44,0/", + "-1,-1,-1/179,76,0/158,67,0/158,67,0/158,67,0/179,76,0/179,76,0/179,76,0/158,67,0/158,67,0/158,67,0/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/179,76,0/158,67,0/158,67,0/158,67,0/179,76,0/179,76,0/179,76,0/158,67,0/158,67,0/158,67,0/-1,-1,-1/", + "179,76,0/158,67,0/140,59,0/140,59,0/140,59,0/158,67,0/158,67,0/158,67,0/140,59,0/140,59,0/122,51,0/106,44,0/", + "179,76,0/158,67,0/140,59,0/140,59,0/140,59,0/140,59,0/140,59,0/140,59,0/140,59,0/140,59,0/122,51,0/106,44,0/", + "-1,-1,-1/179,76,0/179,76,0/158,67,0/158,67,0/140,59,0/140,59,0/122,51,0/106,44,0/106,44,0/106,44,0/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/179,76,0/158,67,0/140,59,0/122,51,0/106,44,0/92,38,0/92,38,0/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/179,76,0/158,67,0/158,67,0/122,51,0/106,44,0/106,44,0/92,38,0/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/179,76,0/158,67,0/140,59,0/122,51,0/106,44,0/92,38,0/92,38,0/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/158,67,0/140,59,0/140,59,0/122,51,0/106,44,0/92,38,0/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/140,59,0/140,59,0/140,59,0/140,59,0/106,44,0/92,38,0/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/140,59,0/106,44,0/122,51,0/122,51,0/106,44,0/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/122,51,0/140,59,0/140,59,0/122,51,0/106,44,0/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/140,59,0/122,51,0/106,44,0/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/106,44,0/106,44,0/106,44,0/", + }; + + public ParticleChickenWings(GadgetManager manager) + { + super(manager, "Chicken Wings", UtilText.splitLineToArray(C.cGray + "Bawk Bawk!", LineFormat.LORE), PARTICLE, CostConstants.FOUND_IN_TREASURE_CHESTS, Material.COOKED_CHICKEN, (byte) 0); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleDeepSeaSwirl.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleDeepSeaSwirl.java new file mode 100644 index 000000000..750a7f1ab --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleDeepSeaSwirl.java @@ -0,0 +1,91 @@ +package mineplex.core.gadget.gadgets.particle; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.gadget.util.CostConstants; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class ParticleDeepSeaSwirl extends ParticleGadget +{ + + private static final DustSpellColor[] COLOURS = + { + new DustSpellColor(Color.AQUA), + new DustSpellColor(Color.TEAL), + new DustSpellColor(Color.BLUE) + }; + + private static final double MAX_RADIUS = 2.2; + private static final int SPIRALS = 3; + private static final double DELTA_THETA = Math.PI / 60; + private static final double DELTA_THETA_2 = 2 * Math.PI / SPIRALS; + + private double _theta; + private int _index; + + public ParticleDeepSeaSwirl(GadgetManager manager) + { + super(manager, "Deep Sea Swirl", UtilText.splitLineToArray(C.cGray + "Under the sea!!", LineFormat.LORE), CostConstants.FOUND_IN_TREASURE_CHESTS, Material.POTION, (byte) 0); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + Location location = player.getLocation().add(0, 0.25, 0); + DustSpellColor colour = COLOURS[_index]; + + if (Manager.isMoving(player)) + { + new ColoredParticle(ParticleType.RED_DUST, colour, location) + .display(); + } + else + { + for (double radius = 0.2; radius < MAX_RADIUS; radius += 0.1) + { + double t = radius / MAX_RADIUS * DELTA_THETA_2; + + for (int i = 0; i < SPIRALS; i++) + { + double x = radius * Math.sin(_theta + t), z = radius * Math.cos(_theta + t); + + location.add(x, 0, z); + + new ColoredParticle(ParticleType.RED_DUST, colour, location) + .display(); + + location.subtract(x, 0, z); + t += DELTA_THETA_2; + } + } + } + } + + @Override + @EventHandler + public void Caller(UpdateEvent event) + { + if (event.getType() == UpdateType.FASTEST) + { + _theta += DELTA_THETA; + super.Caller(event); + } + else if (event.getType() == UpdateType.SEC) + { + _index = (_index + 1) % COLOURS.length; + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnderDragonWings.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnderDragonWings.java new file mode 100644 index 000000000..976046d01 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleEnderDragonWings.java @@ -0,0 +1,54 @@ +package mineplex.core.gadget.gadgets.particle; + +import org.bukkit.Material; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.util.CostConstants; + +public class ParticleEnderDragonWings extends ParticleImageGadget +{ + + private static final String[] PARTICLE = + { + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/175,175,175/175,175,175/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/175,175,175/145,145,145/24,24,24/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/175,175,175/145,145,145/24,24,24/34,34,34/34,34,34/40,40,40/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/175,175,175/145,145,145/24,24,24/34,34,34/34,34,34/40,40,40/40,40,40/40,40,40/34,34,34/34,34,34/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/175,175,175/145,145,145/145,145,145/24,24,24/34,34,34/40,40,40/40,40,40/34,34,34/34,34,34/145,145,145/145,145,145/145,145,145/145,145,145/", + "-1,-1,-1/175,175,175/145,145,145/24,24,24/34,34,34/34,34,34/40,40,40/34,34,34/175,175,175/145,145,145/24,24,24/24,24,24/24,24,24/-1,-1,-1/", + "175,175,175/145,145,145/24,24,24/34,34,34/34,34,34/34,34,34/175,175,175/145,145,145/24,24,24/24,24,24/34,34,34/34,34,34/34,34,34/-1,-1,-1/", + "175,175,175/145,145,145/24,24,24/34,34,34/175,175,175/145,145,145/24,24,24/24,24,24/34,34,34/34,34,34/34,34,34/40,40,40/-1,-1,-1/-1,-1,-1/", + "175,175,175/145,145,145/24,24,24/145,145,145/24,24,24/24,24,24/34,34,34/34,34,34/34,34,34/40,40,40/40,40,40/40,40,40/-1,-1,-1/-1,-1,-1/", + "175,175,175/145,145,145/132,132,132/24,24,24/34,34,34/34,34,34/34,34,34/175,175,175/145,145,145/145,145,145/145,145,145/145,145,145/145,145,145/145,145,145/", + "175,175,175/145,145,145/145,145,145/24,24,24/24,24,24/175,175,175/145,145,145/24,24,24/24,24,24/24,24,24/24,24,24/24,24,24/-1,-1,-1/-1,-1,-1/", + "175,175,175/145,145,145/145,145,145/145,145,145/132,132,132/24,24,24/24,24,24/34,34,34/34,34,34/34,34,34/34,34,34/34,34,34/-1,-1,-1/-1,-1,-1/", + "175,175,175/175,175,175/145,145,145/145,145,145/24,24,24/24,24,24/34,34,34/34,34,34/40,40,40/40,40,40/40,40,40/40,40,40/-1,-1,-1/-1,-1,-1/", + "175,175,175/-1,-1,-1/132,132,132/145,145,145/132,132,132/24,24,24/24,24,24/34,34,34/34,34,34/34,34,34/40,40,40/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/132,132,132/132,132,132/132,132,132/24,24,24/24,24,24/24,24,24/24,24,24/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/132,132,132/132,132,132/132,132,132/132,132,132/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/132,132,132/132,132,132/132,132,132/132,132,132/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/132,132,132/132,132,132/132,132,132/24,24,24/24,24,24/24,24,24/24,24,24/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "175,175,175/-1,-1,-1/132,132,132/145,145,145/132,132,132/24,24,24/24,24,24/34,34,34/34,34,34/34,34,34/40,40,40/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "175,175,175/175,175,175/145,145,145/145,145,145/24,24,24/24,24,24/34,34,34/34,34,34/40,40,40/40,40,40/40,40,40/40,40,40/-1,-1,-1/-1,-1,-1/", + "175,175,175/145,145,145/145,145,145/145,145,145/132,132,132/24,24,24/24,24,24/34,34,34/34,34,34/34,34,34/34,34,34/34,34,34/-1,-1,-1/-1,-1,-1/", + "175,175,175/145,145,145/145,145,145/24,24,24/24,24,24/175,175,175/145,145,145/24,24,24/24,24,24/24,24,24/24,24,24/24,24,24/-1,-1,-1/-1,-1,-1/", + "175,175,175/145,145,145/132,132,132/24,24,24/34,34,34/34,34,34/34,34,34/175,175,175/145,145,145/145,145,145/145,145,145/145,145,145/145,145,145/145,145,145/", + "175,175,175/145,145,145/24,24,24/145,145,145/24,24,24/24,24,24/34,34,34/34,34,34/34,34,34/40,40,40/40,40,40/40,40,40/-1,-1,-1/-1,-1,-1/", + "175,175,175/145,145,145/24,24,24/34,34,34/175,175,175/145,145,145/24,24,24/24,24,24/34,34,34/34,34,34/34,34,34/40,40,40/-1,-1,-1/-1,-1,-1/", + "175,175,175/145,145,145/24,24,24/34,34,34/34,34,34/34,34,34/175,175,175/145,145,145/24,24,24/24,24,24/34,34,34/34,34,34/34,34,34/-1,-1,-1/", + "-1,-1,-1/175,175,175/145,145,145/24,24,24/34,34,34/34,34,34/40,40,40/34,34,34/175,175,175/145,145,145/24,24,24/24,24,24/24,24,24/-1,-1,-1/", + "-1,-1,-1/175,175,175/145,145,145/145,145,145/24,24,24/34,34,34/40,40,40/40,40,40/34,34,34/34,34,34/145,145,145/145,145,145/145,145,145/145,145,145/", + "-1,-1,-1/-1,-1,-1/175,175,175/145,145,145/24,24,24/34,34,34/34,34,34/40,40,40/40,40,40/40,40,40/34,34,34/34,34,34/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/175,175,175/145,145,145/24,24,24/34,34,34/34,34,34/40,40,40/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/175,175,175/145,145,145/24,24,24/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/175,175,175/175,175,175/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + }; + + public ParticleEnderDragonWings(GadgetManager manager) + { + super(manager, "Ender Dragon", UtilText.splitLineToArray(C.cGray + "The most powerful being in all of Minecraft reduced to a couple hundred vectors.", LineFormat.LORE), PARTICLE, CostConstants.LEVEL_REWARDS, Material.DRAGON_EGG, (byte) 0); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFoxTail.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFoxTail.java new file mode 100644 index 000000000..1eb9f4a22 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleFoxTail.java @@ -0,0 +1,31 @@ +package mineplex.core.gadget.gadgets.particle; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.util.CostConstants; + +public class ParticleFoxTail extends ParticleImageGadget +{ + + private static final String[] PARTICLE = + { + "-1,-1,-1/255,93,0/255,93,0/255,81,0/255,84,0/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "255,96,0/255,90,0/255,81,0/246,75,0/246,76,2/255,115,51/255,195,169/-1,-1,-1/", + "255,90,0/246,75,0/246,75,0/238,72,0/238,88,20/246,141,96/255,214,193/255,240,231/", + "255,78,0/238,72,0/238,72,0/238,72,0/230,101,46/246,157,121/255,213,196/-1,-1,-1/", + "246,75,0/230,70,0/238,72,0/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + }; + + public ParticleFoxTail(GadgetManager manager) + { + super(manager, "Fox Tail", UtilText.splitLineToArray(C.cGray + "What does the fox say? Well probably doesn't matter.", LineFormat.LORE), PARTICLE, CostConstants.FOUND_IN_TREASURE_CHESTS, Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.OCELOT)); + + _yOffset = 0.5; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleImageGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleImageGadget.java new file mode 100644 index 000000000..29644bb68 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleImageGadget.java @@ -0,0 +1,87 @@ +package mineplex.core.gadget.gadgets.particle; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import mineplex.core.common.Pair; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class ParticleImageGadget extends ParticleGadget +{ + + private static final short BACKGROUND = (short) -1; + + private final List> _particles; + double _yOffset = 1; + + ParticleImageGadget(GadgetManager manager, String name, String[] desc, String[] image, int cost, Material mat, byte data, String... altNames) + { + super(manager, name, desc, cost, mat, data, altNames); + + _particles = new ArrayList<>(200); + + int width = image.length / 2; + int i = 0; + for (String line : image) + { + String[] pixels = line.split("/"); + int height = pixels.length / 2; + int j = 0; + + for (String pixel : pixels) + { + String[] rgb = pixel.split(","); + short r = Short.valueOf(rgb[0]), g = Short.valueOf(rgb[1]), b = Short.valueOf(rgb[2]); + + if (r == BACKGROUND && g == BACKGROUND && b == BACKGROUND) + { + j++; + continue; + } + + Vector offset = new Vector(width - i, height - j++, 0).multiply(.125); + DustSpellColor color = new DustSpellColor(r, g, b); + _particles.add(Pair.create(offset, color)); + } + + i++; + } + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + Location location = player.getLocation().add(0, _yOffset, 0); + location.setPitch(0); + location.subtract(location.getDirection().multiply(0.5)); + double yaw = Math.toRadians(location.getYaw()); + + _particles.forEach(pair -> + { + Vector offset = pair.getLeft().clone(); + UtilAlg.rotateAroundYAxis(offset, yaw); + + new ColoredParticle(ParticleType.RED_DUST, pair.getRight(), location.add(offset)) + .display(); + + location.subtract(offset); + }); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleInfused.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleInfused.java new file mode 100644 index 000000000..b6cae38ec --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleInfused.java @@ -0,0 +1,126 @@ +package mineplex.core.gadget.gadgets.particle; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.gadget.util.CostConstants; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class ParticleInfused extends ParticleGadget +{ + + private static final double DELTA_THETA = Math.PI / 20; + private static final double DELTA_Y = 0.05; + private static final double RADIUS = 1.4; + private static final double RADIUS_MOVING = 0.4; + private static final double MAX_HEIGHT = 2.5; + private static final DustSpellColor RED = new DustSpellColor(Color.RED); + private static final DustSpellColor BLUE = new DustSpellColor(Color.AQUA); + + private double _theta, _y, _radius; + private boolean _up; + + public ParticleInfused(GadgetManager manager) + { + super(manager, "Colliding Colors", UtilText.splitLineToArray(C.cGray + "The legendary mage Azmah spent years trying to infuse these two super powers.", LineFormat.LORE), CostConstants.FOUND_IN_TREASURE_CHESTS, Material.INK_SACK, (byte) 12); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + Location locationA, locationB; + + if (Manager.isMoving(player)) + { + locationA = player.getLocation().add(0, 1, 0); + locationB = locationA.clone(); + Location fixed = locationA.clone(); + fixed.setPitch(0); + double x = RADIUS_MOVING * Math.cos(_theta), y = RADIUS_MOVING * Math.sin(_theta), r = Math.toRadians(fixed.getYaw()); + + locationA.add(x, y, 0); + locationB.subtract(x, y, 0); + + Vector vectorA = locationA.toVector().subtract(fixed.toVector()), vectorB = locationB.toVector().subtract(fixed.toVector()); + + UtilAlg.rotateAroundYAxis(vectorA, r); + UtilAlg.rotateAroundYAxis(vectorB, r); + + new ColoredParticle(ParticleType.RED_DUST, RED, fixed.clone().add(vectorA)) + .display(); + new ColoredParticle(ParticleType.RED_DUST, BLUE, fixed.clone().add(vectorB)) + .display(); + } + else + { + locationA = player.getLocation().add(0, 0.1, 0); + locationB = locationA.clone(); + double x = _radius * Math.cos(_theta), z = _radius * Math.sin(_theta); + + locationA.add(x, _y, z); + locationB.add(-x, _y, -z); + + if (_up) + { + new ColoredParticle(ParticleType.RED_DUST, RED, locationA) + .display(); + new ColoredParticle(ParticleType.RED_DUST, BLUE, locationB) + .display(); + } + else + { + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, locationA, null, 0, 1, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, locationB, null, 0, 1, ViewDist.NORMAL); + } + } + } + + @Override + @EventHandler + public void Caller(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_up) + { + _y += DELTA_Y; + + if (_y > MAX_HEIGHT) + { + _up = false; + } + } + else + { + _y -= DELTA_Y; + + if (_y < 0) + { + _up = true; + } + } + + _theta += DELTA_THETA; + _radius = (MAX_HEIGHT - _y) / MAX_HEIGHT * RADIUS; + super.Caller(event); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleJetPack.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleJetPack.java new file mode 100644 index 000000000..9219b2136 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleJetPack.java @@ -0,0 +1,32 @@ +package mineplex.core.gadget.gadgets.particle; + +import org.bukkit.Material; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.util.CostConstants; + +public class ParticleJetPack extends ParticleImageGadget +{ + + private static final String[] PARTICLE = + { + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/139,139,139/139,139,139/255,0,0/255,102,0/-1,-1,-1/", + "54,54,54/54,54,54/54,54,54/46,46,46/46,46,46/46,46,46/46,46,46/38,38,38/38,38,38/99,99,99/119,119,119/255,102,0/255,168,0/255,252,0/", + "-1,-1,-1/-1,-1,-1/38,38,38/139,139,139/68,81,104/119,119,119/99,99,99/46,46,46/38,38,38/99,99,99/99,99,99/255,0,0/255,102,0/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/38,38,38/162,162,162/139,139,139/68,81,104/119,119,119/99,99,99/38,38,38/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/38,38,38/162,162,162/139,139,139/68,81,104/119,119,119/99,99,99/38,38,38/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/38,38,38/139,139,139/68,81,104/119,119,119/99,99,99/46,46,46/38,38,38/99,99,99/99,99,99/255,0,0/255,102,0/-1,-1,-1/", + "54,54,54/54,54,54/54,54,54/46,46,46/46,46,46/46,46,46/46,46,46/38,38,38/38,38,38/99,99,99/119,119,119/255,102,0/255,168,0/255,252,0/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/139,139,139/139,139,139/255,0,0/255,102,0/-1,-1,-1/", + }; + + public ParticleJetPack(GadgetManager manager) + { + super(manager, "Jet Pack", UtilText.splitLineToArray(C.cGray + "Shame it doesn't actually allow you to fly ¯\\_(ツ)_/¯", LineFormat.LORE), PARTICLE, CostConstants.FOUND_IN_TREASURE_CHESTS, Material.IRON_INGOT, (byte) 0); + + _yOffset = 0.8; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java index 8f0fe6b1c..9551b2e98 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegend.java @@ -1,7 +1,5 @@ package mineplex.core.gadget.gadgets.particle; -import java.awt.*; - import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -12,9 +10,15 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.set.SetLegend; import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.gadget.util.CostConstants; import mineplex.core.inventory.ClientItem; import mineplex.core.inventory.data.Item; import mineplex.core.updater.UpdateType; @@ -34,15 +38,9 @@ public class ParticleLegend extends ParticleGadget private static final double HEIGHT_MODIFIER_BASE = 0.1; private static final double HEIGHT_MODIFIER_MAX = 1.3; private static final double HEIGHT_MODIFIER_INTERVAL = 0.15; - private static final Color[] SELECTABLE_COLORS = - { - new Color(60, 170, 25), - new Color(33, 92, 13), - new Color(0, 0, 0) - }; private final int _pillars = pillars(); - private final Color[] _colors = colors(); + private final DustSpellColor[] _colors = colors(); private final double[] _heights = heights(); private final double[] _verticals = verticals(); private final double[] _variance = variances(); @@ -53,8 +51,8 @@ public class ParticleLegend extends ParticleGadget { super(manager, "Legendary Aura", UtilText.splitLineToArray(C.cGray + "Legendary energy protects you.", LineFormat.LORE), - -1, - Material.ENDER_PORTAL_FRAME, (byte)0); + CostConstants.UNLOCKED_WITH_LEGEND, + Material.ENDER_PORTAL_FRAME, (byte) 0); } @Override @@ -65,49 +63,38 @@ public class ParticleLegend extends ParticleGadget return; } + Location location = player.getLocation(); + if (Manager.isMoving(player)) { - for (int i = 0; i < MOVING_PARTICLES; i++) { - if (_colors[i % _colors.length].getGreen() == 0) - { - UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.SMOKE, - UtilMath.gauss(player.getLocation(), 8, 4, 8), null, 0, 1, UtilParticle.ViewDist.NORMAL); - } - else - { - UtilParticle.playColoredParticleToAll(_colors[i % _colors.length], UtilParticle.ParticleType.RED_DUST, - UtilMath.gauss(player.getLocation(), 8, 4, 8), 0, UtilParticle.ViewDist.NORMAL); - } + new ColoredParticle(ParticleType.RED_DUST, _colors[i % _colors.length], UtilMath.gauss(location, 8, 4, 8)) + .display(); } } - else + else if (event.getTick() % (ROTATIONAL_SPEED * 100) == 0) { - if (event.getTick() % (ROTATIONAL_SPEED * 100) == 0) + boolean setBonus = getSet().isActive(player) && Math.random() < 0.05; + + for (int i = 0; i < _pillars; i++) { - for (int i = 0; i < _pillars; i++) + _thetas[i] = rollover(_thetas[i], ROTATIONAL_SPEED); + _heights[i] = rollover(_heights[i], _verticals[i]); + + double x = (_radii[i] * Math.cos(_thetas[i])) + location.getX(); + double z = (_radii[i] * Math.sin(_thetas[i])) + location.getZ(); + double y = (Math.sin(_heights[i]) * _variance[i]) + location.getY(); + + for (double h = HEIGHT_MODIFIER_BASE; h <= HEIGHT_MODIFIER_MAX; h += HEIGHT_MODIFIER_INTERVAL) { - _thetas[i] = rollover(_thetas[i], ROTATIONAL_SPEED); - _heights[i] = rollover(_heights[i], _verticals[i]); + new ColoredParticle(ParticleType.RED_DUST, _colors[i % _colors.length], new Location(location.getWorld(), x, y + h, z)) + .display(); + } - double x = (_radii[i] * Math.cos(_thetas[i])) + player.getLocation().getX(); - double z = (_radii[i] * Math.sin(_thetas[i])) + player.getLocation().getZ(); - double y = (Math.sin(_heights[i]) * _variance[i]) + player.getLocation().getY(); - - for (double h = HEIGHT_MODIFIER_BASE; h <= HEIGHT_MODIFIER_MAX; h+= HEIGHT_MODIFIER_INTERVAL) - { - if (_colors[i].getGreen() == 0) - { - UtilParticle.PlayParticleToAll(UtilParticle.ParticleType.SMOKE, - new Location(player.getWorld(), x, y + h, z), null, 0, 1, UtilParticle.ViewDist.NORMAL); - } - else - { - UtilParticle.playColoredParticleToAll(_colors[i], UtilParticle.ParticleType.RED_DUST, - new Location(player.getWorld(), x, y + h, z), 0, UtilParticle.ViewDist.NORMAL); - } - } + if (setBonus) + { + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, new Location(location.getWorld(), x, y + HEIGHT_MODIFIER_MAX, z), null, 0, 1, ViewDist.NORMAL); } } } @@ -176,13 +163,13 @@ public class ParticleLegend extends ParticleGadget return array; } - private Color[] colors() + private DustSpellColor[] colors() { - Color[] array = new Color[_pillars]; + DustSpellColor[] array = new DustSpellColor[_pillars]; for (int i = 0; i < _pillars; i++) { - array[i] = SELECTABLE_COLORS[i % SELECTABLE_COLORS.length]; + array[i] = SetLegend.SELECTABLE_COLORS[i % SetLegend.SELECTABLE_COLORS.length]; } return array; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegendaryHero.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegendaryHero.java new file mode 100644 index 000000000..0ecf8be4c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleLegendaryHero.java @@ -0,0 +1,35 @@ +package mineplex.core.gadget.gadgets.particle; + +import org.bukkit.Material; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.util.CostConstants; + +public class ParticleLegendaryHero extends ParticleImageGadget +{ + + private static final String[] PARTICLE = + { + "137,139,140/117,123,124/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "117,123,124/137,139,140/117,123,124/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/117,123,124/137,139,140/117,123,124/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/181,181,181/181,181,181/181,181,181/181,181,181/181,181,181/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/211,211,211/29,101,143/29,101,143/29,101,143/255,24,0/181,181,181/181,181,181/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/211,211,211/29,101,143/181,181,181/29,101,143/29,101,143/255,24,0/29,101,143/181,181,181/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "181,181,181/34,118,167/255,198,0/255,198,0/29,101,143/255,24,0/29,101,143/255,24,0/29,101,143/151,151,151/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "211,211,211/34,118,167/255,231,0/255,198,0/29,101,143/255,28,0/29,101,143/255,24,0/29,101,143/151,151,151/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/181,181,181/34,118,167/181,181,181/29,101,143/29,101,143/255,28,0/34,118,167/151,151,151/98,103,103/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/211,211,211/34,118,167/34,118,167/34,118,167/255,24,0/151,151,151/151,151,151/98,103,103/114,116,117/98,103,103/4,14,89/-1,-1,-1/", + "-1,-1,-1/211,211,211/211,211,211/211,211,211/211,211,211/181,181,181/-1,-1,-1/-1,-1,-1/-1,-1,-1/98,103,103/5,17,107/5,17,107/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/7,23,146/7,23,146/255,198,0/4,14,89/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/7,23,146/7,23,146/", + }; + + public ParticleLegendaryHero(GadgetManager manager) + { + super(manager, "Legendary Hero", UtilText.splitLineToArray(C.cGray + "Rumor has it that a legendary hero once used these to save a far away kingdom.", LineFormat.LORE), PARTICLE, CostConstants.FOUND_IN_TREASURE_CHESTS, Material.DIAMOND_SWORD, (byte) 0); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleMacawWings.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleMacawWings.java new file mode 100644 index 000000000..06b9b8a68 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleMacawWings.java @@ -0,0 +1,48 @@ +package mineplex.core.gadget.gadgets.particle; + +import org.bukkit.Material; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.util.CostConstants; + +public class ParticleMacawWings extends ParticleImageGadget +{ + + private static final String[] PARTICLE = + { + "12,32,163/0,32,171/12,31,163/0,27,143/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "49,29,139/27,30,153/25,30,155/0,32,171/0,32,171/5,34,167/9,31,136/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/54,27,135/50,28,138/0,32,171/16,39,158/33,47,145/22,42,154/16,41,158/8,39,161/7,35,131/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/108,22,99/100,23,104/0,32,171/48,40,138/67,63,118/41,56,134/37,68,122/22,54,141/32,74,115/7,37,163/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/159,17,64/46,37,139/77,41,118/65,58,122/88,79,99/36,77,112/31,75,114/48,95,86/14,43,154/3,30,138/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/203,11,34/174,27,53/125,47,84/128,82,72/111,91,80/31,83,106/62,119,57/29,55,136/24,54,139/20,71,122/5,45,154/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/226,7,19/201,22,35/145,43,70/133,101,62/101,85,90/40,122,68/59,121,58/58,79,101/39,66,121/31,102,85/10,59,137/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/242,3,8/220,17,22/162,58,55/173,99,36/182,130,9/164,130,11/78,128,38/75,82,93/76,115,55/42,117,68/21,74,120/30,67,128/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/255,0,0/255,0,0/216,22,24/190,56,36/227,76,9/222,80,5/213,112,6/152,132,13/114,140,15/1,165,19/60,107,79/72,112,74/36,72,123/38,73,124/-1,-1,-1/", + "-1,-1,-1/255,0,0/255,0,0/234,16,12/233,62,11/238,49,8/234,50,2/221,134,5/226,150,5/103,171,13/100,134,49/84,122,62/34,89,103/37,81,113/39,82,114/40,84,115/", + "-1,-1,-1/255,0,0/255,0,0/255,0,0/238,49,8/249,45,0/240,80,1/241,66,1/242,121,3/197,147,17/131,138,39/88,131,53/79,123,64/57,103,88/59,104,89/59,104,89/", + "-1,-1,-1/-1,-1,-1/255,0,0/255,0,0/255,0,0/251,30,0/245,53,0/250,26,0/255,186,0/255,186,0/176,161,27/96,136,54/63,148,40/0,171,12/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/255,0,0/255,0,0/255,0,0/255,0,0/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/255,0,0/255,0,0/255,0,0/255,0,0/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/255,0,0/255,0,0/255,0,0/251,30,0/245,53,0/250,26,0/255,186,0/255,186,0/176,161,27/96,136,54/63,148,40/0,171,12/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/255,0,0/255,0,0/255,0,0/238,49,8/249,45,0/240,80,1/241,66,1/242,121,3/197,147,17/131,138,39/88,131,53/79,123,64/57,103,88/59,104,89/59,104,89/", + "-1,-1,-1/255,0,0/255,0,0/234,16,12/233,62,11/238,49,8/234,50,2/221,134,5/226,150,5/103,171,13/100,134,49/84,122,62/34,89,103/37,81,113/39,82,114/40,84,115/", + "-1,-1,-1/255,0,0/255,0,0/216,22,24/190,56,36/227,76,9/222,80,5/213,112,6/152,132,13/114,140,15/1,165,19/60,107,79/72,112,74/36,72,123/38,73,124/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/242,3,8/220,17,22/162,58,55/173,99,36/182,130,9/164,130,11/78,128,38/75,82,93/76,115,55/42,117,68/21,74,120/30,67,128/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/226,7,19/201,22,35/145,43,70/133,101,62/101,85,90/40,122,68/59,121,58/58,79,101/39,66,121/31,102,85/10,59,137/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/203,11,34/174,27,53/125,47,84/128,82,72/111,91,80/31,83,106/62,119,57/29,55,136/24,54,139/20,71,122/5,45,154/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/-1,-1,-1/159,17,64/46,37,139/77,41,118/65,58,122/88,79,99/36,77,112/31,75,114/48,95,86/14,43,154/3,30,138/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/108,22,99/100,23,104/0,32,171/48,40,138/67,63,118/41,56,134/37,68,122/22,54,141/32,74,115/7,37,163/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "-1,-1,-1/54,27,135/50,28,138/0,32,171/16,39,158/33,47,145/22,42,154/16,41,158/8,39,161/7,35,131/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "49,29,139/27,30,153/25,30,155/0,32,171/0,32,171/5,34,167/9,31,136/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "12,32,163/0,32,171/12,31,163/0,27,143/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + }; + + public ParticleMacawWings(GadgetManager manager) + { + super(manager, "Macaw Wings", UtilText.splitLineToArray(C.cGray + "Show off your dazzling colors with this amazing set of parrot wings!", LineFormat.LORE), PARTICLE, CostConstants.LEVEL_REWARDS, Material.FEATHER, (byte) 0); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticlePartyTime.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticlePartyTime.java index a3944317c..24436439d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticlePartyTime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticlePartyTime.java @@ -2,30 +2,18 @@ package mineplex.core.gadget.gadgets.particle; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; import java.util.List; -import java.util.Map; -import java.util.Set; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.entity.Item; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilItem; -import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilText; -import mineplex.core.disguise.disguises.DisguiseArmorStand; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.updater.UpdateType; @@ -34,8 +22,6 @@ import mineplex.core.updater.event.UpdateEvent; public class ParticlePartyTime extends ParticleGadget { - private Map> _hiddenDrops = new HashMap<>(); - private Byte[] _data = new Byte[]{1, 2, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15}; public ParticlePartyTime(GadgetManager manager) @@ -48,7 +34,10 @@ public class ParticlePartyTime extends ParticleGadget @Override public void playParticle(Player player, UpdateEvent event) { - if (event.getType() != UpdateType.TICK) return; + if (event.getType() != UpdateType.TICK) + { + return; + } Location loc = player.getLocation().add(Math.random() * 2 - 1, 2.3 + Math.random() * 0.7, Math.random() * 2 - 1); @@ -65,59 +54,6 @@ public class ParticlePartyTime extends ParticleGadget { UtilParticle.playParticleFor(player, particle, loc, null, 0.08f, 10, ViewDist.NORMAL); } - - } - - if (getSet() != null && getSet().isActive(player)) - { - if (player.getTicksLived() % 10 == 0) - { - Location spawnLoc = player.getLocation().add(0, 2.5, 0); - Vector v = Vector.getRandom().subtract(Vector.getRandom()).setY(0).normalize().multiply(0.3).setY(0.3 + 0.3 * Math.random()); - byte data = _data[UtilMath.r(_data.length)]; - ItemStack stack = new ItemStack(Material.INK_SACK, 1, (short) 0, data); - Item item = UtilItem.dropItem(stack, spawnLoc, false, false, 10, true); - item.setVelocity(v); - - _hiddenDrops.computeIfAbsent(player, key -> new HashSet<>()).add(item); - DisguiseArmorStand stand = new DisguiseArmorStand(item); - stand.setInvisible(true); - Manager.getDisguiseManager().disguise(stand); - - String particle = ParticleType.ICON_CRACK.getParticle(Material.INK_SACK, data); - UtilParticle.playParticleFor(player, particle, spawnLoc, null, 0.08f, 30, ViewDist.NORMAL); - } } } - - @Override - public void stopEffect(Player player) - { - _hiddenDrops.remove(player); - } - - @EventHandler - public void onUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) return; - - _hiddenDrops.forEach((key, value) -> - { - for (Iterator it = value.iterator(); it.hasNext(); ) - { - Item item = it.next(); - if (!item.isValid()) - { - it.remove(); - return; - } - -// Bukkit.broadcastMessage("Item still alive: " + item.getTicksLived()); - - String particle = ParticleType.ICON_CRACK.getParticle(item.getItemStack().getType(), item.getItemStack().getData().getData()); - UtilParticle.playParticleFor(key, particle, item.getLocation(), null, 0, 3, ViewDist.NORMAL); - } - }); - } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRain.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRain.java index b9861e992..9c2831595 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRain.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRain.java @@ -38,10 +38,10 @@ public class ParticleRain extends ParticleGadget else { Location loc = player.getLocation().add(0, 3.5, 0); - UtilParticle.PlayParticle(ParticleType.EXPLODE, loc, 0.6f, 0f, 0.6f, 0, 8, ViewDist.NORMAL, player); - UtilParticle.PlayParticle(ParticleType.CLOUD, loc, 0.6f, 0.1f, 0.6f, 0, 8, ViewDist.NORMAL); + UtilParticle.PlayParticle(ParticleType.EXPLODE, loc, 0.6f, 0f, 0.6f, 0, 5, ViewDist.NORMAL, player); + UtilParticle.PlayParticle(ParticleType.CLOUD, loc, 0.6f, 0.1f, 0.6f, 0, 5, ViewDist.NORMAL); - UtilParticle.playParticleFor(player, ParticleType.DRIP_WATER, loc, 0.4f, 0.1f, 0.4f, 0, 2, ViewDist.NORMAL); + UtilParticle.playParticleFor(player, ParticleType.DRIP_WATER, loc, 0.4f, 0.1f, 0.4f, 0, 1, ViewDist.NORMAL); // Sound player.getWorld().playSound(player.getLocation(), Sound.AMBIENCE_RAIN, 0.1f, 1f); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRainbowTrail.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRainbowTrail.java new file mode 100644 index 000000000..e97d30c52 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleRainbowTrail.java @@ -0,0 +1,50 @@ +package mineplex.core.gadget.gadgets.particle; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.set.SetRainbow; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.gadget.util.CostConstants; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class ParticleRainbowTrail extends ParticleGadget +{ + + private static final double Y_MOD = 0.18; + + public ParticleRainbowTrail(GadgetManager manager) + { + super(manager, "Trail of the Rainbow", UtilText.splitLineToArray(C.cGray + "Did you know Unicorn farts seem like flowers? The More You Know.", LineFormat.LORE), CostConstants.FOUND_IN_TREASURE_CHESTS, Material.WOOL, (byte) UtilMath.r(15)); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Location location = player.getLocation(); + location.setPitch(0); + location.subtract(location.getDirection().multiply(0.5)); + location.add(0, Y_MOD + Y_MOD * SetRainbow.COLOURS.length, 0); + + for (DustSpellColor colour : SetRainbow.COLOURS) + { + new ColoredParticle(ParticleType.MOB_SPELL_AMBIENT, colour, location.subtract(0, Y_MOD, 0)) + .display(); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java index 7edb0b416..19c2e30d8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleTitan.java @@ -46,7 +46,6 @@ public class ParticleTitan extends ParticleGadget double offset2 = (step / 31) * tick % 31; double r = 3; - boolean redstone = false; if (Manager.isMoving(player)) { @@ -69,7 +68,6 @@ public class ParticleTitan extends ParticleGadget loc.add(v); - if (redstone) UtilParticle.playParticleFor(player, ParticleType.RED_DUST, loc, 1, 0, 0, 1, 0, ViewDist.NORMAL); v.multiply(-1); UtilParticle.playParticleFor(player, ParticleType.FLAME, loc, v, 0.05f, 0, ViewDist.NORMAL); @@ -84,7 +82,6 @@ public class ParticleTitan extends ParticleGadget loc.add(v); - if (redstone) UtilParticle.playParticleFor(player, ParticleType.RED_DUST, loc, 1, 0, 0, 1, 0, ViewDist.NORMAL); v.multiply(-1); UtilParticle.playParticleFor(player, ParticleType.FLAME, loc, v, 0.05f, 0, ViewDist.NORMAL); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleWitchsCure.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleWitchsCure.java new file mode 100644 index 000000000..b143887fa --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleWitchsCure.java @@ -0,0 +1,73 @@ +package mineplex.core.gadget.gadgets.particle; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.gadget.util.CostConstants; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class ParticleWitchsCure extends ParticleGadget +{ + + private static final double RADIUS = 1.8; + private static final double DELTA_THETA = Math.PI / 30; + private static final double DELTA_THETA_2 = Math.PI / 2; + + private double _theta; + + public ParticleWitchsCure(GadgetManager manager) + { + super(manager, "Witch's Curse", UtilText.splitLineToArray(C.cGray + "A said I put a curse on yee.", LineFormat.LORE), CostConstants.LEVEL_REWARDS, Material.SPIDER_EYE, (byte) 0); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + Location location = player.getLocation().add(0, 0.7, 0); + + if (Manager.isMoving(player)) + { + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, location, null, 0, 1, ViewDist.NORMAL); + } + else + { + for (double theta = 0; theta < 2 * Math.PI; theta += DELTA_THETA_2) + { + double sin = Math.sin(theta + _theta); + double x = RADIUS * Math.cos(theta + _theta), z = RADIUS * sin; + + sin /= 4; + + location.add(x, sin, z); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, location, null, 0, 1, ViewDist.NORMAL); + + location.subtract(x, sin, z); + } + } + } + + @Override + @EventHandler + public void Caller(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + _theta += DELTA_THETA; + super.Caller(event); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleWolfTail.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleWolfTail.java new file mode 100644 index 000000000..03e7c15ae --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleWolfTail.java @@ -0,0 +1,32 @@ +package mineplex.core.gadget.gadgets.particle; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.util.CostConstants; + +public class ParticleWolfTail extends ParticleImageGadget +{ + + private static final String[] PARTICLE = + { + "-1,-1,-1/121,121,121/119,119,119/123,123,123/128,128,128/-1,-1,-1/-1,-1,-1/-1,-1,-1/", + "100,100,100/109,109,109/116,116,116/122,122,122/129,129,129/143,143,143/157,157,157/-1,-1,-1/", + "92,92,92/100,100,100/113,113,113/118,118,118/127,127,127/143,143,143/167,167,167/194,194,194/", + "91,91,91/102,102,102/110,110,110/120,120,120/128,128,128/144,144,144/171,171,171/204,204,204/", + "96,96,96/101,101,101/108,108,108/-1,-1,-1/-1,-1,-1/-1,-1,-1/187,187,187/221,221,221/", + "-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/-1,-1,-1/244,244,244/", + }; + + public ParticleWolfTail(GadgetManager manager) + { + super(manager, "Wolf Tail", UtilText.splitLineToArray(C.cGray + "On all levels except physical.", LineFormat.LORE), PARTICLE, CostConstants.FOUND_IN_TREASURE_CHESTS, Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.WOLF)); + + _yOffset = 0.5; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleYinYang.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleYinYang.java index 19cd7705c..0ac07ea1d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleYinYang.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleYinYang.java @@ -1,5 +1,8 @@ package mineplex.core.gadget.gadgets.particle; +import net.md_5.bungee.api.ChatColor; +import net.minecraft.server.v1_8_R3.MathHelper; + import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; @@ -7,19 +10,20 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilColor; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.gadget.util.CostConstants; import mineplex.core.recharge.Recharge; import mineplex.core.recharge.RechargeData; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import net.md_5.bungee.api.ChatColor; -import net.minecraft.server.v1_8_R3.MathHelper; public class ParticleYinYang extends ParticleGadget { @@ -28,63 +32,70 @@ public class ParticleYinYang extends ParticleGadget { super(manager, "Yin and Yang", UtilText.splitLineToArray(ChatColor.GRAY + "Achieve the balance of the universe and watch it spin beneath your feet.", LineFormat.LORE), - -2, Material.RECORD_9, (byte) 0); + CostConstants.FOUND_IN_TREASURE_CHESTS, Material.RECORD_9, (byte) 0); } @Override public void playParticle(Player player, UpdateEvent event) { - if(event.getType() != UpdateType.TICK) return; - - float step = (float) (Math.PI/30); - step *= event.getTick()%60; - - float x = MathHelper.sin(step)*0.3f; + if (event.getType() != UpdateType.TICK) return; + + float step = (float) (Math.PI / 30); + step *= event.getTick() % 60; + + float x = MathHelper.sin(step) * 0.3f; float y = 0; - float z = MathHelper.cos(step)*0.3f; - + float z = MathHelper.cos(step) * 0.3f; + Location loc = player.getLocation().add(0, 0.2, 0); - - RechargeData r = Recharge.Instance.Get(player).get("Yin and Yang Move"); - - if(Manager.isMoving(player)) + boolean setBonus = getSet().isActive(player); + RechargeData r = Recharge.Instance.Get(player).get(getName()); + + if (Manager.isMoving(player)) { long time = 50; - if(r != null) + if (r != null) { time = Math.min(1000, r.GetRemaining() + 200); } - Recharge.Instance.useForce(player, "Yin and Yang Move", time); + Recharge.Instance.useForce(player, getName(), time); } - - if(r != null) { - float d = r.GetRemaining()/1000f; + + if (r != null) + { + float d = r.GetRemaining() / 1000f; y = 0.3f * d; - x *= 0.1 + ((1-d) * 0.9); - z *= 0.1 + ((1-d) * 0.9); + x *= 0.1 + ((1 - d) * 0.9); + z *= 0.1 + ((1 - d) * 0.9); } - + UtilParticle.playParticleFor(player, ParticleType.FIREWORKS_SPARK, loc, new Vector(x, y, z), 1, 0, ViewDist.NORMAL); UtilParticle.playParticleFor(player, ParticleType.FIREWORKS_SPARK, loc, new Vector(-x, y, -z), 1, 0, ViewDist.NORMAL); - - if(y == 0) + + if (y == 0) { int a = 2; - - double x2 = Math.sin(step + Math.PI/2); - double z2 = Math.cos(step + Math.PI/2); - + + double x2 = Math.sin(step + Math.PI / 2); + double z2 = Math.cos(step + Math.PI / 2); + Vector v = new Vector(x2, 0, z2).multiply(1.5); - - for(int i = 0; i < a; i++) + DustSpellColor color = new DustSpellColor(Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256))); + + if (setBonus) { - UtilParticle.playParticleFor(player, ParticleType.RED_DUST, loc.clone().add(v), - UtilColor.colorToVector(Color.BLACK), 1, 0, ViewDist.NORMAL); - UtilParticle.playParticleFor(player, ParticleType.RED_DUST, loc.clone().subtract(v), - UtilColor.colorToVector(Color.BLACK), 1, 0, ViewDist.NORMAL); + new ColoredParticle(ParticleType.RED_DUST, color, loc.clone().add(v)) + .display(); + new ColoredParticle(ParticleType.RED_DUST, color, loc.clone().subtract(v)) + .display(); + } + else + { + UtilParticle.playParticleFor(player, ParticleType.SMOKE, loc.clone().add(v), null, 0, 2, ViewDist.NORMAL); + UtilParticle.playParticleFor(player, ParticleType.SMOKE, loc.clone().subtract(v), null, 0, 2, ViewDist.NORMAL); } } - + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/spring/ParticleSpringHalo.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/spring/ParticleSpringHalo.java index f9afe33c0..03525bbcf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/spring/ParticleSpringHalo.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/spring/ParticleSpringHalo.java @@ -1,10 +1,8 @@ package mineplex.core.gadget.gadgets.particle.spring; -import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; -import java.util.List; import java.util.Map; +import java.util.concurrent.TimeUnit; import org.bukkit.Material; import org.bukkit.block.Block; @@ -13,34 +11,29 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.ItemStack; -import mineplex.core.arcadeevents.CoreGameStartEvent; -import mineplex.core.arcadeevents.CoreGameStopEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.RGBData; import mineplex.core.common.util.UtilColor; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilTime; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.OutfitGadget; import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.particleeffects.ColoredCircleEffect; -import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; public class ParticleSpringHalo extends ParticleGadget { - private Map _effects = new HashMap<>(); - private List _springHaloData = new ArrayList<>(); - private Map> _playerSpringHaloData = new HashMap<>(); - private boolean _enableTrail = true; + private static final long BLOCK_TIME = TimeUnit.SECONDS.toMillis(8); + + private final Map _effects = new HashMap<>(); public ParticleSpringHalo(GadgetManager manager) { - super(manager, "Spring Halo", UtilText.splitLinesToArray(new String[]{C.cGray + "Spring is everywhere, if you look hard enough."}, LineFormat.LORE), + super(manager, "Spring Halo", UtilText.splitLinesToArray(new String[] {C.cGray + "Spring is everywhere, if you look hard enough."}, LineFormat.LORE), -19, Material.YELLOW_FLOWER, (byte) 0); } @@ -78,19 +71,6 @@ public class ParticleSpringHalo extends ParticleGadget } _effects.remove(player); player.getInventory().setHelmet(null); - if (_playerSpringHaloData.containsKey(player)) - { - Iterator iterator = _playerSpringHaloData.get(player).iterator(); - while (iterator.hasNext()) - { - SpringHaloData springHaloData = iterator.next(); - springHaloData.getBlock().setType(Material.AIR); - springHaloData.getBlock().setData((byte) 0); - iterator.remove(); - } - _playerSpringHaloData.get(player).clear(); - _playerSpringHaloData.remove(player); - } } @Override @@ -101,84 +81,23 @@ public class ParticleSpringHalo extends ParticleGadget @EventHandler public void spawnFlowers(PlayerMoveEvent event) { - if (!isActive(event.getPlayer())) + if (!isActive(event.getPlayer()) || Manager.isGameLive()) + { return; - - if (!_enableTrail) - return; - - Player player = event.getPlayer(); + } Block block = event.getFrom().getBlock(); - if (block.getType() != Material.AIR) + + if (block.getType() != Material.AIR || Manager.getBlockRestore().contains(block)) + { return; + } - if (block.getLocation().subtract(0, 1, 0).getBlock().getType() != Material.GRASS - && block.getLocation().subtract(0, 1, 0).getBlock().getType() != Material.DIRT) + if (block.getLocation().subtract(0, 1, 0).getBlock().getType() != Material.GRASS && block.getLocation().subtract(0, 1, 0).getBlock().getType() != Material.DIRT) + { return; - - block.setType(Material.RED_ROSE); - block.setData((byte) UtilMath.random.nextInt(8)); - SpringHaloData springHaloData = new SpringHaloData(player, block, System.currentTimeMillis()); - addFlower(player, springHaloData); - } - - @EventHandler - public void onUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - Iterator iterator = _springHaloData.iterator(); - while (iterator.hasNext()) - { - SpringHaloData springHaloData = iterator.next(); - if (UtilTime.elapsed(springHaloData.getSpawned(), 1500)) - { - springHaloData.getBlock().setType(Material.AIR); - springHaloData.getBlock().setData((byte) 0); - removeSpringHalo(springHaloData); - iterator.remove(); - } } - } - private void addFlower(Player player, SpringHaloData springHaloData) - { - _springHaloData.add(springHaloData); - if (_playerSpringHaloData.containsKey(player)) - { - List list = _playerSpringHaloData.get(player); - list.add(springHaloData); - } - else - { - List list = new ArrayList<>(); - list.add(springHaloData); - _playerSpringHaloData.put(player, list); - } + Manager.getBlockRestore().add(block, Material.RED_ROSE.getId(), (byte) UtilMath.random.nextInt(8), BLOCK_TIME); } - - private void removeSpringHalo(SpringHaloData springHaloData) - { - Player player = springHaloData.getPlayer(); - List list = _playerSpringHaloData.get(player); - if (list != null) - { - list.remove(springHaloData); - } - } - - @EventHandler - public void onGameStart(CoreGameStartEvent event) - { - _enableTrail = false; - } - - @EventHandler - public void onGameEnd(CoreGameStopEvent event) - { - _enableTrail = true; - } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/spring/SpringHaloData.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/spring/SpringHaloData.java deleted file mode 100644 index c497b99a9..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/spring/SpringHaloData.java +++ /dev/null @@ -1,34 +0,0 @@ -package mineplex.core.gadget.gadgets.particle.spring; - -import org.bukkit.block.Block; -import org.bukkit.entity.Player; - -public class SpringHaloData -{ - - private Player _player; - private Block _block; - private long _spawned; - - public SpringHaloData(Player player, Block block, long spawned) - { - _player = player; - _block = block; - _spawned = spawned; - } - - public Player getPlayer() - { - return _player; - } - - public Block getBlock() - { - return _block; - } - - public long getSpawned() - { - return _spawned; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EasyModeTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EasyModeTaunt.java new file mode 100644 index 000000000..4e5e7f42b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EasyModeTaunt.java @@ -0,0 +1,95 @@ +package mineplex.core.gadget.gadgets.taunts; + +import java.util.concurrent.TimeUnit; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.TauntGadget; +import mineplex.core.gadget.util.CostConstants; +import mineplex.core.particleeffects.TextEffect; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; + +public class EasyModeTaunt extends TauntGadget +{ + + private static final long COOLDOWN = TimeUnit.SECONDS.toMillis(30); + private static final String[] TEXT = + { + "Is", + "this", + "easy", + "mode?" + }; + + public EasyModeTaunt(GadgetManager manager) + { + super(manager, "Easy Mode Taunt", new String[] + { + C.cGray + "You think to yourself, this can't be this easy.", + C.blankLine, + C.cWhite + "Use /taunt in game to use this taunt.", + C.cGreen + "Can be used while in PvP!" + }, CostConstants.NO_LORE, Material.SKULL_ITEM, (byte) 3); + + setCanPlayWithPvp(true); + setEventType(UpdateType.FASTER); + } + + @Override + public boolean onStart(Player player) + { + if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) + { + return false; + } + + Location location = player.getLocation().add(0, 5, 0); + + Bukkit.broadcastMessage(F.main("Taunt", F.name(player.getName()) + " thought to themselves... " + F.elem("Is this easy mode?"))); + + TextEffect effect = new TextEffect(Integer.MAX_VALUE, TEXT[0], location, true, false, ParticleType.FLAME); + effect.start(); + + Manager.runSyncTimer(new BukkitRunnable() + { + int index = 0; + + @Override + public void run() + { + if (index == TEXT.length) + { + cancel(); + effect.stop(); + finish(player); + return; + } + + location.getWorld().playSound(location, Sound.VILLAGER_IDLE, 1, (float) (0.5F + Math.random())); + effect.setText(TEXT[index++]); + } + }, 0, 20); + + return true; + } + + @Override + public void onPlay(Player player) + { + } + + @Override + public void onFinish(Player player) + { + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EmojiTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EmojiTaunt.java new file mode 100644 index 000000000..ffe859865 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EmojiTaunt.java @@ -0,0 +1,92 @@ +package mineplex.core.gadget.gadgets.taunts; + +import java.util.concurrent.TimeUnit; + +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.TauntGadget; +import mineplex.core.gadget.util.CostConstants; +import mineplex.core.particleeffects.TextEffect; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; + +public class EmojiTaunt extends TauntGadget +{ + + private static final long COOLDOWN = TimeUnit.SECONDS.toMillis(30); + private static final int TICKS = 40; + private static final String[] EMOJIS = + { + ":)", + ";)", + ";o", + "<3" + }; + private static final FireworkEffect FIREWORK_EFFECT = FireworkEffect.builder() + .with(Type.STAR) + .withColor(Color.RED) + .withFade(Color.WHITE) + .withFlicker() + .build(); + + public EmojiTaunt(GadgetManager manager) + { + super(manager, "Emoji Taunt", new String[] + { + C.cGray + "Winky face ;p", + C.blankLine, + C.cWhite + "Use /taunt in game to use this taunt.", + C.cGreen + "Can be used while in PvP!" + }, CostConstants.NO_LORE, Material.CAKE, (byte) 0); + + setCanPlayWithPvp(true); + setShouldPlay(true); + setEventType(UpdateType.FASTER); + } + + @Override + public boolean onStart(Player player) + { + if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) + { + return false; + } + + Location location = player.getLocation().add(0, 5, 0); + String emoji = UtilMath.randomElement(EMOJIS); + + Bukkit.broadcastMessage(F.main("Taunt", F.name(player.getName()) + " : " + F.name(emoji))); + + UtilFirework.playFirework(location, FIREWORK_EFFECT); + new TextEffect(TICKS, emoji, location, false, false, ParticleType.FLAME) + .start(); + + return true; + } + + @Override + public void onPlay(Player player) + { + if (getPlayerTicks(player) >= TICKS) + { + finish(player); + } + } + + @Override + public void onFinish(Player player) + { + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/FrostBreathTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/FrostBreathTaunt.java index 8325479fa..2f204f118 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/FrostBreathTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/FrostBreathTaunt.java @@ -28,7 +28,7 @@ import mineplex.core.recharge.Recharge; public class FrostBreathTaunt extends TauntGadget { - private static final long COOLDOWN = TimeUnit.SECONDS.toMillis(3); + private static final long COOLDOWN = TimeUnit.SECONDS.toMillis(20); private static final int TICKS = 80; private static final double MAX_RADIUS = 1.3; private static final ItemStack[] TO_DROP = diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/weaponname/WeaponNameType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/weaponname/WeaponNameType.java new file mode 100644 index 000000000..9a83addb6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/weaponname/WeaponNameType.java @@ -0,0 +1,126 @@ +package mineplex.core.gadget.gadgets.weaponname; + +import org.bukkit.Material; + +import mineplex.core.common.util.C; +import mineplex.core.gadget.types.WeaponNameGadget.WeaponType; +import mineplex.core.gadget.util.CostConstants; + +public enum WeaponNameType +{ + + SWORD_WOOD_SPLINTER(WeaponType.WOOD_SWORD, "Splinter", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.STICK), + SWORD_WOOD_THORN(WeaponType.WOOD_SWORD, "Thorn", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.RED_ROSE), + SWORD_WOOD_TOOTHPICK(WeaponType.WOOD_SWORD, "Kevin’s Lost Toothpick", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.GRASS), + SWORD_WOOD_STRIKER(WeaponType.WOOD_SWORD, "Striker", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.BLAZE_ROD), + SWORD_WOOD_THORN_BUSH(WeaponType.WOOD_SWORD, "Thorn Bush", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.DOUBLE_PLANT, (byte) 4), + SWORD_WOOD_HOWLING_SWORD(WeaponType.WOOD_SWORD, "Howling Sword", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.BONE), + SWORD_WOOD_QUiCK_BLADE(WeaponType.WOOD_SWORD, "Quick Blade", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.FEATHER), + SWORD_WOOD_WINTER_THORN(WeaponType.WOOD_SWORD, "Winterthorn", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.SNOW_BALL), + SWORD_WOOD_SPIKE(WeaponType.WOOD_SWORD, "Needle", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.TORCH), + SWORD_WOOD_LONGSWORD(WeaponType.WOOD_SWORD, "Longsword", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.WOOD_SWORD), + SWORD_WOOD_WHISPER(WeaponType.WOOD_SWORD, "Whisper", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.STRING), + SWORD_WOOD_BRUISER(WeaponType.WOOD_SWORD, "Bruiser", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.MAGMA_CREAM), + + SWORD_STONE_SPLINTER(WeaponType.STONE_SWORD, "Heart of the Mountain", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.STONE_PICKAXE), + SWORD_STONE_QUERN(WeaponType.STONE_SWORD, "Quern-Biter", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.IRON_SPADE), + SWORD_STONE_GRAVEN_EDGE(WeaponType.STONE_SWORD, "Graven Edge", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.STONE), + SWORD_STONE_PROTECTOR(WeaponType.STONE_SWORD, "Protector", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.DIAMOND_CHESTPLATE), + SWORD_STONE_GHOST_REAVER(WeaponType.STONE_SWORD, "Ghost Reaver", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.SKULL_ITEM, (byte) 1), + SWORD_STONE_SKULL_CRUSHER(WeaponType.STONE_SWORD, "Skullcrusher", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.SKULL_ITEM), + SWORD_STONE_RAGNAROK(WeaponType.STONE_SWORD, "Ragnarok", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.LAVA_BUCKET), + SWORD_STONE_WARMONGER(WeaponType.STONE_SWORD, "Warmonger", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.BEACON), + SWORD_STONE_GUTRENDER(WeaponType.STONE_SWORD, "Gutrender", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.REDSTONE), + SWORD_STONE_FROSTY(WeaponType.STONE_SWORD, "Frosty Greatsword", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.SNOW_BALL), + SWORD_STONE_SHADOW(WeaponType.STONE_SWORD, "Shadowstrike", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.INK_SACK), + SWORD_STONE_TENDERIZER(WeaponType.STONE_SWORD, "Tenderizer", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.RAW_BEEF), + + SWORD_GOLD_DIGGER(WeaponType.GOLD_SWORD, "Gold Digger", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.GOLD_PICKAXE), + SWORD_GOLD_PEACEKEEPER(WeaponType.GOLD_SWORD, "Peacekeeper", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.GOLD_HELMET), + SWORD_GOLD_GLADIUS(WeaponType.GOLD_SWORD, "Gladius", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.YELLOW_FLOWER), + SWORD_GOLD_GHOST_WALKER(WeaponType.GOLD_SWORD, "Ghostwalker", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.DIAMOND_HOE), + SWORD_GOLD_SCAR(WeaponType.GOLD_SWORD, "Scar", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.ANVIL, (byte) 2), + SWORD_GOLD_BURN(WeaponType.GOLD_SWORD, "Burn", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.LAVA_BUCKET), + SWORD_GOLD_SUNSTRIKE(WeaponType.GOLD_SWORD, "Sun Strike", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.BLAZE_POWDER), + SWORD_GOLD_MAGEBLADE(WeaponType.GOLD_SWORD, "Mage Blade", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.POTION), + SWORD_GOLD_FLAMING_RAPIER(WeaponType.GOLD_SWORD, "Flaming Rapier", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.MAGMA_CREAM), + + SWORD_IRON_ALIEN(WeaponType.IRON_SWORD, "Alien Artifact", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.SLIME_BLOCK), + SWORD_IRON_STORMBRINGER(WeaponType.IRON_SWORD, "Stormbringer", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.WATER_BUCKET), + SWORD_IRON_STING(WeaponType.IRON_SWORD, "Sting", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.SHEARS), + SWORD_IRON_DRAGONFIRE(WeaponType.IRON_SWORD, "Dragonfire", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.DRAGON_EGG), + SWORD_IRON_HOPE(WeaponType.IRON_SWORD, "Hope's End", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.DETECTOR_RAIL), + SWORD_IRON_DOOMBRINGER(WeaponType.IRON_SWORD, "Doombringer", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.FIREBALL), + SWORD_IRON_STORMCALLER(WeaponType.IRON_SWORD, "Storm Caller", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.GHAST_TEAR), + SWORD_IRON_BLACKOUT(WeaponType.IRON_SWORD, "Black Out", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.WOOL, (byte) 15), + + SWORD_DIAMOND_ICE_HEART(WeaponType.DIAMOND_SWORD, "Ice Heart", C.cAquaB + "Ice Heart", CostConstants.NO_LORE, Material.ICE), + SWORD_DIAMOND_SHINY(WeaponType.DIAMOND_SWORD, "Oooh Shiny", C.cGoldB + "Oooh Shiny", CostConstants.NO_LORE, Material.GOLD_NUGGET), + SWORD_DIAMOND_DRAGONSLAYER(WeaponType.DIAMOND_SWORD, "Dragonslayer", C.cDRedB + "Dragonslayer", CostConstants.NO_LORE, Material.EYE_OF_ENDER), + SWORD_DIAMOND_OBLIVION(WeaponType.DIAMOND_SWORD, "Oblivion", C.cRedB + "Oblivion", CostConstants.NO_LORE, Material.ENDER_PEARL), + SWORD_DIAMOND_DEATHRAZE(WeaponType.DIAMOND_SWORD, "Deathraze", C.cRedB + "Deathraze", CostConstants.NO_LORE, Material.DARK_OAK_STAIRS), + SWORD_DIAMOND_OATHBREAKER(WeaponType.DIAMOND_SWORD, "Oathbreaker", C.cGreenB + "Oathbreaker", CostConstants.NO_LORE, Material.SPIDER_EYE), + SWORD_DIAMOND_VANQUISHER(WeaponType.DIAMOND_SWORD, "Vanquisher", C.cYellowB + "Vanquisher", CostConstants.NO_LORE, Material.DIAMOND_AXE), + SWORD_DIAMOND_NOBLE_PHANTASM(WeaponType.DIAMOND_SWORD, "Noble Phantasm", C.cAquaB + "Noble Phantasm", CostConstants.NO_LORE, Material.CAKE),; + + private final WeaponType _weaponType; + private final String _name, _display; + private final int _cost; + private final Material _material; + private final byte _materialData; + + WeaponNameType(WeaponType weaponType, String name, int cost, Material material) + { + this(weaponType, name, name, cost, material); + } + + WeaponNameType(WeaponType weaponType, String name, int cost, Material material, byte materialData) + { + this(weaponType, name, name, cost, material, materialData); + } + + WeaponNameType(WeaponType weaponType, String name, String display, int cost, Material material) + { + this(weaponType, name, display, cost, material, (byte) 0); + } + + WeaponNameType(WeaponType weaponType, String name, String display, int cost, Material material, byte materialData) + { + _weaponType = weaponType; + _name = name; + _display = display; + _cost = cost; + _material = material; + _materialData = materialData; + } + + public WeaponType getWeaponType() + { + return _weaponType; + } + + public String getName() + { + return _name; + } + + public String getDisplay() + { + return _display; + } + + public int getCost() + { + return _cost; + } + + public Material getMaterial() + { + return _material; + } + + public byte getMaterialData() + { + return _materialData; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectDragonRider.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectDragonRider.java deleted file mode 100644 index 2f630647c..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectDragonRider.java +++ /dev/null @@ -1,33 +0,0 @@ -package mineplex.core.gadget.gadgets.wineffect; - -import org.bukkit.Bukkit; -import org.bukkit.Material; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilText; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.WinEffectGadget; - -public class WinEffectDragonRider extends WinEffectGadget -{ - - public WinEffectDragonRider(GadgetManager manager) - { - super(manager, "Dragon Rider", UtilText.splitLineToArray(C.cGray + "Watch me on the podium riding this bad ass YOLO SWAG to da max epic DRAGON!", LineFormat.LORE), - 1, Material.DRAGON_EGG, (byte) 0); - } - - @Override - public void play() - { - Bukkit.broadcastMessage("Playing effect win effect: " + getName()); - } - - @Override - public void finish() - { - Bukkit.broadcastMessage("Playing effect win effect: " + getName()); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectEarthquake.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectEarthquake.java new file mode 100644 index 000000000..4309e9dce --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectEarthquake.java @@ -0,0 +1,148 @@ +package mineplex.core.gadget.gadgets.wineffect; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import org.bukkit.EntityEffect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.WinEffectGadget; +import mineplex.core.gadget.util.CostConstants; + +public class WinEffectEarthquake extends WinEffectGadget +{ + + private static final int DROP_HEIGHT = 25; + private static final int RADIUS = 8; + private static final int PERIOD = 5; + private static final double DELTA_SCALE = 0.1; + + public WinEffectEarthquake(GadgetManager manager) + { + super(manager, "Earthquake", UtilText.splitLineToArray(C.cGray + "Come crashing down on the losers and send them flying away!", LineFormat.LORE), CostConstants.NO_LORE, Material.STONE, (byte) 3); + + _schematicName = "TornadoPodium"; + _length = TimeUnit.SECONDS.toMillis(7); + } + + @Override + public void play() + { + Entity entity = getNPC(_player, getBaseLocation().add(0, DROP_HEIGHT, 0), true).getEntity().getBukkitEntity(); + List circle = UtilShapes.getPointsInCircle(getBaseLocation(), _other.size(), 4); + + int i = 0; + for (Player player : _other) + { + Location location = circle.get(i++); + location.add(UtilAlg.getTrajectory(getBaseLocation(), location).multiply(0.4 + Math.random() / 2)); + + getNPC(player, location, true).getEntity().getBukkitEntity(); + } + + Manager.runSyncTimer(new BukkitRunnable() + { + @Override + public void run() + { + if (entity.isValid() && !UtilEnt.isGrounded(entity)) + { + return; + } + + entity.getWorld().playSound(entity.getLocation(), Sound.EXPLODE, 3, 1); + Manager.runSyncTimer(new BukkitRunnable() + { + Map blocks = UtilBlock.getInRadius(getBaseLocation(), RADIUS); + Map entities = UtilEnt.getInRadius(getBaseLocation(), RADIUS); + double scale = 0.9; + + @Override + public void run() + { + blocks.entrySet().removeIf(entry -> + { + Block block = entry.getKey(); + + if (block.getType() == Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR || entry.getValue() > 0.9) + { + return true; + } + + if (scale < entry.getValue()) + { + if (Math.random() < 0.7) + { + Location location = block.getLocation().add(0.5, 1, 0.5); + double random = 0.5 + Math.random() / 2; + FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(location, block.getType(), block.getData()); + fallingBlock.setDropItem(false); + fallingBlock.setHurtEntities(false); + fallingBlock.setVelocity(UtilAlg.getTrajectory(entity, fallingBlock).multiply(0.3).setY(random)); + location.getWorld().playSound(location, Sound.DIG_GRASS, 2, (float) random); + } + + return true; + } + + return false; + }); + + entities.entrySet().removeIf(entry -> + { + LivingEntity nearby = entry.getKey(); + + if (nearby.equals(entity)) + { + return true; + } + + if (scale < entry.getValue()) + { + nearby.playEffect(EntityEffect.HURT); + UtilAction.velocity(nearby, UtilAlg.getTrajectory(getBaseLocation(), nearby.getLocation()), 2, true, 1, 0, 1, true); + return true; + } + + return false; + }); + + scale -= DELTA_SCALE; + + if (blocks.isEmpty()) + { + cancel(); + } + } + }, 0, PERIOD); + + cancel(); + } + }, 10, 1); + } + + @Override + public void finish() + { + + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFireworks.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFireworks.java deleted file mode 100644 index 18b3fb26d..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectFireworks.java +++ /dev/null @@ -1,79 +0,0 @@ -package mineplex.core.gadget.gadgets.wineffect; - -import org.bukkit.Color; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.event.EventHandler; -import org.bukkit.util.Vector; - -import mineplex.core.common.animation.AnimationPoint; -import mineplex.core.common.animation.AnimatorEntity; -import mineplex.core.common.util.C; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilText; -import mineplex.core.disguise.disguises.DisguisePlayer; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.WinEffectGadget; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - -public class WinEffectFireworks extends WinEffectGadget -{ - private DisguisePlayer _npc; - - public WinEffectFireworks(GadgetManager manager) - { - super(manager, "Fireworks", UtilText.splitLineToArray(C.cGray + "What’s more appropriate for victory than EXPLOSIONS?", LineFormat.LORE), - 1, Material.FIREWORK, (byte) 0); - - _schematicName = "FlatPodium"; - } - - @Override - public void play() - { - - int i = 0; - int points = 12; - double r = 3; - - Location start = getBaseLocation(); - start.add(0, 0, r); - start.setDirection(new Vector(1, 0, 0)); - - _npc = getNPC(_player, start); - AnimatorEntity animator = new AnimatorEntity(Manager.getPlugin(), _npc.getEntity().getBukkitEntity()); - - - for(double rad = 0; rad < Math.PI*2; rad+= Math.PI/points) - { - i++; - double s = Math.sin(rad)*3; - double c = Math.cos(rad)*3; - animator.addPoint(new AnimationPoint(2*i, new Vector(s, 0, c-r), new Vector(c, 0, -s))); - } - animator.setRepeat(true); - animator.start(start); - } - - @EventHandler - public void onUpdate(UpdateEvent event) - { - if(event.getType() != UpdateType.SEC) return; - if(!isRunning()) return; - - Location loc = _npc.getEntity().getBukkitEntity().getLocation(); - - UtilFirework.launchFirework(loc, Type.values()[UtilMath.r(Type.values().length)], - Color.fromRGB(UtilMath.r(255*255*255)), UtilMath.random.nextBoolean(), UtilMath.random.nextBoolean(), new Vector(0,0,0), 0); - } - - @Override - public void finish() - { - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectPartyAnimal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectPartyAnimal.java new file mode 100644 index 000000000..1c4c69fdb --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectPartyAnimal.java @@ -0,0 +1,120 @@ +package mineplex.core.gadget.gadgets.wineffect; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.WinEffectGadget; +import mineplex.core.gadget.util.CostConstants; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class WinEffectPartyAnimal extends WinEffectGadget +{ + + private static final EntityType[] ENTITY_TYPES = + { + EntityType.PIG, + EntityType.SHEEP, + EntityType.CHICKEN, + EntityType.COW + }; + private static final int ANIMALS = 20; + + private final Set _entities; + + public WinEffectPartyAnimal(GadgetManager manager) + { + super(manager, "Party Animal", new String[] + { + C.cGray + "Anyone want any cake?" + }, CostConstants.FOUND_IN_TREASURE_CHESTS, Material.CAKE, (byte) 0); + + _schematicName = "CakePodium"; + _entities = new HashSet<>(); + } + + @Override + public void play() + { + _entities.add((LivingEntity) getNPC(_player, getBaseLocation(), false).getEntity().getBukkitEntity()); + List circle = UtilShapes.getPointsInCircle(getBaseLocation(), ANIMALS, 6); + + int i = 0; + for (Location location : circle) + { + if (location.getBlock().getType() != Material.AIR) + { + location.add(0, 1, 0); + } + + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, getBaseLocation()))); + location.setPitch(UtilMath.rRange(-2, 5)); + + LivingEntity entity = (LivingEntity) location.getWorld().spawnEntity(location, UtilMath.randomElement(ENTITY_TYPES)); + + UtilEnt.vegetate(entity, true); + UtilEnt.setFakeHead(entity, true); + + if (i < _other.size()) + { + entity.setCustomName(C.cYellow + _other.get(i++).getName()); + entity.setCustomNameVisible(true); + } + + _entities.add(entity); + } + } + + @Override + public void finish() + { + _entities.clear(); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER || !isRunning()) + { + return; + } + + _entities.forEach(entity -> + { + double random = Math.random(); + + if (random > 0.3 || !UtilEnt.isGrounded(entity)) + { + return; + } + + entity.setVelocity(new Vector(0, 0.3 + UtilMath.random(0.2, 0.5), 0)); + + if (random < 0.15) + { + UtilFirework.launchFirework(entity.getLocation(), FireworkEffect.builder() + .with(Type.values()[UtilMath.r(Type.values().length)]) + .withColor(Color.fromRGB(UtilMath.r(256), UtilMath.r(256), UtilMath.r(256))) + .build(), null, 2); + } + }); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectTornado.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectTornado.java index 7e2d8c025..e3f07f59c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectTornado.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectTornado.java @@ -8,12 +8,9 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.block.Block; import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; @@ -23,14 +20,12 @@ import mineplex.core.common.animation.Animator; import mineplex.core.common.animation.AnimatorEntity; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.MapUtil; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.WinEffectGadget; +import mineplex.core.gadget.util.CostConstants; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -43,10 +38,11 @@ public class WinEffectTornado extends WinEffectGadget private static final double DELTA_Y = 0.5 / (2 * Math.PI); private static final double DELTA_R = DELTA_Y / 4; private static final List LOCATION_DELTAS; - private static final ItemStack[] BLOCKS = { - new ItemStack(Material.DIRT), - new ItemStack(Material.GRASS) - }; + private static final ItemStack[] BLOCKS = + { + new ItemStack(Material.DIRT), + new ItemStack(Material.GRASS) + }; static { @@ -79,7 +75,6 @@ public class WinEffectTornado extends WinEffectGadget private DisguisePlayer _npc; private Animator _animator; private Map _stands; - private List _destructibleBlocks; private boolean _spawnBlocks; public WinEffectTornado(GadgetManager manager) @@ -88,7 +83,7 @@ public class WinEffectTornado extends WinEffectGadget UtilText.splitLineToArray( C.cGray + "Capable of reaching EF-5 on the Fujita scale! This will really show your fellow players how strong you really are.", LineFormat.LORE ), - -14, Material.DIRT, (byte) 0); + CostConstants.POWERPLAY_BONUS, Material.DIRT, (byte) 0); _schematicName = "TornadoPodium"; setPPCYearMonth(YearMonth.of(2017, Month.SEPTEMBER)); @@ -123,17 +118,6 @@ public class WinEffectTornado extends WinEffectGadget }, 20); _stands = new HashMap<>(ARRAY_SIZE); - _destructibleBlocks = new ArrayList<>(200); - - for (Block block : UtilBlock.getInSquare(getBaseLocation().getBlock(), 25)) - { - if (block.getType() != Material.LEAVES && block.getType() != Material.LONG_GRASS) - { - continue; - } - - _destructibleBlocks.add(block.getLocation()); - } } @EventHandler @@ -144,31 +128,6 @@ public class WinEffectTornado extends WinEffectGadget return; } - for (int i = 0; i < 5; i++) - { - Location fallingSpawn = UtilAlg.Random(_destructibleBlocks); - - if (fallingSpawn != null) - { - fallingSpawn.add(0.5, 0.5, 0.5); - - if (Math.random() > 0.98) - { - Block block = fallingSpawn.getBlock(); - - block.getWorld().playEffect(fallingSpawn, Effect.STEP_SOUND, block.getType()); - - FallingBlock fallingBlock = fallingSpawn.getWorld().spawnFallingBlock(fallingSpawn, block.getType(), block.getData()); - fallingBlock.setHurtEntities(false); - fallingBlock.setDropItem(false); - fallingBlock.setVelocity(UtilAlg.getTrajectory2d(fallingBlock, _npc.getEntity().getBukkitEntity())); - } - - MapUtil.QuickChangeBlockAt(fallingSpawn, Material.AIR); - _destructibleBlocks.remove(fallingSpawn); - } - } - if (_stands.size() < LOCATION_DELTAS.size()) { _stands.put(spawnStand(), -1); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectWinterWarfare.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectWinterWarfare.java index 67a9abe9c..27dda9d48 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectWinterWarfare.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/WinEffectWinterWarfare.java @@ -28,6 +28,7 @@ import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.WinEffectGadget; import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; public class WinEffectWinterWarfare extends WinEffectGadget { @@ -88,8 +89,8 @@ public class WinEffectWinterWarfare extends WinEffectGadget super.teleport(loc); } - @Override - public void update(UpdateType type) + @EventHandler + public void update(UpdateEvent event) { if (!isRunning()) return; @@ -97,7 +98,7 @@ public class WinEffectWinterWarfare extends WinEffectGadget if (_sleighLocation == null) return; - if (type == UpdateType.FAST) + if (event.getType() == UpdateType.FAST) { if (_npc == null) return; @@ -108,7 +109,7 @@ public class WinEffectWinterWarfare extends WinEffectGadget UtilAction.velocity(tnt, vel, Math.abs(Math.sin(r * 12/3000d)), false, 0, 0.2 + Math.abs(Math.cos(r * 12/3000d))*0.6, 1, false); } - if (type != UpdateType.TICK) + if (event.getType() != UpdateType.TICK) return; // Teleports sleigh diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/persistence/UserGadgetPersistence.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/persistence/UserGadgetPersistence.java index 7439ae81c..7c615a633 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/persistence/UserGadgetPersistence.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/persistence/UserGadgetPersistence.java @@ -10,6 +10,7 @@ import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.GameModifierGadget; import mineplex.core.gadget.types.OutfitGadget; +import mineplex.core.gadget.types.WeaponNameGadget; public class UserGadgetPersistence { @@ -91,6 +92,15 @@ public class UserGadgetPersistence } } break; + case WEAPON_NAME: + WeaponNameGadget weaponNameGadget = (WeaponNameGadget) gadget; + key = weaponNameGadget.getGadgetType().getDatabaseKey() + weaponNameGadget.getWeaponNameType().getWeaponType().getId(); + + if (gadget.getName().equals(values.get(key))) + { + gadget.enable(player, false); + } + break; default: if (!values.containsKey(gadgetType.getDatabaseKey())) { @@ -151,6 +161,15 @@ public class UserGadgetPersistence } } break; + case WEAPON_NAME: + WeaponNameGadget weaponNameGadget = (WeaponNameGadget) gadget; + key = weaponNameGadget.getGadgetType().getDatabaseKey() + weaponNameGadget.getWeaponNameType().getWeaponType().getId(); + + if (enabled) + { + value = gadget.getName(); + } + break; default: key = gadgetType.getDatabaseKey(); if (enabled) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetBalance.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetBalance.java new file mode 100644 index 000000000..a6d9e790d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetBalance.java @@ -0,0 +1,27 @@ +package mineplex.core.gadget.set; + +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBalance; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailLegend; +import mineplex.core.gadget.gadgets.death.DeathBalance; +import mineplex.core.gadget.gadgets.death.DeathLegend; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBalance; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpLegend; +import mineplex.core.gadget.gadgets.particle.ParticleYinYang; +import mineplex.core.gadget.types.GadgetSet; + +public class SetBalance extends GadgetSet +{ + + public SetBalance(GadgetManager manager) + { + super(manager, "Balance", "Improved Yin Yang", + manager.getGadget(ArrowTrailBalance.class), + manager.getGadget(DeathBalance.class), + manager.getGadget(DoubleJumpBalance.class), + manager.getGadget(ParticleYinYang.class) + ); + } + + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java index dca2f191c..0ae59b019 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetCupidsLove.java @@ -12,7 +12,7 @@ public class SetCupidsLove extends GadgetSet public SetCupidsLove(GadgetManager manager) { - super(manager, "Cupid's Love", /*"Running into other players gives them hearts for 5 seconds."*/ "2x Holiday Points while active (Titles)", + super(manager, "Cupid's Love", "2x Holiday Points while active (Titles)", manager.getGadget(ArrowTrailCupid.class), manager.getGadget(DeathCupidsBrokenHeart.class), manager.getGadget(DoubleJumpCupidsWings.class), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java index 26df2fd6f..a3fa3d1a9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetEmerald.java @@ -12,7 +12,7 @@ public class SetEmerald extends GadgetSet public SetEmerald(GadgetManager manager) { - super(manager, "Emerald", /*"Press Shift to summon a Gem Party Bomb. 24 hour cooldown."*/ "2x Gem Points while active (Titles)", + super(manager, "Emerald", "2x Gem Points while active (Titles)", manager.getGadget(ArrowTrailEmerald.class), manager.getGadget(DeathEmerald.class), manager.getGadget(DoubleJumpEmerald.class), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java index 311600e5e..a74efc764 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetFrostLord.java @@ -12,7 +12,7 @@ public class SetFrostLord extends GadgetSet public SetFrostLord(GadgetManager manager) { - super(manager, "Frost Lord", /*"Improved Wind of the Frost Lord"*/ "2x Holiday Points while active (Titles)", + super(manager, "Frost Lord", "2x Holiday Points while active (Titles)", manager.getGadget(ArrowTrailFrostLord.class), manager.getGadget(DeathFrostLord.class), manager.getGadget(DoubleJumpFrostLord.class), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHalloween.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHalloween.java index 5e2ac0d59..8ca5529a3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHalloween.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHalloween.java @@ -12,7 +12,7 @@ public class SetHalloween extends GadgetSet public SetHalloween(GadgetManager manager) { - super(manager, "Spooky", "Increased chance of spawning Flaming Pumpkins in game (During Halloween)", + super(manager, "Spooky", "Increased chance of spawning Flaming Pumpkins in game (During Halloween). 2x Holiday Points while active (Titles)", manager.getGadget(ArrowTrailHalloween.class), manager.getGadget(DeathHalloween.class), manager.getGadget(DoubleJumpHalloween.class), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java index 668503111..b85592958 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetHowlingWinds.java @@ -1,5 +1,9 @@ package mineplex.core.gadget.set; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerVelocityEvent; + import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; import mineplex.core.gadget.gadgets.death.DeathStorm; @@ -12,11 +16,29 @@ public class SetHowlingWinds extends GadgetSet public SetHowlingWinds(GadgetManager manager) { - super(manager, "Howling Winds", /*"Press shift to start a flood around you, water runs in all directions for 10 seconds. 5 minute cooldown."*/ "Coming soon...", + super(manager, "Howling Winds", "The winds carry you further. Any velocity you have is doubled (In Lobbies Only)", manager.getGadget(ArrowTrailStorm.class), manager.getGadget(DeathStorm.class), manager.getGadget(DoubleJumpStorm.class), manager.getGadget(ParticleRain.class)); } + @EventHandler + public void playerVelocity(PlayerVelocityEvent event) + { + if (Manager.isGameLive()) + { + return; + } + + Player player = event.getPlayer(); + + if (!isActive(player)) + { + return; + } + + event.getVelocity().multiply(2); + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetLegend.java new file mode 100644 index 000000000..13aa45391 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetLegend.java @@ -0,0 +1,55 @@ +package mineplex.core.gadget.set; + +import java.awt.*; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; + +import mineplex.core.common.util.particles.DustSpellColor; +import mineplex.core.donation.Donor; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.GadgetManager.Perm; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailLegend; +import mineplex.core.gadget.gadgets.death.DeathLegend; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpLegend; +import mineplex.core.gadget.gadgets.particle.ParticleLegend; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetSet; + +public class SetLegend extends GadgetSet +{ + + public static final DustSpellColor[] SELECTABLE_COLORS = + { + new DustSpellColor(new Color(60, 170, 25)), + new DustSpellColor(new Color(33, 92, 13)), + new DustSpellColor(Color.BLACK) + }; + + public SetLegend(GadgetManager manager) + { + super(manager, "Legend", "Improved Legendary Aura", + manager.getGadget(ArrowTrailLegend.class), + manager.getGadget(DeathLegend.class), + manager.getGadget(DoubleJumpLegend.class), + manager.getGadget(ParticleLegend.class) + ); + } + + @EventHandler + public void legendOwner(PlayerJoinEvent event) + { + Player player = event.getPlayer(); + + if (Manager.getClientManager().Get(player).hasPermission(Perm.LEGEND_PARTICLE_EFFECT)) + { + Donor donor = Manager.getDonationManager().Get(player); + + for (Gadget gadget : getGadgets()) + { + donor.addOwnedUnknownSalesPackage(gadget.getName()); + } + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java index 50eef82a0..42f9968f2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetMusic.java @@ -12,7 +12,7 @@ public class SetMusic extends GadgetSet public SetMusic(GadgetManager manager) { - super(manager, "Ultimate Music Collection", /*"Press Shift to shoot a blast of music particles. People hit by the blast hear music for 15 seconds. 5 minute cooldown."*/ "2x Peaceful Points while active (Titles)", + super(manager, "Ultimate Music Collection", "2x Peaceful Points while active (Titles)", manager.getGadget(ArrowTrailMusic.class), manager.getGadget(DeathMusic.class), manager.getGadget(DoubleJumpMusic.class), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java index f22ce959e..d270e8dfa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetParty.java @@ -12,7 +12,7 @@ public class SetParty extends GadgetSet public SetParty(GadgetManager manager) { - super(manager, "Party", /*"Improved Party Time"*/ "2x Party Points while active (Titles)", + super(manager, "Party", "2x Party Points while active (Titles)", manager.getGadget(ArrowTrailConfetti.class), manager.getGadget(DeathPinataBurst.class), manager.getGadget(DoubleJumpFirecracker.class), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java index 80b751d7d..4c356ec9c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetShadow.java @@ -1,22 +1,69 @@ package mineplex.core.gadget.set; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; import mineplex.core.gadget.gadgets.death.DeathShadow; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; import mineplex.core.gadget.gadgets.particle.ParticleFoot; import mineplex.core.gadget.types.GadgetSet; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; public class SetShadow extends GadgetSet { + private static final PotionEffect POTION_EFFECT = new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false); + public SetShadow(GadgetManager manager) { - super(manager, "Shadow", /*"Press Shift to randomly teleport ~15 blocks away in a puff of shadow. 5 minute cooldown."*/ "Coming soon...", + super(manager, "Shadow", "Standing still causes you to be completely invisible (In Lobbies Only)", manager.getGadget(ArrowTrailShadow.class), manager.getGadget(DeathShadow.class), manager.getGadget(DoubleJumpShadow.class), manager.getGadget(ParticleFoot.class)); } + @Override + public void customDisable(Player player) + { + super.customDisable(player); + + player.removePotionEffect(PotionEffectType.INVISIBILITY); + } + + @EventHandler + public void updateMovement(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || Manager.isGameLive()) + { + return; + } + + for (Player player : _active) + { + if (Manager.isMoving(player)) + { + player.removePotionEffect(PotionEffectType.INVISIBILITY); + } + else + { + if (player.addPotionEffect(POTION_EFFECT)) + { + UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, player.getLocation().add(0, 0.5, 0), 0.6F, 0.6F, 0.6F, 0, 20, ViewDist.NORMAL); + } + else + { + UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, player.getLocation().add(0, 0.2, 0), null, 0, 1, ViewDist.NORMAL); + } + } + } + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java index fb21b5f9e..464548866 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java @@ -12,7 +12,6 @@ public class SetSpring extends GadgetSet public SetSpring(GadgetManager manager) { - // TODO LORE super(manager, "Spring", "2x Holiday Points while active (Titles)", manager.getGadget(ArrowTrailSpring.class), manager.getGadget(DeathSpring.class), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java index 360d86270..6af0afa84 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetTitan.java @@ -12,7 +12,7 @@ public class SetTitan extends GadgetSet public SetTitan(GadgetManager manager) { - super(manager, "The Titans", /*"Improved Flame of the Titans"*/ "Coming soon...", + super(manager, "The Titans", "Improved Flame of the Titans", manager.getGadget(ArrowTrailTitan.class), manager.getGadget(DeathTitan.class), manager.getGadget(DoubleJumpTitan.class), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java index 1a5541085..f7a492b95 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetVampire.java @@ -12,7 +12,7 @@ public class SetVampire extends GadgetSet public SetVampire(GadgetManager manager) { - super(manager, "Blood", /*"Press Shift to turn into a bat and be able to fly for 10 seconds. 5 Minute cooldown."*/ "2x Warrior Points while active (Titles)", + super(manager, "Blood", "2x Warrior Points while active (Titles)", manager.getGadget(ArrowTrailBlood.class), manager.getGadget(DeathBlood.class), manager.getGadget(DoubleJumpBlood.class), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java index 5bbae55da..21f9ca9d3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetWisdom.java @@ -12,7 +12,7 @@ public class SetWisdom extends GadgetSet public SetWisdom(GadgetManager manager) { - super(manager, "Wisdom", /*"Wearing the full Wisdom set when opening a chest slightly increases your chest roll %."*/ "2x Treasure Points while active (Titles)", + super(manager, "Wisdom", "2x Treasure Points while active (Titles)", manager.getGadget(ArrowTrailEnchant.class), manager.getGadget(DeathEnchant.class), manager.getGadget(DoubleJumpEnchant.class), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/suits/SetWindUpSuit.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/suits/SetWindUpSuit.java deleted file mode 100644 index 94717c90f..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/suits/SetWindUpSuit.java +++ /dev/null @@ -1,22 +0,0 @@ -package mineplex.core.gadget.set.suits; - -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.outfit.windupsuit.OutfitWindUpSuitBoots; -import mineplex.core.gadget.gadgets.outfit.windupsuit.OutfitWindUpSuitChestplate; -import mineplex.core.gadget.gadgets.outfit.windupsuit.OutfitWindUpSuitHelmet; -import mineplex.core.gadget.gadgets.outfit.windupsuit.OutfitWindUpSuitLeggings; -import mineplex.core.gadget.types.GadgetSet; - -public class SetWindUpSuit extends GadgetSet -{ - - public SetWindUpSuit(GadgetManager manager) - { - super(manager, "Wind Up Suit", "Placeholder", - manager.getGadget(OutfitWindUpSuitHelmet.class), - manager.getGadget(OutfitWindUpSuitChestplate.class), - manager.getGadget(OutfitWindUpSuitLeggings.class), - manager.getGadget(OutfitWindUpSuitBoots.class)); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ArrowEffectGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ArrowEffectGadget.java index 4d3b5b0d4..1ed567538 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ArrowEffectGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ArrowEffectGadget.java @@ -2,39 +2,28 @@ package mineplex.core.gadget.types; import java.util.HashSet; import java.util.Iterator; +import java.util.Set; import org.bukkit.Material; import org.bukkit.entity.Arrow; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileLaunchEvent; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; public abstract class ArrowEffectGadget extends Gadget { - protected HashSet _arrows = new HashSet(); + + protected final Set _arrows = new HashSet<>(); public ArrowEffectGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, String...altNames) { super(manager, GadgetType.ARROW_TRAIL, name, desc, cost, mat, data, 1, altNames); } - public boolean shouldDisplay(Player player) - { - if (UtilPlayer.isSpectator(player)) - return false; - - if (Manager.hideParticles()) - return false; - - return true; - } - @EventHandler public void arrowLaunch(ProjectileLaunchEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/BalloonGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/BalloonGadget.java index feb632597..553dfab4e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/BalloonGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/BalloonGadget.java @@ -1,176 +1,170 @@ package mineplex.core.gadget.types; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; -import java.util.UUID; -import org.bukkit.Material; +import org.bukkit.Location; +import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.disguise.disguises.DisguiseAgeable; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseZombie; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.balloons.BalloonEntity; import mineplex.core.gadget.gadgets.balloons.BalloonType; -import mineplex.core.gadget.util.BalloonData; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -public abstract class BalloonGadget extends Gadget +public class BalloonGadget extends Gadget { - private static final Map> PLAYER_BALLOONS = new HashMap<>(); + private static final int MAX_BALLOONS = 3; - private EntityType _balloon; - private BalloonType _balloonType; - - public BalloonGadget(GadgetManager manager, String name, String[] desc, int cost, Material material, byte data, BalloonType balloonType, EntityType balloon, String... altNames) + static { - super(manager, GadgetType.BALLOON, name, desc, cost, material, data, 1, altNames); - _balloon = balloon; - _balloonType = balloonType; + try + { + UtilEnt.registerEntityType(BalloonEntity.class, EntityType.SLIME, "Balloon"); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + private final BalloonType _balloonType; + private final Map _data; + + public BalloonGadget(GadgetManager manager, BalloonType type) + { + super(manager, GadgetType.BALLOON, type.getName() + " Balloon", type.getDescription(), type.getCost(), type.getDisplayMaterial(), type.getDisplayData()); + + _balloonType = type; + _data = new HashMap<>(); } @Override public void enableCustom(Player player, boolean message) { - boolean add = addPlayerBalloon(player); - if (add) + long active = Manager.getGadgets(getGadgetType()) + .stream() + .filter(gadget -> gadget.isActive(player)) + .count(); + + if (active >= MAX_BALLOONS) { - _active.add(player); - if (message) - { - UtilPlayer.message(player, F.main("Gadget", "You spawned a " + F.elem(getName()) + "!")); - } + Manager.removeActive(player, this); + player.sendMessage(F.main(Manager.getName(), "You already have the maximum about of balloons active!")); + return; + } + + _active.add(player); + + Location location = player.getLocation(); + ArmorStand stand = location.getWorld().spawn(location, ArmorStand.class); + + stand.setGravity(false); + UtilEnt.ghost(stand, true, false); + UtilEnt.addFlag(stand, UtilEnt.FLAG_NO_REMOVE); + UtilEnt.addFlag(stand, UtilEnt.FLAG_ENTITY_COMPONENT); + + BalloonEntity balloonEntity = BalloonEntity.spawn(stand, player, _balloonType.getClazz() != null); + + Slime slime = (Slime) balloonEntity.getBukkitEntity(); + slime.setSize(-1); + + UtilEnt.vegetate(slime, true); + UtilEnt.ghost(slime, true, true); + UtilEnt.addFlag(slime, UtilEnt.FLAG_NO_REMOVE); + UtilEnt.addFlag(slime, UtilEnt.FLAG_ENTITY_COMPONENT); + + if (_balloonType.getClazz() == null) + { + stand.setVisible(false); + stand.setHelmet(_balloonType.getHelmet()); } else { - Manager.removeActive(player, this); - UtilPlayer.message(player, F.main("Gadget", "You cannot have more than " + F.count("10") + " balloons!")); + try + { + DisguiseBase disguise = _balloonType.getClazz().getConstructor(Entity.class).newInstance(stand); + + if (disguise instanceof DisguiseAgeable) + { + ((DisguiseAgeable) disguise).setBaby(); + } + else if (disguise instanceof DisguiseZombie) + { + ((DisguiseZombie) disguise).setBaby(true); + } + + Manager.getDisguiseManager().disguise(disguise); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + _data.put(player, balloonEntity); + + if (message) + { + player.sendMessage(F.main(Manager.getName(), "You spawned " + F.vowelAN(getName()) + " " + F.name(getName()) + ".")); } } @Override public void disableCustom(Player player, boolean message) { - if (!_active.remove(player)) - return; + BalloonEntity data = _data.remove(player); + + if (data == null) + { + return; + } + + data.remove(); + _active.remove(player); - removePlayerBalloon(player); if (message) - UtilPlayer.message(player, F.main("Gadget", "You despawned a " + F.elem(getName())) + "!"); - } - - private boolean addPlayerBalloon(Player player) - { - if (!canSpawnBalloon(player)) - return false; - - PLAYER_BALLOONS.computeIfAbsent(player.getUniqueId(), map -> new HashMap<>()); - BalloonData balloonData; - Entity[] ents = spawnEntity(player); - if (ents[1] == null) - balloonData = new BalloonData(player, ents[0]); - else if (!_balloon.equals(EntityType.ARMOR_STAND)) - balloonData = new BalloonData(player, ents[0], ents[1]); - else { - balloonData = new BalloonData(player, ents[0]); - balloonData.setLeash(ents[1]); - } - PLAYER_BALLOONS.get(player.getUniqueId()).put(_balloon, balloonData); - - return true; - } - - private void removePlayerBalloon(Player player) - { - if (PLAYER_BALLOONS.containsKey(player.getUniqueId())) - { - if (PLAYER_BALLOONS.get(player.getUniqueId()).containsKey(_balloon)) - { - removeEntities(player); - PLAYER_BALLOONS.get(player.getUniqueId()).remove(_balloon); - } + player.sendMessage(F.main(Manager.getName(), "You despawned " + F.vowelAN(getName()) + " " + F.name(getName()) + ".")); } } - protected abstract Entity[] spawnEntity(Player player); - - protected abstract void removeEntities(Player player); - @EventHandler - public void onUpdate(UpdateEvent event) + public void interactEntity(PlayerInteractEntityEvent event) { - if (event.getType() != UpdateType.TICK) - return; - - Iterator>> iterator = PLAYER_BALLOONS.entrySet().iterator(); - while (iterator.hasNext()) + for (BalloonEntity entity : _data.values()) { - Map.Entry> entry = iterator.next(); - for (BalloonData balloonData : entry.getValue().values()) + if (entity.isPartOfEntity(event.getRightClicked())) { - balloonData.teleport(); + event.setCancelled(true); + return; } } } @EventHandler - public void onPlayerMove(PlayerMoveEvent event) + public void teleport(PlayerTeleportEvent event) { - if (PLAYER_BALLOONS.containsKey(event.getPlayer().getUniqueId())) + if (event.getCause() == TeleportCause.PLUGIN) { - Map balloons = PLAYER_BALLOONS.get(event.getPlayer().getUniqueId()); - for (BalloonData balloonData : balloons.values()) - { - balloonData.update(); - } + disable(event.getPlayer(), false); } } - private boolean canSpawnBalloon(Player player) - { - if (PLAYER_BALLOONS.containsKey(player.getUniqueId())) - { - Map balloonGadgets = PLAYER_BALLOONS.get(player.getUniqueId()); - return balloonGadgets.size() < 10; - } - return true; - } - public BalloonType getBalloonType() { return _balloonType; } - - public static int getBalloons(Player player) - { - return ((PLAYER_BALLOONS.containsKey(player.getUniqueId())) ? PLAYER_BALLOONS.get(player.getUniqueId()).size() : 0); - } - - /** - * Prevents errors caused by players teleporting - * @param event - */ - @EventHandler - public void onTeleport(PlayerTeleportEvent event) - { - if (getBalloons(event.getPlayer()) > 0) - { - if (event.getFrom().getY() > 0) - return; - - for (BalloonGadget balloonGadget : Manager.getActiveBalloons(event.getPlayer())) - { - balloonGadget.disable(event.getPlayer(), false); - } - UtilPlayer.message(event.getPlayer(), F.main("Balloons", "Your balloons popped when you fell into the void! Equip them again!")); - } - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/DeathEffectGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/DeathEffectGadget.java index 35eeb4737..9f1dee1d2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/DeathEffectGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/DeathEffectGadget.java @@ -10,6 +10,7 @@ import mineplex.core.gadget.GadgetManager; public abstract class DeathEffectGadget extends Gadget { + public DeathEffectGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, String... altNames) { super(manager, GadgetType.DEATH, name, desc, cost, mat, data, 1, altNames); @@ -17,27 +18,17 @@ public abstract class DeathEffectGadget extends Gadget public boolean shouldDisplay(Player player) { - if (UtilPlayer.isSpectator(player)) - return false; - - if (Manager.hideParticles()) - return false; - - return true; + return player != null && !UtilPlayer.isSpectator(player) && !Manager.hideParticles() && isActive(player); } @EventHandler public void callDeath(BloodEvent event) { - if (event.getPlayer() == null) - return; - - if (!isActive(event.getPlayer())) - return; - if (!shouldDisplay(event.getPlayer())) + { return; - + } + onBlood(event.getPlayer(), event); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/DoubleJumpEffectGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/DoubleJumpEffectGadget.java index e1076dba7..0c8bfbcef 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/DoubleJumpEffectGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/DoubleJumpEffectGadget.java @@ -10,34 +10,29 @@ import mineplex.core.gadget.GadgetManager; public abstract class DoubleJumpEffectGadget extends Gadget { + public DoubleJumpEffectGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, String... altNames) { super(manager, GadgetType.DOUBLE_JUMP, name, desc, cost, mat, data, 1, altNames); } - - public boolean shouldDisplay(Player player) + + private boolean shouldDisplay(Player player) { - if (UtilPlayer.isSpectator(player)) - return false; - - if (Manager.hideParticles()) - return false; - - return true; + return !UtilPlayer.isSpectator(player) && !Manager.hideParticles() && !player.isFlying() && isActive(player); } - + @EventHandler public void jump(PlayerToggleFlightEvent event) { - if (!shouldDisplay(event.getPlayer())) + Player player = event.getPlayer(); + + if (!shouldDisplay(player)) + { return; - - if (!event.getPlayer().isFlying()) - if (isActive(event.getPlayer())) - { - doEffect(event.getPlayer()); - } - } - + } + + doEffect(event.getPlayer()); + } + public abstract void doEffect(Player player); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java index 9362ef34d..559cb1e47 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java @@ -28,13 +28,14 @@ public abstract class Gadget extends SalesPackageBase implements Listener public final GadgetManager Manager; private final GadgetType _gadgetType; - private String[] _alternativePackageNames; + private final String[] _alternativePackageNames; - private YearMonth _yearMonth = null; - private ItemStack _displayItem = null; + private YearMonth _yearMonth; + private ItemStack _displayItem; private boolean _hidden; + private int _maxActive = Integer.MAX_VALUE; - private GadgetSet _set = null; + private GadgetSet _set; protected final Set _active = new HashSet<>(); @@ -60,11 +61,6 @@ public abstract class Gadget extends SalesPackageBase implements Listener _alternativePackageNames = alternativePackageNames; - if (alternativePackageNames == null) - { - _alternativePackageNames = new String[0]; - } - UtilServer.RegisterEvents(this); } @@ -103,6 +99,11 @@ public abstract class Gadget extends SalesPackageBase implements Listener return _hidden; } + public void setMaxActive(int maxActive) + { + _maxActive = maxActive; + } + @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { @@ -124,8 +125,15 @@ public abstract class Gadget extends SalesPackageBase implements Listener { if (message) { - UtilPlayer.message(player, F.main(Manager.getName(), getName() + " is not enabled.")); + UtilPlayer.message(player, F.main(Manager.getName(), F.name(getName()) + " is not enabled.")); } + + return; + } + + if (_active.size() + 1 >= _maxActive) + { + player.sendMessage(F.main(Manager.getName(), "Sorry there is a limit to how many people can use " + F.name(getName()) + " at one time in a lobby.")); return; } @@ -151,10 +159,10 @@ public abstract class Gadget extends SalesPackageBase implements Listener { if (isActive(player)) { - Manager.removeActive(player, this); GadgetDisableEvent event = new GadgetDisableEvent(player, this); UtilServer.CallEvent(event); disableCustom(player, message); + Manager.removeActive(player, this); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetSet.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetSet.java index 47feb114b..e5dfc0004 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetSet.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetSet.java @@ -1,8 +1,8 @@ package mineplex.core.gadget.types; import java.util.HashSet; +import java.util.Set; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -11,112 +11,119 @@ import org.bukkit.event.Listener; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.event.GadgetDisableEvent; +import mineplex.core.gadget.event.GadgetEnableEvent; public abstract class GadgetSet implements Listener { - private String _name; - private String[] _bonus; - - private Gadget[] _gadgets; - - protected GadgetManager Manager; - - HashSet _active = new HashSet<>(); + + private final String _name; + private final String[] _bonus; + + private final Gadget[] _gadgets; + protected final GadgetManager Manager; + + protected final Set _active = new HashSet<>(); public GadgetSet(GadgetManager manager, String name, String bonus, Gadget... gadgets) { Manager = manager; _gadgets = gadgets; - + _name = name; _bonus = UtilText.splitLineToArray(bonus, LineFormat.LORE); - + for (Gadget gadget : gadgets) + { gadget.setSet(this); - - Bukkit.getPluginManager().registerEvents(this, Manager.getPlugin()); + } + + UtilServer.RegisterEvents(this); } - - public void checkPlayer(Player player, Gadget gadget, boolean enable, boolean message) + + private void checkPlayer(Player player, Gadget gadget, boolean enable, boolean message) { boolean wasActive = isActive(player); - - for(Gadget g : _gadgets) + + for (Gadget g : _gadgets) { - if(!g.isActive(player) || g.equals(gadget)) + if (!g.isActive(player) || g.equals(gadget)) { - if(enable && g.equals(gadget)) continue; - + if (enable && g.equals(gadget)) continue; + _active.remove(player); - if(wasActive) + if (wasActive) customDisable(player); return; } } _active.add(player); - if(!wasActive) + if (!wasActive) { customEnable(player, message); } } - + @EventHandler(priority = EventPriority.MONITOR) public void onActivate(GadgetEnableEvent event) { checkPlayer(event.getPlayer(), event.getGadget(), true, event.canShowMessage()); } - + @EventHandler(priority = EventPriority.MONITOR) public void onDeativate(GadgetDisableEvent event) { checkPlayer(event.getPlayer(), event.getGadget(), false, true); } - + public boolean isActive(Player player) { return _active.contains(player); } - + public void customEnable(Player player, boolean message) { if (message) + { player.sendMessage(F.main("Gadget", "Set Enabled: " + F.elem(C.cGreen + getName()))); + } } public void customDisable(Player player) { player.sendMessage(F.main("Gadget", "Set Disabled: " + F.elem(C.cRed + getName()))); } - + public Gadget[] getGadgets() { - Gadget[] array = new Gadget[_gadgets.length]; - System.arraycopy(_gadgets, 0, array, 0, array.length); - return array; + return _gadgets; } - + public boolean isPartOfSet(Gadget gadget) { - for(Gadget g : _gadgets) + for (Gadget setGadget : _gadgets) { - if(g.equals(gadget)) return true; + if (setGadget.equals(gadget)) + { + return true; + } } + return false; } - public String getName() + public String getName() { return _name; } - + public String[] getBonus() { return _bonus; } - + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java index 56c6731ca..af9eca1d0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java @@ -5,32 +5,35 @@ package mineplex.core.gadget.types; */ public enum GadgetType { - ITEM("Items", "activeItem"), - MORPH("Morphs", "activeMorph"), - PARTICLE("Particles", "activeParticle"), - MUSIC_DISC("Music Discs", ""), - COSTUME("Costumes", ""), - DOUBLE_JUMP("Double Jump Effects", "activeDoubleJump"), - ARROW_TRAIL("Arrow Trails", "activeArrowTrail"), - DEATH("Death Effects", "activeDeathEffect"), - HAT("Hats", "activeHat"), - TAUNT("Taunts", "activeTaunt"), - WIN_EFFECT("Win Effects", "activeWinEffect"), - GAME_MODIFIER("Game Cosmetics", ""), - BALLOON("Balloons", ""), - KIT_SELECTOR("Kit Selectors", "activeKitSelector"), - FLAG("Flags", "activeFlag"), - MOUNT("Mounts", ""), + ITEM("Items", "activeItem", true), + MORPH("Morphs", "activeMorph", true), + PARTICLE("Particles", "activeParticle", false), + MUSIC_DISC("Music Discs", "", true), + COSTUME("Costumes", "", true), + DOUBLE_JUMP("Leap Effects", "activeDoubleJump", false), + ARROW_TRAIL("Arrow Trails", "activeArrowTrail", false), + DEATH("Death Effects", "activeDeathEffect", false), + HAT("Hats", "activeHat", true), + TAUNT("Taunts", "activeTaunt", false), + WIN_EFFECT("Win Effects", "activeWinEffect", false), + GAME_MODIFIER("Game Cosmetics", "", false), + BALLOON("Balloons", "", true), + KIT_SELECTOR("Kit Selectors", "activeKitSelector", false), + FLAG("Flags", "activeFlag", true), + MOUNT("Mounts", "", true), + WEAPON_NAME("Weapon Names", "activeWeapon", false), + LEVEL_PREFIX("Level Prefixes", "activeLevelPrefix", false) ; - private String _name; - private String _databaseKey; + private final String _name, _databaseKey; + private final boolean _disableForGame; - GadgetType(String name, String databaseKey) + GadgetType(String name, String databaseKey, boolean disableForGame) { _name = name; _databaseKey = databaseKey; + _disableForGame = disableForGame; } /** @@ -48,4 +51,9 @@ public enum GadgetType { return _databaseKey; } + + public boolean disableForGame() + { + return _disableForGame; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java index c356382c6..89484541e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ItemGadget.java @@ -61,11 +61,6 @@ public abstract class ItemGadget extends Gadget RemoveItem(player, message); } - public boolean isActive(Player player) - { - return _active.contains(player); - } - public void ApplyItem(Player player, boolean inform) { Manager.removeGadgetType(player, GadgetType.ITEM, this); @@ -149,6 +144,12 @@ public abstract class ItemGadget extends Gadget return; } + if (!Manager.selectLocation(this, player.getLocation())) + { + Manager.informNoUse(player); + return; + } + //Stock if (!hasAmmo(player)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/LevelPrefixGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/LevelPrefixGadget.java new file mode 100644 index 000000000..8ab34a713 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/LevelPrefixGadget.java @@ -0,0 +1,56 @@ +package mineplex.core.gadget.types; + +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.chat.LevelPrefixType; +import mineplex.core.gadget.util.CostConstants; + +public class LevelPrefixGadget extends Gadget +{ + + private final LevelPrefixType _prefixType; + + public LevelPrefixGadget(GadgetManager manager, LevelPrefixType prefixType) + { + super(manager, GadgetType.LEVEL_PREFIX, prefixType.getName() + " Level Color", new String[] + { + C.cGray + "Changes the color of your level", + C.cGray + "in chat to " + prefixType.getChatColor() + prefixType.getName() + C.cGray + "." + }, CostConstants.LEVEL_REWARDS, Material.INK_SACK, prefixType.getDyeColor().getDyeData()); + + _prefixType = prefixType; + } + + @Override + public void enableCustom(Player player, boolean message) + { + Manager.removeGadgetType(player, getGadgetType(), this); + _active.add(player); + + if (message) + { + player.sendMessage(F.main(Manager.getName(), "You changed your level color to " + _prefixType.getChatColor() + _prefixType.getName() + C.cGray + ".")); + } + } + + @Override + public void disableCustom(Player player, boolean message) + { + _active.remove(player); + } + + @Override + public boolean ownsGadget(Player player) + { + return Manager.getAchievementManager().getMineplexLevelNumber(player, false) >= _prefixType.getUnlockAt(); + } + + public LevelPrefixType getPrefixType() + { + return _prefixType; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WeaponNameGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WeaponNameGadget.java new file mode 100644 index 000000000..a9284324a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WeaponNameGadget.java @@ -0,0 +1,269 @@ +package mineplex.core.gadget.types; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryAction; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import mineplex.core.arcadeevents.CoreGameStartEvent; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilServer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.weaponname.WeaponNameType; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class WeaponNameGadget extends Gadget +{ + + private final WeaponNameType _weaponNameType; + + public WeaponNameGadget(GadgetManager manager, WeaponNameType weaponNameType) + { + super(manager, GadgetType.WEAPON_NAME, weaponNameType.getName(), new String[] + { + C.cGray + "Changes the name of your", + ItemStackFactory.Instance.GetName(weaponNameType.getWeaponType().getMaterial(), (byte) 0, true) + C.cGray + " to " + F.item(weaponNameType.getDisplay()) + "." + }, weaponNameType.getCost(), weaponNameType.getMaterial(), weaponNameType.getMaterialData()); + + _weaponNameType = weaponNameType; + } + + @Override + public void enableCustom(Player player, boolean message) + { + for (Gadget gadget : Manager.getGadgets(GadgetType.WEAPON_NAME)) + { + if (((WeaponNameGadget) gadget).getWeaponNameType().getWeaponType() == _weaponNameType.getWeaponType()) + { + gadget.disable(player); + } + } + + _active.add(player); + + if (message) + { + player.sendMessage(F.main(Manager.getName(), "You enabled " + F.name(getName()) + ".")); + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void inventroyClick(InventoryClickEvent event) + { + if (event.isCancelled() || event.getClickedInventory() == null) + { + return; + } + + Player player = (Player) event.getWhoClicked(); + + if (!isEnabled(player)) + { + return; + } + + InventoryAction action = event.getAction(); + ItemStack itemStack = event.getCursor(); + boolean playerInv = event.getClickedInventory().equals(player.getInventory()); + + if (action == InventoryAction.HOTBAR_SWAP || action == InventoryAction.HOTBAR_MOVE_AND_READD || action == InventoryAction.MOVE_TO_OTHER_INVENTORY) + { + playerInv = !playerInv; + itemStack = event.getCurrentItem(); + } + + if (isItem(itemStack) && !playerInv) + { + setItemName(itemStack, null); + } + else if (isItemBase(itemStack) && playerInv) + { + setItemName(itemStack); + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void playerDropItem(PlayerDropItemEvent event) + { + if (event.isCancelled()) + { + return; + } + + Player player = event.getPlayer(); + + if (!isEnabled(player)) + { + return; + } + + ItemStack itemStack = event.getItemDrop().getItemStack(); + + if (isItem(itemStack)) + { + setItemName(itemStack, null); + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void playerPickupItem(PlayerPickupItemEvent event) + { + if (event.isCancelled()) + { + return; + } + + Player player = event.getPlayer(); + ItemStack itemStack = event.getItem().getItemStack(); + boolean active = isActive(player); + + if (isItemBase(itemStack) && active) + { + setItemName(itemStack); + } + else if (isItem(itemStack) && !active) + { + setItemName(itemStack, null); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void playerDeath(PlayerDeathEvent event) + { + Player player = event.getEntity(); + + if (!isEnabled(player)) + { + return; + } + + event.getDrops().forEach(itemStack -> + { + if (isItem(itemStack)) + { + setItemName(itemStack, null); + } + }); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void updateInventoryFallback(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOWER) + { + return; + } + + validateInventories(); + } + + @EventHandler + public void gameStart(CoreGameStartEvent event) + { + Manager.runSyncLater(this::validateInventories, 10); + } + + private boolean isEnabled(Player player) + { + return Manager.showWeaponNames() && isActive(player); + } + + private boolean isItemBase(ItemStack itemStack) + { + return itemStack != null && !isItem(itemStack) && itemStack.getType() == _weaponNameType.getWeaponType().getMaterial() && (!itemStack.hasItemMeta() || !itemStack.getItemMeta().hasDisplayName()); + } + + private boolean isItem(ItemStack itemStack) + { + if (itemStack == null || itemStack.getType() != _weaponNameType.getWeaponType().getMaterial() || !itemStack.hasItemMeta()) + { + return false; + } + + String name = itemStack.getItemMeta().getDisplayName(); + + return name != null && name.contains(_weaponNameType.getDisplay()); + } + + private void setItemName(ItemStack itemStack) + { + setItemName(itemStack, C.mItem + _weaponNameType.getDisplay()); + } + + private void setItemName(ItemStack itemStack, String name) + { + ItemMeta itemMeta = itemStack.getItemMeta(); + itemMeta.setDisplayName(name); + itemStack.setItemMeta(itemMeta); + } + + private void validateInventories() + { + if (!Manager.showWeaponNames()) + { + return; + } + + for (Player player : UtilServer.getPlayersCollection()) + { + boolean active = isActive(player); + + for (ItemStack itemStack : player.getInventory().getContents()) + { + if (isItem(itemStack) && !active) + { + setItemName(itemStack, null); + } + else if (isItemBase(itemStack) && active) + { + setItemName(itemStack); + } + } + } + } + + public WeaponNameType getWeaponNameType() + { + return _weaponNameType; + } + + public enum WeaponType + { + + WOOD_SWORD(0, Material.WOOD_SWORD), + STONE_SWORD(1, Material.STONE_SWORD), + GOLD_SWORD(2, Material.GOLD_SWORD), + IRON_SWORD(3, Material.IRON_SWORD), + DIAMOND_SWORD(4, Material.DIAMOND_SWORD),; + + private final int _id; + private final Material _material; + + WeaponType(int id, Material material) + { + _id = id; + _material = material; + } + + public int getId() + { + return _id; + } + + public Material getMaterial() + { + return _material; + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java index 1f0fa190b..c59e0282f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java @@ -5,9 +5,9 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.UUID; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import mineplex.core.incognito.IncognitoManager; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -27,8 +27,8 @@ import org.bukkit.util.Vector; import com.mojang.authlib.GameProfile; -import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.Managers; +import mineplex.core.account.permissions.PermissionGroup; import mineplex.core.common.block.schematic.Schematic; import mineplex.core.common.block.schematic.UtilSchematic; import mineplex.core.common.skin.SkinData; @@ -38,6 +38,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; +import mineplex.core.incognito.IncognitoManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.visibility.VisibilityManager; @@ -45,65 +46,72 @@ import mineplex.core.visibility.VisibilityManager; /** * A wrapper for different win effects */ - public abstract class WinEffectGadget extends Gadget { - + protected Player _player; - protected long _start; - protected long _finish; + protected long _start, _finish, _length = TimeUnit.SECONDS.toMillis(12); protected Location _baseLocation; private int _gameTime = 12000; - + /** - * The file name of the schematic used for this win room. Schematics can be found in the "schematic" folder + * The file name of the schematic used for this win room. Schematics can be found in the "schematic" folder * in the server root folder. This name should not contain the file suffix of ".schematic" as this is automatically applied later. */ protected String _schematicName = "WinRoomPodium"; - - /** All the players on the winners team. Empty if solo game. */ + + /** + * All the players on the winners team. Empty if solo game. + */ protected List _team; - /** All the other players on the other teams that didn't win. */ + /** + * All the other players on the other teams that didn't win. + */ protected List _nonTeam; - /** All players on the team that didn't win + spectators which were not in the game at all. */ + /** + * All players on the team that didn't win + spectators which were not in the game at all. + */ protected List _other; - /** All the players that were teleported to the winroom */ + /** + * All the players that were teleported to the winroom + */ protected List _allPlayers; /** - * @param manager The normal GadgetManager - * @param name The display name of the WinEffect - * @param desc The description of the WinEffect - * @param cost The shard cost of the WinEffect - * @param mat The display material of the WinEffect - * @param data The display data of the WinEffect + * @param manager The normal GadgetManager + * @param name The display name of the WinEffect + * @param desc The description of the WinEffect + * @param cost The shard cost of the WinEffect + * @param mat The display material of the WinEffect + * @param data The display data of the WinEffect * @param alternativesalepackageNames Alternative packet names used to check if the player owns this WinEffect */ public WinEffectGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, - String... alternativesalepackageNames) + String... alternativesalepackageNames) { super(manager, GadgetType.WIN_EFFECT, name, desc, cost, mat, data, 1, alternativesalepackageNames); } - /** - * @param manager The normal GadgetManager - * @param name The display name of the WinEffect - * @param desc The description of the WinEffect - * @param cost The shard cost of the WinEffect - * @param mat The display material of the WinEffect - * @param data The display data of the WinEffect - * @param free Sets the gadget to be free for all the players by default - * @param altName Alternative package names used to check if the player owns this WinEffect - */ - public WinEffectGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, - boolean free, String... altName) - { - super(manager, GadgetType.WIN_EFFECT, name, desc, cost, mat, data, 1, free, altName); - } + /** + * @param manager The normal GadgetManager + * @param name The display name of the WinEffect + * @param desc The description of the WinEffect + * @param cost The shard cost of the WinEffect + * @param mat The display material of the WinEffect + * @param data The display data of the WinEffect + * @param free Sets the gadget to be free for all the players by default + * @param altName Alternative package names used to check if the player owns this WinEffect + */ + public WinEffectGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, + boolean free, String... altName) + { + super(manager, GadgetType.WIN_EFFECT, name, desc, cost, mat, data, 1, free, altName); + } public void runPlay() { - this._finish = _start + 1000*12; + _finish = _start + _length; + _length += 1000; play(); } @@ -116,7 +124,7 @@ public abstract class WinEffectGadget extends Gadget finally { VisibilityManager vm = Managers.require(VisibilityManager.class); - + Bukkit.getOnlinePlayers().forEach(p -> { Bukkit.getOnlinePlayers().forEach(pl -> vm.showPlayer(p, pl, "Inside Win Effect")); @@ -144,37 +152,28 @@ public abstract class WinEffectGadget extends Gadget * This method is called when the win effect should start playing */ public abstract void play(); - + /** - * This method is called when this win effect is finished. Do any necessary clean up here. Note that entities do not need to be + * This method is called when this win effect is finished. Do any necessary clean up here. Note that entities do not need to be * cleared. */ public abstract void finish(); - /** - * This method is called when an update happens - * @param type The type of the update - */ - public void update(UpdateType type){}; - public boolean isRunning() { - if(_player == null) return false; - if(_baseLocation == null) return false; - if(System.currentTimeMillis() >= _finish) return false; - return true; + return _player != null && _baseLocation != null && System.currentTimeMillis() < _finish; } - + public Player getPlayer() { return _player; } - + public Location getBaseLocation() { return _baseLocation.clone(); } - + /** * @return The time stamp of when this effect started */ @@ -182,7 +181,7 @@ public abstract class WinEffectGadget extends Gadget { return _start; } - + /** * @return The time stamp of when this effect should end */ @@ -190,16 +189,21 @@ public abstract class WinEffectGadget extends Gadget { return _finish; } - + /** * @return Returns how many milliseconds there is left before this effect should end. It will return negative values if the * effect has finished. */ public long getTimeLeft() { - return getFinish()-getStart(); + return getFinish() - getStart(); } - + + public long getLength() + { + return _length; + } + public void setup(Player player, List team, List nonTeam, Location loc) { _player = player; @@ -227,68 +231,66 @@ public abstract class WinEffectGadget extends Gadget _allPlayers = new ArrayList<>(); _allPlayers.addAll(UtilServer.getPlayersCollection()); - + this._start = System.currentTimeMillis(); this._baseLocation = loc.clone(); } - + /** * Teleport the players to the win room + * * @see #teleport(Location) */ public void teleport() { Location loc = getBaseLocation().add(getBaseLocation().getDirection().normalize().multiply(10)).add(0, 3, 0); loc.setDirection(getBaseLocation().clone().subtract(loc).toVector()); - + teleport(loc); } - + /** * Teleport the players to the win room + * * @param loc The base location to teleport the players too */ public void teleport(Location loc) { createBarriers(loc); - BukkitRunnable bRunnable = new BukkitRunnable() - { - @Override - public void run() - { - VisibilityManager vm = Managers.require(VisibilityManager.class); - for (Player p : UtilServer.getPlayers()) - { - Bukkit.getOnlinePlayers().forEach(pl -> vm.hidePlayer(pl, p, "Inside Win Effect")); + BukkitRunnable bRunnable = new BukkitRunnable() + { + @Override + public void run() + { + VisibilityManager vm = Managers.require(VisibilityManager.class); + for (Player p : UtilServer.getPlayers()) + { + Bukkit.getOnlinePlayers().forEach(pl -> vm.hidePlayer(pl, p, "Inside Win Effect")); p.eject(); p.teleport(loc); p.setGameMode(GameMode.ADVENTURE); p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 10 * 20, 1, false, false)); p.getInventory().clear(); - p.setAllowFlight(false); + p.setAllowFlight(false); p.setHealth(p.getMaxHealth()); p.setFoodLevel(20); - } - } - }; - bRunnable.runTaskLater(UtilServer.getPlugin(), 10l); - } + } + } + }; + bRunnable.runTaskLater(UtilServer.getPlugin(), 10L); + } /** * Updates players inventory - * @param event */ @EventHandler public void onUpdate(UpdateEvent event) { - update(event.getType()); - - if (event.getType() != UpdateType.TICK) - return; - - if (!isRunning()) + if (event.getType() != UpdateType.FAST || !isRunning()) + { return; + } for (Player player : _allPlayers) { @@ -315,45 +317,38 @@ public abstract class WinEffectGadget extends Gadget } /** - * Build the win room, by default this will paste the scheamtic. Do any major setup here. This is called before the players are + * Build the win room, by default this will paste the scheamtic. Do any major setup here. This is called before the players are * teleported. */ - public void buildWinnerRoom() + public void buildWinnerRoom() { pasteScematic(_schematicName); } - + /** * Get a disguised ArmorStand with the skin of the provided player at the provided location. The ArmorStand got no gravity and * 2048 health. + * * @param player The player to create the disguise from - * @param loc The location to spawn the ArmorStand at + * @param loc The location to spawn the ArmorStand at * @return Returns a disguised ArmorStand at the given location */ - public DisguisePlayer getNPC(Player player, Location loc) { - ArmorStand stand = loc.getWorld().spawn(loc, ArmorStand.class); - - stand.setMaxHealth(2048); - stand.setHealth(2048); - stand.setGravity(false); - - GameProfile profile = new GameProfile(UUID.randomUUID(), player.getName()); - profile.getProperties().putAll(((CraftPlayer) player).getHandle().getProfile().getProperties()); - - DisguisePlayer disguise = new DisguisePlayer(stand, profile); - Manager.getDisguiseManager().disguise(disguise); - return disguise; + public DisguisePlayer getNPC(Player player, Location loc) + { + return getNPC(player, loc, false); } /** - * Get a disguised ArmorStand with the skin of the provided skindata at the provided location. The ArmorStand got no gravity and + * Get a disguised ArmorStand with the skin of the provided skindata at the provided location. The ArmorStand got no gravity and * 2048 health. - * @param player The player to create the disguise from - * @param loc The location to spawn the ArmorStand at + * + * @param player The player to create the disguise from + * @param loc The location to spawn the ArmorStand at * @param skinData The skin data to disguise the armorstand * @return Returns a disguised ArmorStand at the given location */ - public DisguisePlayer getNPC(Player player, Location loc, SkinData skinData) { + public DisguisePlayer getNPC(Player player, Location loc, SkinData skinData) + { ArmorStand stand = loc.getWorld().spawn(loc, ArmorStand.class); stand.setMaxHealth(2048); @@ -371,12 +366,14 @@ public abstract class WinEffectGadget extends Gadget /** * Get a disguised ArmorStand with the skin of the provided player at the provided location. The ArmorStand got 2048 health. - * @param player The player to create the disguise from - * @param loc The location to spawn the ArmorStand at + * + * @param player The player to create the disguise from + * @param loc The location to spawn the ArmorStand at * @param gravity true if the armorstand should have gravity * @return Returns a disguised ArmorStand at the given location */ - public DisguisePlayer getNPC(Player player, Location loc, boolean gravity) { + public DisguisePlayer getNPC(Player player, Location loc, boolean gravity) + { ArmorStand stand = loc.getWorld().spawn(loc, ArmorStand.class); stand.setMaxHealth(2048); @@ -390,50 +387,35 @@ public abstract class WinEffectGadget extends Gadget Manager.getDisguiseManager().disguise(disguise); return disguise; } - + /** * Paste a schematic relative to the base location - * @param schematicName Schematic name without the file suffix ".schematic". The file should be located in the "schematic" folder - * in the server root directory + * + * @param schematicName Schematic name without the file suffix ".schematic". The file should be located in the "schematic" folder + * in the server root directory * @return Returns the schematic after pasting it. Will return null if any errors ocured. */ - public Schematic pasteScematic(String schematicName) { - try + public Schematic pasteScematic(String schematicName) + { + try { Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/" + schematicName + ".schematic")); if (schematic != null) schematic.paste(getBaseLocation(), false, true); return schematic; } - catch(IOException e) + catch (IOException e) { e.printStackTrace(); return null; } } - public void spawnFirework(int tick, Color fireworkColor) - { - Location loc = getBaseLocation(); - - for(int i = 0; i < 3; i++) - { - double r = 3; - double rad = (((Math.PI * 2) / 3.0) * i) + ((tick % 240) * Math.PI / 120.0); - double x = Math.sin(rad) * r; - double z = Math.cos(rad) * r; - - Location l = loc.clone().add(x, 0, z); - UtilFirework.launchFirework(l, FireworkEffect.Type.BALL, fireworkColor, false, - true, new Vector(0, 0.01, 0), 1); - } - } - public void spawnFirework(int tick) { Location loc = getBaseLocation(); - for(int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { double r = 3; double rad = (((Math.PI * 2) / 3.0) * i) + ((tick % 240) * Math.PI / 120.0); @@ -513,6 +495,7 @@ public abstract class WinEffectGadget extends Gadget /** * Gets the formatted rank of the player + * * @param player * @return */ diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/util/BalloonData.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/util/BalloonData.java deleted file mode 100644 index 8ac58de85..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/util/BalloonData.java +++ /dev/null @@ -1,140 +0,0 @@ -package mineplex.core.gadget.util; - -import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilMath; - -public class BalloonData -{ - - /** - * Makes the balloons fly around the player - * Copied from {@link mineplex.core.gadget.gadgets.particle.ParticleFairyData} - */ - - private Player _player; - private Entity _balloon, _passenger, _leash; - private Location _balloonLoc, _target; - private Vector _direction; - private double _speed; - private long _idleTime; - - public BalloonData(Player player, Entity balloon) - { - _player = player; - _balloon = balloon; - _balloonLoc = player.getEyeLocation(); - _target = getNewTarget(); - _speed = 0.2; - _idleTime = 0; - _direction = new Vector(1, 0, 0); - ((LivingEntity) _balloon).setLeashHolder(_player); - } - - // This exists for a possible widder balloon that could be added later - public BalloonData(Player player, Entity balloon, Entity passenger) - { - _player = player; - _balloon = balloon; - _passenger = passenger; - _balloonLoc = player.getEyeLocation(); - _target = getNewTarget(); - _speed = 0.2; - _idleTime = 0; - _direction = new Vector(1, 0, 0); - ((LivingEntity) _balloon).setLeashHolder(_player); - } - - public void teleport() - { - _balloon.teleport(_balloonLoc); - _balloon.setVelocity(new Vector(0, 3, 0)); - } - - public void update() - { - if (_leash == null) - { - if (!((LivingEntity) _balloon).isLeashed()) - ((LivingEntity) _balloon).setLeashHolder(_player); - } - else - { - if (!((LivingEntity) _leash).isLeashed()) - ((LivingEntity) _leash).setLeashHolder(_player); - } - - //Update Target - if (UtilMath.offset(_player.getEyeLocation(), _target) > 3 || UtilMath.offset(_balloonLoc, _target) < 1) - _target = getNewTarget(); - - //Pause? - if (Math.random() > 0.98) - _idleTime = System.currentTimeMillis() + (long)(Math.random() * 3000); - - //Speed - if (UtilMath.offset(_player.getEyeLocation(), _balloonLoc) < 3) - { - if (_idleTime > System.currentTimeMillis()) - { - _speed = Math.max(0, _speed - 0.005); - } - else - { - _speed = Math.min(0.15, _speed + 0.005); - } - } - else - { - _idleTime = 0; - - _speed = Math.min(0.15 + UtilMath.offset(_player.getEyeLocation(), _balloonLoc) * 0.05, _speed + 0.02); - } - - - //Modify Direction - _direction.add(UtilAlg.getTrajectory(_balloonLoc, _target).multiply(0.15)); - if (_direction.length() < 1) - _speed = _speed * _direction.length(); - UtilAlg.Normalize(_direction); - - //Move - if (UtilMath.offset(_balloonLoc, _target) > 0.1) - _balloonLoc.add(_direction.clone().multiply(_speed)); - - _balloon.teleport(_balloonLoc); - _balloon.setVelocity(new Vector(0, .25, 0)); - if (_passenger != null) - { - _passenger.teleport(_balloonLoc); - _balloon.setPassenger(_passenger); - } - if (_leash != null) - { - _leash.teleport(_balloon.getLocation().add(0, 1.5, 0)); - } - //return false; - } - - private Location getNewTarget() - { - return _player.getEyeLocation().add(Math.random() * 6 - 3, Math.random() * 7.5, Math.random() * 6 - 3); - } - - public Entity getBalloon() - { - return _balloon; - } - - public void setLeash(Entity leashedEntity) - { - _leash = leashedEntity; - ((LivingEntity) _leash).setLeashHolder(_player); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/util/CostConstants.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/util/CostConstants.java index 5fa7db300..0bf7fe34c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/util/CostConstants.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/util/CostConstants.java @@ -75,6 +75,14 @@ public class CostConstants * Found in Trick or Treat Treasure */ public static final int FOUND_IN_TRICK_OR_TREAT = -22; + /** + * Found in MineStrike Chests + */ + public static final int FOUND_IN_MINESTRIKE_CHESTS = -23; + /** + * Unlocked in Level Rewards + */ + public static final int LEVEL_REWARDS = -24; /** * Unlocked with Ultra Rank */ diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BlowAKissEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BlowAKissEffect.java index 35345f4ff..b29247f06 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BlowAKissEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/BlowAKissEffect.java @@ -8,6 +8,7 @@ import org.bukkit.util.Vector; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; public class BlowAKissEffect extends Effect @@ -64,18 +65,16 @@ public class BlowAKissEffect extends Effect private boolean checkPlayer() { - for (Player player : UtilServer.getPlayers()) + for (Player player : UtilPlayer.getNearby(_fixedLoc, 1.25)) { if (player.equals(_player)) continue; - if (player.getLocation().distanceSquared(_fixedLoc) <= 2.25) - { - UtilParticle.PlayParticle(UtilParticle.ParticleType.HEART, player.getLocation(), 0.25f, 0.25f, 0.25f, 0.5f, 7, UtilParticle.ViewDist.NORMAL); - UtilServer.broadcast(F.main("Blow A Kiss", F.name(_player.getName()) + " blows a kiss at " + F.name(player.getName()) + "!")); - return true; - } + UtilParticle.PlayParticle(UtilParticle.ParticleType.HEART, player.getLocation(), 0.25f, 0.25f, 0.25f, 0.5f, 7, UtilParticle.ViewDist.NORMAL); + UtilServer.broadcast(F.main("Blow A Kiss", F.name(_player.getName()) + " blows a kiss at " + F.name(player.getName()) + "!")); + return true; } + return false; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/LoveDoctorEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/LoveDoctorEffect.java index fad8f33df..497267cdd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/LoveDoctorEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/LoveDoctorEffect.java @@ -77,8 +77,10 @@ public class LoveDoctorEffect extends Effect HashMap players = UtilPlayer.getInRadius(loc, 9d); for (Player ent : players.keySet()) { - if (_gadget.Manager.collideEvent(_player, _gadget, ent)) + if (!_gadget.Manager.selectEntity(_gadget, ent)) + { continue; + } double mult = players.get(ent); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/MetalManEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/MetalManEffect.java index c960e4969..e88ed9226 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/MetalManEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/MetalManEffect.java @@ -105,8 +105,10 @@ public class MetalManEffect extends Effect HashMap players = UtilPlayer.getInRadius(loc, 9d); for (Player ent : players.keySet()) { - if (_gadget.Manager.collideEvent(_player, _gadget, ent)) + if (!_gadget.Manager.selectEntity(_gadget, ent)) + { continue; + } double mult = players.get(ent); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/TextEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/TextEffect.java index 7e8439895..a04fa20eb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/TextEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/TextEffect.java @@ -60,7 +60,9 @@ public class TextEffect extends Effect _bufferedImage = UtilText.stringToBufferedImage(FONT, _text); } - int color; + Location location = _effectLocation.getFixedLocation(); + int color, height = _bufferedImage.getHeight() / 2, width = _bufferedImage.getWidth() / 2; + double yaw = Math.toRadians(location.getYaw() + 180); for (int y = 0; y < _bufferedImage.getHeight(); y++) { @@ -77,9 +79,10 @@ public class TextEffect extends Effect continue; } - Vector vector = new Vector((float) _bufferedImage.getWidth() / 2 - x, (float) _bufferedImage.getHeight() / 2 - y, 0).multiply(IMAGE_SIZE); - vector = UtilAlg.rotateAroundYAxis(vector, -_effectLocation.getFixedLocation().getYaw() * (Math.PI / 180)); - UtilParticle.PlayParticleToAll(_particleType, _effectLocation.getFixedLocation().clone().add(vector), 0, 0, 0, 0.0001F, 1, ViewDist.LONG); + Vector vector = new Vector(width - x, height - y, 0).multiply(IMAGE_SIZE); + UtilAlg.rotateAroundYAxis(vector, yaw); + UtilParticle.PlayParticleToAll(_particleType, location.add(vector), 0, 0, 0, 0, 1, ViewDist.LONG); + location.subtract(vector); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index 82e7076a8..db8a310e1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -424,6 +424,7 @@ public class PetManager extends MiniClientPlugin // Spawns villager Villager villager = _creatureModule.SpawnEntity(zombie.getLocation(), Villager.class); villager.setBaby(); + villager.setAgeLock(true); UtilEnt.silence(villager, true); _trueLovePets.put(zombie, new TrueLoveData(player, zombie, villager)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPet.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPet.java deleted file mode 100644 index d46290c2f..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPet.java +++ /dev/null @@ -1,168 +0,0 @@ -package mineplex.core.pet.custom; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.cosmetic.ui.page.GadgetPage; -import mineplex.core.donation.DonationManager; -import mineplex.core.pet.PetManager; - -public abstract class CustomPet -{ - - private static Map _customPet = new HashMap<>(); - - protected PetManager _petManager; - protected Player _player; - protected EntityType _entityType; - protected int _step = 0; - private String _name; - private List _lines = new ArrayList<>(); - - public CustomPet(PetManager petManager, Player player, EntityType entityType) - { - _petManager = petManager; - _player = player; - _entityType = entityType; - _customPet.put(player, this); - } - - public void spawn(Entity entity) - { - UtilEnt.silence(entity, true); - onSpawn(entity); - } - - public abstract void onSpawn(Entity entity); - - public abstract GadgetPage getNextStep(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager); - - public abstract GadgetPage getPreviousStep(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager); - - public void setName(String name) - { - _name = name; - } - - public String getName() - { - return _name; - } - - public void addLine(String lineKey, String lineValue) - { - _lines.add(C.cGray + lineKey + ": " + F.name(lineValue)); - } - - public void addLine(String lineKey, String lineValue, int i) - { - _lines.add(i, C.cGray + lineKey + ": " + F.name(lineValue)); - } - - protected void addTypeLine(String type) - { - addLine("Type", type); - } - - public List getLines() - { - return _lines; - } - - public ItemStack getCustomPetDescription() - { - ItemStack itemStack = new ItemStack(Material.PAPER); - ItemMeta meta = itemStack.getItemMeta(); - if (_name != null) - { - meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', _name)); - } - else - { - meta.setDisplayName("Custom Pet"); - } - meta.setLore(_lines); - itemStack.setItemMeta(meta); - return itemStack; - } - - public static CustomPet getCustomPet(Player player) - { - if (_customPet.containsKey(player)) - { - return _customPet.get(player); - } - return null; - } - - public static void removeCustomPet(Player player) - { - if (_customPet.containsKey(player)) - { - _customPet.remove(player); - } - } - - public enum CustomPetType - { - ZOMBIE("Zombie", Material.GLASS); - - private String _name; - private Material _material; - private byte _data; - - CustomPetType(String name, Material material, byte data) - { - _name = name; - _material = material; - _data = data; - } - - CustomPetType(String name, Material material) - { - this(name, material, (byte) 0); - } - - public String getName() - { - return _name; - } - - public Material getMaterial() - { - return _material; - } - - public byte getData() - { - return _data; - } - - public CustomPet getCustomPet(PetManager petManager, Player player) - { - switch (this) - { - case ZOMBIE: - return new CustomPetZombie(petManager, player); - default: - return new CustomPetZombie(petManager, player); - } - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPetAgeable.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPetAgeable.java deleted file mode 100644 index 9744b784b..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPetAgeable.java +++ /dev/null @@ -1,28 +0,0 @@ -package mineplex.core.pet.custom; - -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; - -import mineplex.core.pet.PetManager; - -public abstract class CustomPetAgeable extends CustomPet -{ - - private boolean _baby = false; - - public CustomPetAgeable(PetManager petManager, Player player, EntityType entityType) - { - super(petManager, player, entityType); - } - - public void setBaby(boolean baby) - { - _baby = baby; - addLine("Age", (baby) ? "Baby" : "Adult"); - } - - protected boolean isBaby() - { - return _baby; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPetEquipment.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPetEquipment.java deleted file mode 100644 index 60ea7224b..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPetEquipment.java +++ /dev/null @@ -1,66 +0,0 @@ -package mineplex.core.pet.custom; - -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.pet.PetManager; - -public abstract class CustomPetEquipment extends CustomPetAgeable -{ - - private ItemStack _helmet; - private ItemStack _chestplate; - private ItemStack _leggings; - private ItemStack _boots; - - public CustomPetEquipment(PetManager petManager, Player player, EntityType entityType) - { - super(petManager, player, entityType); - } - - public void setHelmet(ItemStack helmet) - { - _helmet = helmet; - addLine("Helmet", (helmet.getType() == Material.AIR) ? "None" : helmet.getItemMeta().getDisplayName()); - } - - public void setChestplate(ItemStack chestplate) - { - _chestplate = chestplate; - addLine("Chestplate", (chestplate.getType() == Material.AIR) ? "None" : chestplate.getItemMeta().getDisplayName()); - } - - public void setLeggings(ItemStack leggings) - { - _leggings = leggings; - addLine("Leggings", (leggings.getType() == Material.AIR) ? "None" : leggings.getItemMeta().getDisplayName()); - } - - public void setBoots(ItemStack boots) - { - _boots = boots; - addLine("Boots", (boots.getType() == Material.AIR) ? "None" : boots.getItemMeta().getDisplayName()); - } - - public ItemStack getHelmet() - { - return _helmet; - } - - public ItemStack getChestplate() - { - return _chestplate; - } - - public ItemStack getLeggings() - { - return _leggings; - } - - public ItemStack getBoots() - { - return _boots; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPetZombie.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPetZombie.java deleted file mode 100644 index b45c57f6d..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPetZombie.java +++ /dev/null @@ -1,149 +0,0 @@ -package mineplex.core.pet.custom; - -import org.bukkit.ChatColor; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.cosmetic.ui.CosmeticShop; -import mineplex.core.cosmetic.ui.page.GadgetPage; -import mineplex.core.cosmetic.ui.page.custompet.CustomPetBasePage; -import mineplex.core.cosmetic.ui.page.custompet.CustomPetConfirmPage; -import mineplex.core.cosmetic.ui.page.custompet.age.CustomPetAgePage; -import mineplex.core.cosmetic.ui.page.custompet.equipment.CustomPetBootsPage; -import mineplex.core.cosmetic.ui.page.custompet.equipment.CustomPetChestplatePage; -import mineplex.core.cosmetic.ui.page.custompet.equipment.CustomPetHelmetPage; -import mineplex.core.cosmetic.ui.page.custompet.equipment.CustomPetLeggingsPage; -import mineplex.core.cosmetic.ui.page.custompet.name.CustomPetNamePage; -import mineplex.core.cosmetic.ui.page.custompet.zombie.CustomPetZombieTypePage; -import mineplex.core.disguise.disguises.DisguiseZombie; -import mineplex.core.donation.DonationManager; -import mineplex.core.pet.PetManager; - -public class CustomPetZombie extends CustomPetEquipment -{ - - private boolean _villager = false; - - public CustomPetZombie(PetManager petManager, Player player) - { - super(petManager, player, EntityType.ZOMBIE); - addTypeLine("Zombie"); - } - - @Override - public void onSpawn(Entity entity) - { - DisguiseZombie disguiseZombie = new DisguiseZombie(entity); - disguiseZombie.setBaby(isBaby()); - disguiseZombie.setVillager(_villager); - if (getHelmet() != null) - { - disguiseZombie.setHelmet(getHelmet()); - } - if (getChestplate() != null) - { - disguiseZombie.setChestplate(getChestplate()); - } - if (getLeggings() != null) - { - disguiseZombie.setLeggings(getLeggings()); - } - if (getBoots() != null) - { - disguiseZombie.setBoots(getBoots()); - } - if (getName() != null) - { - disguiseZombie.setCustomNameVisible(true); - disguiseZombie.setName(ChatColor.translateAlternateColorCodes('&', getName())); - } - else - { - disguiseZombie.setCustomNameVisible(false); - } - _petManager.getDisguiseManager().disguise(disguiseZombie); - } - - @Override - public GadgetPage getNextStep(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager) - { - switch (_step) - { - case 0: - _step++; - return new CustomPetNamePage(plugin, shop, clientManager, donationManager, "Zombie Name", _player); - case 1: - _step++; - return new CustomPetAgePage(plugin, shop, clientManager, donationManager, "Zombie Age", _player); - case 2: - _step++; - return new CustomPetHelmetPage(plugin, shop, clientManager, donationManager, "Zombie Helmet", _player); - case 3: - _step++; - return new CustomPetChestplatePage(plugin, shop, clientManager, donationManager, "Zombie Chestplate", _player); - case 4: - _step++; - return new CustomPetLeggingsPage(plugin, shop, clientManager, donationManager, "Zombie Leggings", _player); - case 5: - _step++; - return new CustomPetBootsPage(plugin, shop, clientManager, donationManager, "Zombie Boots", _player); - case 6: - _step++; - return new CustomPetZombieTypePage(plugin, shop, clientManager, donationManager, "Zombie Type", _player); - case 7: - _step++; - return new CustomPetConfirmPage(plugin, shop, clientManager, donationManager, "Confirm", _player); - default: - _step++; - return new CustomPetAgePage(plugin, shop, clientManager, donationManager, "Zombie Age", _player); - } - } - - @Override - public GadgetPage getPreviousStep(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager) - { - switch (_step) - { - case 1: - _step--; - return new CustomPetBasePage(plugin, shop, clientManager, donationManager, "Custom Pet", _player); - case 2: - _step--; - return new CustomPetNamePage(plugin, shop, clientManager, donationManager, "Zombie Name", _player); - case 3: - _step--; - return new CustomPetAgePage(plugin, shop, clientManager, donationManager, "Zombie Age", _player); - case 4: - _step--; - return new CustomPetHelmetPage(plugin, shop, clientManager, donationManager, "Zombie Helmet", _player); - case 5: - _step--; - return new CustomPetChestplatePage(plugin, shop, clientManager, donationManager, "Zombie Chestplate", _player); - case 6: - _step--; - return new CustomPetLeggingsPage(plugin, shop, clientManager, donationManager, "Zombie Leggings", _player); - case 7: - _step--; - return new CustomPetBootsPage(plugin, shop, clientManager, donationManager, "Zombie Boots", _player); - case 8: - _step--; - return new CustomPetZombieTypePage(plugin, shop, clientManager, donationManager, "Zombie Type", _player); - default: - _step--; - return new CustomPetBasePage(plugin, shop, clientManager, donationManager, "Custom Pet", _player); - } - } - - public void setVillager(boolean villager) - { - _villager = villager; - } - - public boolean isVillager() - { - return _villager; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index dca70b578..10dfbd23e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -47,6 +47,7 @@ public class PowerPlayClubRewards .put(YearMonth.of(2017, Month.DECEMBER), new UnknownSalesPackageItem("Sledge Mount")) .put(YearMonth.of(2018, Month.JANUARY), new UnknownSalesPackageItem("Mob Bomb")) .put(YearMonth.of(2018, Month.FEBRUARY), new UnknownSalesPackageItem("Play Catch")) + .put(YearMonth.of(2018, Month.MARCH), new UnknownSalesPackageItem("Connect 4")) .build(); public interface PowerPlayClubItem diff --git a/Plugins/Mineplex.Core/src/mineplex/core/profile/ProfileManager.java b/Plugins/Mineplex.Core/src/mineplex/core/profile/ProfileManager.java index e4fdeac8b..debdd2346 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/profile/ProfileManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/profile/ProfileManager.java @@ -4,7 +4,6 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.function.Function; @@ -24,7 +23,6 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.Achievement; import mineplex.core.achievement.AchievementManager; import mineplex.core.achievement.leveling.LevelingManager; -import mineplex.core.achievement.leveling.rewards.LevelReward; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; @@ -151,22 +149,22 @@ public class ProfileManager extends MiniPlugin } return "Missions: " + C.cYellow + available + C.cGreen + " Available"; - }, - // Level Rewards - player -> - { - int available = 0; - - for (Entry entry : _levelingManager.getLevelRewards()) - { - if (_levelingManager.canClaim(player, entry.getKey()) && !_levelingManager.hasClaimed(player, entry.getKey())) - { - available++; - } - } - - return "Level Rewards: " + C.cYellow + available + C.cGreen + " Available"; } + // Level Rewards +// player -> +// { +// int available = 0; +// +// for (Entry entry : _levelingManager.getLevelRewards().entrySet()) +// { +// if (_levelingManager.canClaim(player, entry.getKey()) && !_levelingManager.hasClaimed(player, entry.getKey())) +// { +// available++; +// } +// } +// +// return "Level Rewards: " + C.cYellow + available + C.cGreen + " Available"; +// } ); spawnNPC(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java index 4353e8073..01a4352ff 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java @@ -9,7 +9,7 @@ public enum RewardType OLD_CHEST( 20, 0.06, 0.8, 16, 40), ANCIENT_CHEST( 0, 2, 8, 32, 0), - MYTHICAL_CHEST( 0.1, 4, 16, 72, 0), + MYTHICAL_CHEST( 0.001, 4, 18, 72, 0), WINTER_CHEST( 0, 5, 18, 32, 40), ILLUMINATED_CHEST( 0, 2, 16, 72, 0), FREEDOM_CHEST( 0, 5, 18, 0, 0), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/MultiPageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/MultiPageManager.java index 74cae6c9f..ab05d688b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/MultiPageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/MultiPageManager.java @@ -6,19 +6,21 @@ import java.util.function.BiPredicate; import java.util.function.Supplier; import org.bukkit.Material; +import org.bukkit.entity.Player; -import mineplex.core.common.Pair; import mineplex.core.common.util.C; +import mineplex.core.recharge.Recharge; import mineplex.core.shop.item.ShopItem; public class MultiPageManager { - private int ELEMENTS_PER_PAGE = 28; + + private int _elementsPerPage = 28; private int _page; - private BiPredicate _addItem; - private Supplier> _getItems; - private ShopPageBase _shopPage; + private final BiPredicate _addItem; + private final Supplier> _getItems; + private final ShopPageBase _shopPage; public MultiPageManager(ShopPageBase shopPage, Supplier> getItems, BiPredicate addItem) { @@ -38,12 +40,12 @@ public class MultiPageManager public void setElementsPerPage(int elements) { - this.ELEMENTS_PER_PAGE = elements; + _elementsPerPage = elements; } public int getElementsPerPage() { - return ELEMENTS_PER_PAGE; + return _elementsPerPage; } public void setPage(int page) @@ -55,10 +57,13 @@ public class MultiPageManager public void buildPage() { int slot = 10; - int startIndex = _page * ELEMENTS_PER_PAGE; - int endIndex = startIndex + ELEMENTS_PER_PAGE; + int startIndex = _page * _elementsPerPage; + int endIndex = startIndex + _elementsPerPage; - for (ItemType item : _getItems.get()) + List items = _getItems.get(); + items = items.subList(startIndex, Math.min(endIndex, items.size())); + + for (ItemType item : items) { if (!_addItem.test(item, slot)) { @@ -75,6 +80,11 @@ public class MultiPageManager { _shopPage.addButton(45, new ShopItem(Material.ARROW, C.cGreen + "Previous Page", new String[0], 1, false), (player, clickType) -> { + if (!changePage(player)) + { + return; + } + _page--; _shopPage.refresh(); }); @@ -84,9 +94,26 @@ public class MultiPageManager { _shopPage.addButton(53, new ShopItem(Material.ARROW, C.cGreen + "Next Page", new String[0], 1, false), (player, clickType) -> { + if (!changePage(player)) + { + return; + } + _page++; _shopPage.refresh(); }); } } + + private boolean changePage(Player player) + { + boolean can = Recharge.Instance.use(player, "Change Page", 200, false, false); + + if (!can) + { + _shopPage.playDenySound(player); + } + + return can; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/IlluminatedTreasure.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/IlluminatedTreasure.java index dbb480a6a..e60646fc7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/IlluminatedTreasure.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/IlluminatedTreasure.java @@ -1,14 +1,9 @@ package mineplex.core.treasure.types; -import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector; -import mineplex.core.gadget.gadgets.kitselector.RainbowDanceKitSelector; -import mineplex.core.gadget.gadgets.kitselector.ShimmeringRingKitSelector; -import mineplex.core.gadget.gadgets.kitselector.SingleParticleKitSelector; import mineplex.core.reward.Reward; import mineplex.core.reward.RewardType; import mineplex.core.reward.rewards.InventoryReward; import mineplex.core.treasure.animation.animations.IlluminatedChestAnimation; -import mineplex.core.treasure.reward.RewardRarity; public class IlluminatedTreasure extends NormalTreasure { @@ -25,18 +20,6 @@ public class IlluminatedTreasure extends NormalTreasure enabledByDefault(); } - @Override - protected void addRare(RewardRarity rarity) - { - // Kit Selectors - addGadgetReward(getGadget(HaloKitSelector.class), rarity, 100); - addGadgetReward(getGadget(RainbowDanceKitSelector.class), rarity, 100); - addGadgetReward(getGadget(ShimmeringRingKitSelector.class), rarity, 150); - addGadgetReward(getKitSelector(SingleParticleKitSelector.SingleParticleSelectors.FLAMES_OF_FURY), rarity, 150); - addGadgetReward(getKitSelector(SingleParticleKitSelector.SingleParticleSelectors.EMBER), rarity, 100); - addGadgetReward(getKitSelector(SingleParticleKitSelector.SingleParticleSelectors.LOVE), rarity, 100); - } - @Override protected void addReward(Reward reward, int weight) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/MythicalTreasure.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/MythicalTreasure.java index 27ef03578..139a2bdad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/MythicalTreasure.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/MythicalTreasure.java @@ -1,9 +1,5 @@ package mineplex.core.treasure.types; -import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector; -import mineplex.core.gadget.gadgets.kitselector.RainbowDanceKitSelector; -import mineplex.core.gadget.gadgets.kitselector.ShimmeringRingKitSelector; -import mineplex.core.gadget.gadgets.kitselector.SingleParticleKitSelector; import mineplex.core.reward.RewardType; import mineplex.core.treasure.animation.animations.MythicalChestAnimation; import mineplex.core.treasure.reward.RewardRarity; @@ -24,20 +20,6 @@ public class MythicalTreasure extends NormalTreasure enabledByDefault(); } - @Override - protected void addRare(RewardRarity rarity) - { - super.addRare(rarity); - - // Kit Selectors - addGadgetReward(getGadget(HaloKitSelector.class), rarity, 100); - addGadgetReward(getGadget(RainbowDanceKitSelector.class), rarity, 100); - addGadgetReward(getGadget(ShimmeringRingKitSelector.class), rarity, 150); - addGadgetReward(getKitSelector(SingleParticleKitSelector.SingleParticleSelectors.FLAMES_OF_FURY), rarity, 150); - addGadgetReward(getKitSelector(SingleParticleKitSelector.SingleParticleSelectors.EMBER), rarity, 100); - addGadgetReward(getKitSelector(SingleParticleKitSelector.SingleParticleSelectors.LOVE), rarity, 100); - } - @Override protected void addMythical(RewardRarity rarity) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/NormalTreasure.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/NormalTreasure.java index a523ad2a8..59107b1be 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/NormalTreasure.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/NormalTreasure.java @@ -1,5 +1,6 @@ package mineplex.core.treasure.types; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBalance; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; @@ -8,6 +9,7 @@ import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; import mineplex.core.gadget.gadgets.balloons.BalloonType; +import mineplex.core.gadget.gadgets.death.DeathBalance; import mineplex.core.gadget.gadgets.death.DeathBlood; import mineplex.core.gadget.gadgets.death.DeathEmerald; import mineplex.core.gadget.gadgets.death.DeathEnchant; @@ -15,6 +17,7 @@ import mineplex.core.gadget.gadgets.death.DeathMusic; import mineplex.core.gadget.gadgets.death.DeathPinataBurst; import mineplex.core.gadget.gadgets.death.DeathShadow; import mineplex.core.gadget.gadgets.death.DeathStorm; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBalance; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; @@ -29,11 +32,17 @@ import mineplex.core.gadget.gadgets.item.ItemFleshHook; import mineplex.core.gadget.gadgets.item.ItemMelonLauncher; import mineplex.core.gadget.gadgets.item.ItemPaintballGun; import mineplex.core.gadget.gadgets.item.ItemTNT; +import mineplex.core.gadget.gadgets.item.ItemTrampoline; +import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector; +import mineplex.core.gadget.gadgets.kitselector.RainbowDanceKitSelector; +import mineplex.core.gadget.gadgets.kitselector.ShimmeringRingKitSelector; +import mineplex.core.gadget.gadgets.kitselector.SingleParticleKitSelector; import mineplex.core.gadget.gadgets.morph.MorphBat; import mineplex.core.gadget.gadgets.morph.MorphBlock; import mineplex.core.gadget.gadgets.morph.MorphChicken; import mineplex.core.gadget.gadgets.morph.MorphCow; import mineplex.core.gadget.gadgets.morph.MorphEnderman; +import mineplex.core.gadget.gadgets.morph.MorphSkeleton; import mineplex.core.gadget.gadgets.morph.MorphSlime; import mineplex.core.gadget.gadgets.morph.MorphVillager; import mineplex.core.gadget.gadgets.mount.types.MountCart; @@ -50,25 +59,39 @@ import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitChestplate; import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitHelmet; import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitLeggings; import mineplex.core.gadget.gadgets.particle.ParticleBlood; +import mineplex.core.gadget.gadgets.particle.ParticleCape; +import mineplex.core.gadget.gadgets.particle.ParticleChickenWings; +import mineplex.core.gadget.gadgets.particle.ParticleDeepSeaSwirl; import mineplex.core.gadget.gadgets.particle.ParticleEmerald; import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.gadgets.particle.ParticleFairy; import mineplex.core.gadget.gadgets.particle.ParticleFireRings; import mineplex.core.gadget.gadgets.particle.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.ParticleFoxTail; import mineplex.core.gadget.gadgets.particle.ParticleHeart; +import mineplex.core.gadget.gadgets.particle.ParticleInfused; +import mineplex.core.gadget.gadgets.particle.ParticleJetPack; +import mineplex.core.gadget.gadgets.particle.ParticleLegendaryHero; import mineplex.core.gadget.gadgets.particle.ParticleMusic; import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; import mineplex.core.gadget.gadgets.particle.ParticleRain; +import mineplex.core.gadget.gadgets.particle.ParticleRainbowTrail; import mineplex.core.gadget.gadgets.particle.ParticleWingsAngel; import mineplex.core.gadget.gadgets.particle.ParticleWingsDemons; import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal; import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie; +import mineplex.core.gadget.gadgets.particle.ParticleWolfTail; import mineplex.core.gadget.gadgets.particle.ParticleYinYang; +import mineplex.core.gadget.gadgets.taunts.EmojiTaunt; +import mineplex.core.gadget.gadgets.weaponname.WeaponNameType; import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken; +import mineplex.core.gadget.gadgets.wineffect.WinEffectEarthquake; import mineplex.core.gadget.gadgets.wineffect.WinEffectLavaTrap; import mineplex.core.gadget.gadgets.wineffect.WinEffectLightningStrike; import mineplex.core.gadget.gadgets.wineffect.WinEffectMrPunchMan; +import mineplex.core.gadget.gadgets.wineffect.WinEffectPartyAnimal; import mineplex.core.gadget.gadgets.wineffect.WinEffectRiseOfTheElderGuardian; +import mineplex.core.gadget.util.CostConstants; import mineplex.core.pet.PetType; import mineplex.core.treasure.reward.RewardRarity; @@ -140,6 +163,7 @@ public class NormalTreasure extends Treasure addGadgetReward(getGadget(MorphCow.class), rarity, 167); addGadgetReward(getGadget(MorphChicken.class), rarity, 50); addGadgetReward(getGadget(MorphEnderman.class), rarity, 33); + addGadgetReward(getGadget(MorphSkeleton.class), rarity, 40); //Mounts addGadgetReward(getGadget(MountFrost.class), rarity, 50); @@ -165,6 +189,7 @@ public class NormalTreasure extends Treasure addGadgetReward(getGadget(ArrowTrailMusic.class), rarity, 27); addGadgetReward(getGadget(ArrowTrailStorm.class), rarity, 30); addGadgetReward(getGadget(ArrowTrailShadow.class), rarity, 15); + addGadgetReward(getGadget(ArrowTrailBalance.class), rarity, 16); // Double Jumps addGadgetReward(getGadget(DoubleJumpFirecracker.class), rarity, 33); @@ -173,6 +198,7 @@ public class NormalTreasure extends Treasure addGadgetReward(getGadget(DoubleJumpStorm.class), rarity, 30); addGadgetReward(getGadget(DoubleJumpBlood.class), rarity, 50); addGadgetReward(getGadget(DoubleJumpMusic.class), rarity, 20); + addGadgetReward(getGadget(DoubleJumpBalance.class), rarity, 20); // Death Effects addGadgetReward(getGadget(DeathPinataBurst.class), rarity, 27); @@ -181,6 +207,7 @@ public class NormalTreasure extends Treasure addGadgetReward(getGadget(DeathStorm.class), rarity, 30); addGadgetReward(getGadget(DeathBlood.class), rarity, 50); addGadgetReward(getGadget(DeathMusic.class), rarity, 20); + addGadgetReward(getGadget(DeathBalance.class), rarity, 20); // Particles addGadgetReward(getGadget(ParticlePartyTime.class), rarity, 12); @@ -209,6 +236,30 @@ public class NormalTreasure extends Treasure addBalloonReward(BalloonType.BABY_VILLAGER, rarity, 25, 500); addBalloonReward(BalloonType.BABY_SLIME, rarity, 25, 500); addBalloonReward(BalloonType.BAT, rarity, 50, 500); + addBalloonReward(BalloonType.SQUID, rarity, 10); + addBalloonReward(BalloonType.SILVERFISH, rarity, 30); + addBalloonReward(BalloonType.GUARDIAN, rarity, 30); + addBalloonReward(BalloonType.DRAGON_EGG, rarity, 15); + addBalloonReward(BalloonType.DIAMOND_BLOCK, rarity, 15); + addBalloonReward(BalloonType.IRON_BLOCK, rarity, 15); + addBalloonReward(BalloonType.GOLD_BLOCK, rarity, 15); + addBalloonReward(BalloonType.EMERALD_BLOCK, rarity, 15); + addBalloonReward(BalloonType.RED_BLOCK, rarity, 15); + + addGadgetReward(getGadget(HaloKitSelector.class), rarity, 20); + addGadgetReward(getGadget(RainbowDanceKitSelector.class), rarity, 20); + addGadgetReward(getGadget(ShimmeringRingKitSelector.class), rarity, 20); + addGadgetReward(getKitSelector(SingleParticleKitSelector.SingleParticleSelectors.FLAMES_OF_FURY), rarity, 20); + addGadgetReward(getKitSelector(SingleParticleKitSelector.SingleParticleSelectors.EMBER), rarity, 20); + addGadgetReward(getKitSelector(SingleParticleKitSelector.SingleParticleSelectors.LOVE), rarity, 20); + + for (WeaponNameType type : WeaponNameType.values()) + { + if (type.getCost() == CostConstants.FOUND_IN_TREASURE_CHESTS) + { + addWeaponNameReward(type, rarity, 10); + } + } } @Override @@ -242,6 +293,15 @@ public class NormalTreasure extends Treasure addGadgetReward(getGadget(ParticleRain.class), rarity, 13); addGadgetReward(getGadget(ParticleFoot.class), rarity, 33); addGadgetReward(getGadget(ParticleYinYang.class), rarity, 20); + addGadgetReward(getGadget(ParticleChickenWings.class), rarity, 15); + addGadgetReward(getGadget(ParticleFoxTail.class), rarity, 15); + addGadgetReward(getGadget(ParticleWolfTail.class), rarity, 15); + addGadgetReward(getGadget(ParticleJetPack.class), rarity, 15); + addGadgetReward(getGadget(ParticleCape.class), rarity, 15); + addGadgetReward(getGadget(ParticleLegendaryHero.class), rarity, 10); + addGadgetReward(getGadget(ParticleRainbowTrail.class), rarity, 10); + addGadgetReward(getGadget(ParticleDeepSeaSwirl.class), rarity, 10); + addGadgetReward(getGadget(ParticleInfused.class), rarity, 10); // Win Effects addGadgetReward(getGadget(WinEffectBabyChicken.class), rarity, 10); @@ -249,6 +309,8 @@ public class NormalTreasure extends Treasure addGadgetReward(getGadget(WinEffectLightningStrike.class), rarity, 20); addGadgetReward(getGadget(WinEffectMrPunchMan.class), rarity, 33); addGadgetReward(getGadget(WinEffectRiseOfTheElderGuardian.class), rarity, 4); + addGadgetReward(getGadget(WinEffectEarthquake.class), rarity, 10); + addGadgetReward(getGadget(WinEffectPartyAnimal.class), rarity, 10); // Titles addTitleReward("ayyye", rarity, 25); @@ -266,10 +328,8 @@ public class NormalTreasure extends Treasure addTitleReward("gotta-go", rarity, 30); addTitleReward("whaaat", rarity, 30); - // Balloons - addBalloonReward(BalloonType.SQUID, rarity, 10); - addBalloonReward(BalloonType.SILVERFISH, rarity, 30); - addBalloonReward(BalloonType.GUARDIAN, rarity, 30); - addBalloonReward(BalloonType.EMERALD_BLOCK, rarity, 15); + addGadgetReward(getGadget(ItemTrampoline.class), rarity, 10); + + addGadgetReward(getGadget(EmojiTaunt.class), rarity, 25); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/OmegaTreasure.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/OmegaTreasure.java index e303e41fd..08b49772b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/OmegaTreasure.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/OmegaTreasure.java @@ -1,5 +1,8 @@ package mineplex.core.treasure.types; +import java.util.List; + +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBalance; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; @@ -15,6 +18,7 @@ import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailSpring; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; import mineplex.core.gadget.gadgets.balloons.BalloonType; +import mineplex.core.gadget.gadgets.death.DeathBalance; import mineplex.core.gadget.gadgets.death.DeathBlood; import mineplex.core.gadget.gadgets.death.DeathCandyCane; import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; @@ -29,6 +33,7 @@ import mineplex.core.gadget.gadgets.death.DeathPresentDanger; import mineplex.core.gadget.gadgets.death.DeathShadow; import mineplex.core.gadget.gadgets.death.DeathSpring; import mineplex.core.gadget.gadgets.death.DeathStorm; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBalance; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; @@ -45,6 +50,7 @@ import mineplex.core.gadget.gadgets.doublejump.DoubleJumpSpring; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; import mineplex.core.gadget.gadgets.flag.FlagType; import mineplex.core.gadget.gadgets.hat.HatType; +import mineplex.core.gadget.gadgets.item.ItemTrampoline; import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector; import mineplex.core.gadget.gadgets.kitselector.RainbowDanceKitSelector; import mineplex.core.gadget.gadgets.kitselector.ShimmeringRingKitSelector; @@ -59,6 +65,7 @@ import mineplex.core.gadget.gadgets.morph.MorphEnderman; import mineplex.core.gadget.gadgets.morph.MorphGrimReaper; import mineplex.core.gadget.gadgets.morph.MorphLoveDoctor; import mineplex.core.gadget.gadgets.morph.MorphPumpkinKing; +import mineplex.core.gadget.gadgets.morph.MorphSkeleton; import mineplex.core.gadget.gadgets.morph.MorphSlime; import mineplex.core.gadget.gadgets.morph.MorphSnowman; import mineplex.core.gadget.gadgets.morph.MorphUncleSam; @@ -96,24 +103,33 @@ import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksHat; import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksLeggings; import mineplex.core.gadget.gadgets.particle.ParticleBlood; import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; -import mineplex.core.gadget.gadgets.particle.christmas.ParticleChristmasTree; +import mineplex.core.gadget.gadgets.particle.ParticleCape; +import mineplex.core.gadget.gadgets.particle.ParticleChickenWings; import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes; +import mineplex.core.gadget.gadgets.particle.ParticleDeepSeaSwirl; import mineplex.core.gadget.gadgets.particle.ParticleEmerald; import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.gadgets.particle.ParticleFairy; import mineplex.core.gadget.gadgets.particle.ParticleFireRings; import mineplex.core.gadget.gadgets.particle.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.ParticleFoxTail; import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; import mineplex.core.gadget.gadgets.particle.ParticleHeart; +import mineplex.core.gadget.gadgets.particle.ParticleInfused; +import mineplex.core.gadget.gadgets.particle.ParticleJetPack; +import mineplex.core.gadget.gadgets.particle.ParticleLegendaryHero; import mineplex.core.gadget.gadgets.particle.ParticleMusic; import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; import mineplex.core.gadget.gadgets.particle.ParticleRain; +import mineplex.core.gadget.gadgets.particle.ParticleRainbowTrail; import mineplex.core.gadget.gadgets.particle.ParticleWingsAngel; import mineplex.core.gadget.gadgets.particle.ParticleWingsDemons; import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal; import mineplex.core.gadget.gadgets.particle.ParticleWingsLove; import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie; +import mineplex.core.gadget.gadgets.particle.ParticleWolfTail; import mineplex.core.gadget.gadgets.particle.ParticleYinYang; +import mineplex.core.gadget.gadgets.particle.christmas.ParticleChristmasTree; import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; @@ -121,15 +137,19 @@ import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; +import mineplex.core.gadget.gadgets.taunts.EmojiTaunt; import mineplex.core.gadget.gadgets.taunts.RainbowTaunt; import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken; +import mineplex.core.gadget.gadgets.wineffect.WinEffectEarthquake; import mineplex.core.gadget.gadgets.wineffect.WinEffectFlames; import mineplex.core.gadget.gadgets.wineffect.WinEffectHalloween; import mineplex.core.gadget.gadgets.wineffect.WinEffectLavaTrap; import mineplex.core.gadget.gadgets.wineffect.WinEffectLightningStrike; import mineplex.core.gadget.gadgets.wineffect.WinEffectMrPunchMan; +import mineplex.core.gadget.gadgets.wineffect.WinEffectPartyAnimal; import mineplex.core.gadget.gadgets.wineffect.WinEffectRiseOfTheElderGuardian; import mineplex.core.gadget.gadgets.wineffect.WinEffectSnowTrails; +import mineplex.core.gadget.types.Gadget; import mineplex.core.pet.PetType; import mineplex.core.reward.RewardType; import mineplex.core.treasure.animation.animations.OmegaChestAnimation; @@ -206,6 +226,7 @@ public class OmegaTreasure extends Treasure addGadgetReward(getGadget(DoubleJumpSpring.class), rarity, 40); addGadgetReward(getGadget(DoubleJumpFreedom.class), rarity, 50); addGadgetReward(getGadget(DoubleJumpMaple.class), rarity, 50); + addGadgetReward(getGadget(DoubleJumpBalance.class), rarity, 20); addGadgetReward(getGadget(DeathFreedom.class), rarity, 15); addGadgetReward(getGadget(DeathStorm.class), rarity, 30); @@ -217,6 +238,7 @@ public class OmegaTreasure extends Treasure addGadgetReward(getGadget(DeathCandyCane.class), rarity, 25); addGadgetReward(getGadget(DeathSpring.class), rarity, 60); addGadgetReward(getGadget(DeathMapleLeaf.class), rarity, 10); + addGadgetReward(getGadget(DeathBalance.class), rarity, 20); addGadgetReward(getGadget(ArrowTrailFreedom.class), rarity, 10); addGadgetReward(getGadget(ArrowTrailConfetti.class), rarity, 27); @@ -227,6 +249,7 @@ public class OmegaTreasure extends Treasure addGadgetReward(getGadget(ArrowTrailShadow.class), rarity, 15); addGadgetReward(getGadget(ArrowTrailCandyCane.class), rarity, 10); addGadgetReward(getGadget(ArrowTrailSpring.class), rarity, 60); + addGadgetReward(getGadget(ArrowTrailBalance.class), rarity, 20); addHatReward(HatType.UNCLE_SAM, rarity, 25); addHatReward(HatType.COMPANION_BLOCK, rarity, 15); @@ -243,6 +266,7 @@ public class OmegaTreasure extends Treasure addGadgetReward(getGadget(MorphCow.class), rarity, 167); addGadgetReward(getGadget(MorphEnderman.class), rarity, 33); addGadgetReward(getGadget(MorphVillager.class), rarity, 83); + addGadgetReward(getGadget(MorphSkeleton.class), rarity, 40); addGadgetReward(getGadget(WinEffectFlames.class), rarity, 100); addGadgetReward(getGadget(WinEffectSnowTrails.class), rarity, 100); @@ -278,6 +302,22 @@ public class OmegaTreasure extends Treasure addBalloonReward(BalloonType.BABY_VILLAGER, rarity, 25, 500); addBalloonReward(BalloonType.BABY_SLIME, rarity, 25, 500); addBalloonReward(BalloonType.BAT, rarity, 50, 500); + addBalloonReward(BalloonType.BABY_ZOMBIE, rarity, 25, 500); + addBalloonReward(BalloonType.BABY_MUSHROOM, rarity, 50, 500); + addBalloonReward(BalloonType.BABY_OCELOT, rarity, 50, 500); + addBalloonReward(BalloonType.BABY_WOLF, rarity, 75, 500); + addBalloonReward(BalloonType.BABY_VILLAGER, rarity, 25, 500); + addBalloonReward(BalloonType.BABY_SLIME, rarity, 25, 500); + addBalloonReward(BalloonType.BAT, rarity, 50, 500); + addBalloonReward(BalloonType.SQUID, rarity, 10); + addBalloonReward(BalloonType.SILVERFISH, rarity, 30); + addBalloonReward(BalloonType.GUARDIAN, rarity, 30); + addBalloonReward(BalloonType.DRAGON_EGG, rarity, 15); + addBalloonReward(BalloonType.DIAMOND_BLOCK, rarity, 15); + addBalloonReward(BalloonType.IRON_BLOCK, rarity, 15); + addBalloonReward(BalloonType.GOLD_BLOCK, rarity, 15); + addBalloonReward(BalloonType.EMERALD_BLOCK, rarity, 15); + addBalloonReward(BalloonType.RED_BLOCK, rarity, 15); addGadgetReward(getGadget(HaloKitSelector.class), rarity, 100); addGadgetReward(getGadget(RainbowDanceKitSelector.class), rarity, 100); @@ -347,6 +387,15 @@ public class OmegaTreasure extends Treasure addGadgetReward(getGadget(ParticleAuraNiceness.class), rarity, 4); addGadgetReward(getGadget(ParticleCanadian.class), rarity, 1); addGadgetReward(getGadget(ParticleStarSpangled.class), rarity, 1); + addGadgetReward(getGadget(ParticleChickenWings.class), rarity, 15); + addGadgetReward(getGadget(ParticleFoxTail.class), rarity, 15); + addGadgetReward(getGadget(ParticleWolfTail.class), rarity, 15); + addGadgetReward(getGadget(ParticleJetPack.class), rarity, 15); + addGadgetReward(getGadget(ParticleCape.class), rarity, 15); + addGadgetReward(getGadget(ParticleLegendaryHero.class), rarity, 10); + addGadgetReward(getGadget(ParticleRainbowTrail.class), rarity, 10); + addGadgetReward(getGadget(ParticleDeepSeaSwirl.class), rarity, 10); + addGadgetReward(getGadget(ParticleInfused.class), rarity, 10); addGadgetReward(getGadget(MountFreedomHorse.class), rarity, 5); addGadgetReward(getGadget(MountZombie.class), rarity, 1); @@ -365,6 +414,8 @@ public class OmegaTreasure extends Treasure addGadgetReward(getGadget(WinEffectLightningStrike.class), rarity, 20); addGadgetReward(getGadget(WinEffectMrPunchMan.class), rarity, 33); addGadgetReward(getGadget(WinEffectHalloween.class), rarity, 75); + addGadgetReward(getGadget(WinEffectEarthquake.class), rarity, 10); + addGadgetReward(getGadget(WinEffectPartyAnimal.class), rarity, 10); addGadgetReward(getGadget(DeathEnchant.class), rarity, 10); addGadgetReward(getGadget(DeathCupidsBrokenHeart.class), rarity, 25); @@ -384,16 +435,24 @@ public class OmegaTreasure extends Treasure addGadgetReward(getGadget(OutfitStPatricksHat.class), rarity, 5); addGadgetReward(getGadget(OutfitFreezeSuitHelmet.class), rarity, 2); - addBalloonReward(BalloonType.SQUID, rarity, 10, 5000); - addBalloonReward(BalloonType.SILVERFISH, rarity, 30, 5000); - addBalloonReward(BalloonType.GUARDIAN, rarity, 30, 5000); - addBalloonReward(BalloonType.EMERALD_BLOCK, rarity, 15, 5000); - addGadgetReward(getGadget(BlowAKissTaunt.class), rarity, 7); addGadgetReward(getGadget(RainbowTaunt.class), rarity, 1); + addGadgetReward(getGadget(EmojiTaunt.class), rarity, 15); addFlagReward(FlagType.CANADA, rarity, 35); addFlagReward(FlagType.USA, rarity, 35); + addFlagReward(FlagType.HEART, rarity, 50); + + addGadgetReward(getGadget(ItemTrampoline.class), rarity, 10); + + List powerPlayGadgets = GADGET_MANAGER.getPowerPlayGadgets(); + + if (powerPlayGadgets.size() > 6) + { + powerPlayGadgets = powerPlayGadgets.subList(0, powerPlayGadgets.size() - 6); + } + + powerPlayGadgets.forEach(gadget -> addGadgetReward(gadget, rarity, 5)); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/Treasure.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/Treasure.java index e7405fc35..9d458a100 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/Treasure.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/types/Treasure.java @@ -16,6 +16,7 @@ import mineplex.core.gadget.gadgets.balloons.BalloonType; import mineplex.core.gadget.gadgets.flag.FlagType; import mineplex.core.gadget.gadgets.hat.HatType; import mineplex.core.gadget.gadgets.kitselector.SingleParticleKitSelector; +import mineplex.core.gadget.gadgets.weaponname.WeaponNameType; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.ItemGadget; @@ -314,6 +315,16 @@ public class Treasure return addGadgetReward(GADGET_MANAGER.getFlagGadget(type), rarity, weight, shards); } + protected GadgetReward addWeaponNameReward(WeaponNameType type, RewardRarity rarity, int weight) + { + return addWeaponNameReward(type, rarity, weight, getShards(rarity)); + } + + protected GadgetReward addWeaponNameReward(WeaponNameType type, RewardRarity rarity, int weight, int shards) + { + return addGadgetReward(GADGET_MANAGER.getWeaponNameGadget(type), rarity, weight, shards); + } + protected ChestReward addChestReward(TreasureType type, RewardRarity rarity, int min, int max, int weight) { ChestReward reward = new ChestReward(type, min, max, rarity, 0); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/KnightLance.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/KnightLance.java index 38b5f1342..e147d44a1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/KnightLance.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/KnightLance.java @@ -1,234 +1,234 @@ -package mineplex.game.clans.items.legendaries; - -import java.util.HashSet; -import java.util.Set; - -import org.bukkit.GameMode; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Horse; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.util.Vector; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextBottom; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.recharge.Recharge; -import mineplex.game.clans.clans.ClansManager; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - -public class KnightLance extends LegendaryItem -{ - private static final double CHARGE_VELOCITY = 1.5d; - private static final double MAX_BUILDUP_TICKS = 20 * 3; - - private boolean _charging; - private double _buildup; - - private transient final Set _hit = new HashSet<>(); //Avoid creating a new list every tick - - public KnightLance() - { - super("Knight's Greatlance", new String[] - { - C.cWhite + "Relic of a bygone age.", - C.cWhite + "Emblazoned with cryptic runes, this", - C.cWhite + "Lance bears the marks of its ancient master.", - C.cWhite + "You feel him with you always:", - C.cWhite + "Heed his warnings and stave off the darkness.", - " ", - C.cWhite + "Deals " + C.cYellow + "8 Damage" + C.cWhite + " with attack", - C.cYellow + "Right-Click" + C.cWhite + " to use " + C.cGreen + "Charge", - }, Material.RECORD_12); - } - - @Override - public void update(Player wielder) - { - boolean holding = isHoldingRightClick(); - - if (holding && !_charging) - { - if (canPropel(wielder)) - { - _buildup = 0; - _charging = true; - } - } - else if (!holding && _charging) - { - _charging = false; - _buildup = 0; - } - else if (_charging && !canPropel(wielder)) - { - _charging = false; - _buildup = 0; - } - - if (_charging) - { - for (Entity near : wielder.getNearbyEntities(0.6, 1, 0.6)) - { - if (near instanceof LivingEntity) - { - LivingEntity entity = (LivingEntity) near; - if (!canHit(wielder, entity)) - { - continue; - } - if (entity instanceof Horse) - { - _hit.add((LivingEntity)((Horse)entity).getPassenger()); - ((Horse)entity).eject(); - } - else - { - _hit.add(entity); - } - } - } - if (!_hit.isEmpty()) - { - _charging = false; - double damagePercentage = getBuildup() / MAX_BUILDUP_TICKS; - _buildup = 0; - - wielder.getWorld().playSound(wielder.getLocation(), Sound.ZOMBIE_METAL, 1.5f, 0.5f); - for (LivingEntity hit : _hit) - { - //Damage Event - ClansManager.getInstance().getDamageManager().NewDamageEvent(hit, wielder, null, - DamageCause.CUSTOM, 2 + (10 * damagePercentage), false, true, false, - wielder.getName(), "Knight's Greatlance Charge"); - - //Velocity - UtilAction.velocity(hit, - UtilAlg.getTrajectory2d(wielder.getLocation().toVector(), hit.getLocation().toVector()), - 2.6, true, 0, 0.2, 1.4, true); - - //Condition - ClansManager.getInstance().getCondition().Factory().Falling("Knight's Greatlance Charge", hit, wielder, 10, false, true); - } - _hit.clear(); - Recharge.Instance.useForce(wielder, "Knight Lance Charge Attack", 5000); - Recharge.Instance.recharge(wielder, "Knight Lance Charge CD Inform"); - return; - } - - propelPlayer(wielder); - UtilTextBottom.displayProgress(getBuildup() / MAX_BUILDUP_TICKS, wielder); - _buildup++; - } - } - - @Override - public void onUnequip(Player wielder) - { - _charging = false; - _buildup = 0; - } - - @Override - public void onAttack(CustomDamageEvent event, Player wielder) - { - event.AddMod("Knight's Greatlance", 7); - } - - private void propelPlayer(Player player) - { - Vector direction = player.getLocation().getDirection().normalize(); - direction.setY(0); - direction.multiply(CHARGE_VELOCITY); - - player.setVelocity(direction); - - UtilParticle.PlayParticle(ParticleType.CRIT, player.getLocation(), - (float)(Math.random() - 0.5), 0.2f + (float)(Math.random() * 1), (float)(Math.random() - 0.5), 0, 3, - ViewDist.LONG, UtilServer.getPlayers()); - } - - private boolean canPropel(Player player) - { - return UtilEnt.isGrounded(player) && - !UtilEnt.isInWater(player) && - player.getVehicle() == null && - !ClansManager.getInstance().getClanUtility().isSafe(player) && - Recharge.Instance.usable(player, "Knight Lance Charge Attack", Recharge.Instance.use(player, "Knight Lance Charge CD Inform", 1500, false, false)); - } - - private boolean canHit(Player player, LivingEntity entity) - { - if (UtilEnt.hasFlag(entity, "LegendaryAbility.IgnoreMe")) - { - return false; - } - if (ClansManager.getInstance().getClanUtility().isSafe(entity.getLocation())) - { - return false; - } - if (entity instanceof Horse) - { - Entity passenger = ((Horse)entity).getPassenger(); - if (passenger == null) - { - return false; - } - else - { - if (passenger instanceof LivingEntity) - { - if (!canHit(player, (LivingEntity)passenger)) - { - return false; - } - } - else - { - return false; - } - } - } - if (entity instanceof Player) - { - Player target = (Player) entity; - if (ClansManager.getInstance().hasTimer(target)) - { - return false; - } - if (ClansManager.getInstance().isInClan(player) && ClansManager.getInstance().getClan(player).isMember(target)) - { - return false; - } - if (target.getGameMode() == GameMode.CREATIVE || target.getGameMode() == GameMode.SPECTATOR) - { - return false; - } - if (ClansManager.getInstance().getIncognitoManager().Get(target).Hidden) - { - return false; - } - if (ClansManager.getInstance().isInClan(player) && ClansManager.getInstance().getClan(player).isAlly(ClansManager.getInstance().getClan(target))) - { - return false; - } - } - - return true; - } - - private double getBuildup() - { - return UtilMath.clamp(_buildup, 0d, MAX_BUILDUP_TICKS); - } +package mineplex.game.clans.items.legendaries; + +import java.util.HashSet; +import java.util.Set; + +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Horse; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.recharge.Recharge; +import mineplex.game.clans.clans.ClansManager; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class KnightLance extends LegendaryItem +{ + private static final double CHARGE_VELOCITY = 1.5d; + private static final double MAX_BUILDUP_TICKS = 20 * 3; + + private boolean _charging; + private double _buildup; + + private transient final Set _hit = new HashSet<>(); //Avoid creating a new list every tick + + public KnightLance() + { + super("Knight's Greatlance", new String[] + { + C.cWhite + "Relic of a bygone age.", + C.cWhite + "Emblazoned with cryptic runes, this", + C.cWhite + "Lance bears the marks of its ancient master.", + C.cWhite + "You feel him with you always:", + C.cWhite + "Heed his warnings and stave off the darkness.", + " ", + C.cWhite + "Deals " + C.cYellow + "8 Damage" + C.cWhite + " with attack", + C.cYellow + "Right-Click" + C.cWhite + " to use " + C.cGreen + "Charge", + }, Material.RECORD_12); + } + + @Override + public void update(Player wielder) + { + boolean holding = isHoldingRightClick(); + + if (holding && !_charging) + { + if (canPropel(wielder)) + { + _buildup = 0; + _charging = true; + } + } + else if (!holding && _charging) + { + _charging = false; + _buildup = 0; + } + else if (_charging && !canPropel(wielder)) + { + _charging = false; + _buildup = 0; + } + + if (_charging) + { + for (Entity near : wielder.getNearbyEntities(0.6, 1, 0.6)) + { + if (near instanceof LivingEntity) + { + LivingEntity entity = (LivingEntity) near; + if (!canHit(wielder, entity)) + { + continue; + } + if (entity instanceof Horse) + { + _hit.add((LivingEntity)((Horse)entity).getPassenger()); + ((Horse)entity).eject(); + } + else + { + _hit.add(entity); + } + } + } + if (!_hit.isEmpty()) + { + _charging = false; + double damagePercentage = getBuildup() / MAX_BUILDUP_TICKS; + _buildup = 0; + + wielder.getWorld().playSound(wielder.getLocation(), Sound.ZOMBIE_METAL, 1.5f, 0.5f); + for (LivingEntity hit : _hit) + { + //Damage Event + ClansManager.getInstance().getDamageManager().NewDamageEvent(hit, wielder, null, + DamageCause.CUSTOM, 2 + (10 * damagePercentage), false, true, false, + wielder.getName(), "Knight's Greatlance Charge"); + + //Velocity + UtilAction.velocity(hit, + UtilAlg.getTrajectory2d(wielder.getLocation().toVector(), hit.getLocation().toVector()), + 2.6, true, 0, 0.2, 1.4, true); + + //Condition + ClansManager.getInstance().getCondition().Factory().Falling("Knight's Greatlance Charge", hit, wielder, 10, false, true); + } + _hit.clear(); + Recharge.Instance.useForce(wielder, "Knight Lance Charge Attack", 5000); + Recharge.Instance.recharge(wielder, "Knight Lance Charge CD Inform"); + return; + } + + propelPlayer(wielder); + UtilTextBottom.displayProgress(getBuildup() / MAX_BUILDUP_TICKS, wielder); + _buildup++; + } + } + + @Override + public void onUnequip(Player wielder) + { + _charging = false; + _buildup = 0; + } + + @Override + public void onAttack(CustomDamageEvent event, Player wielder) + { + event.AddMod("Knight's Greatlance", 7); + } + + private void propelPlayer(Player player) + { + Vector direction = player.getLocation().getDirection().normalize(); + direction.setY(0); + direction.multiply(CHARGE_VELOCITY); + + player.setVelocity(direction); + + UtilParticle.PlayParticle(ParticleType.CRIT, player.getLocation(), + (float)(Math.random() - 0.5), 0.2f + (float)(Math.random() * 1), (float)(Math.random() - 0.5), 0, 3, + ViewDist.LONG, UtilServer.getPlayers()); + } + + private boolean canPropel(Player player) + { + return UtilEnt.isGrounded(player) && + !UtilEnt.isInWater(player) && + player.getVehicle() == null && + !ClansManager.getInstance().getClanUtility().isSafe(player) && + Recharge.Instance.usable(player, "Knight Lance Charge Attack", Recharge.Instance.use(player, "Knight Lance Charge CD Inform", 1500, false, false)); + } + + private boolean canHit(Player player, LivingEntity entity) + { + if (UtilEnt.hasFlag(entity, "LegendaryAbility.IgnoreMe")) + { + return false; + } + if (ClansManager.getInstance().getClanUtility().isSafe(entity.getLocation())) + { + return false; + } + if (entity instanceof Horse) + { + Entity passenger = ((Horse)entity).getPassenger(); + if (passenger == null) + { + return false; + } + else + { + if (passenger instanceof LivingEntity) + { + if (!canHit(player, (LivingEntity)passenger)) + { + return false; + } + } + else + { + return false; + } + } + } + if (entity instanceof Player) + { + Player target = (Player) entity; + if (ClansManager.getInstance().hasTimer(target)) + { + return false; + } + if (ClansManager.getInstance().isInClan(player) && ClansManager.getInstance().getClan(player).isMember(target)) + { + return false; + } + if (target.getGameMode() == GameMode.CREATIVE || target.getGameMode() == GameMode.SPECTATOR) + { + return false; + } + if (ClansManager.getInstance().getIncognitoManager().Get(target).Hidden) + { + return false; + } + if (ClansManager.getInstance().isInClan(player) && ClansManager.getInstance().getClan(player).isAlly(ClansManager.getInstance().getClan(target))) + { + return false; + } + } + + return true; + } + + private double getBuildup() + { + return UtilMath.clamp(_buildup, 0d, MAX_BUILDUP_TICKS); + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index c6e56720e..39a7bb3eb 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -844,7 +844,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter { if (!event.isCancelled()) { - SetPortalDelay(event.getOther()); + SetPortalDelay(event.getEntity()); } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index eb90eae7d..9c88b2866 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -57,6 +57,9 @@ import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetBlockEvent; +import mineplex.core.gadget.event.GadgetCollideEntityEvent; +import mineplex.core.gadget.event.GadgetSelectLocationEvent; import mineplex.core.hologram.HologramManager; import mineplex.core.incognito.events.IncognitoHidePlayerEvent; import mineplex.core.interactions.NewInteractionsManager; @@ -589,4 +592,33 @@ public class HubManager extends MiniClientPlugin implements IChatMess } } } + + public boolean isNearSpawn(Location location) + { + return UtilMath.offsetSquared(GetSpawn(), location) < 100; + } + + @EventHandler + public void gadgetLocation(GadgetSelectLocationEvent event) + { + if (isNearSpawn(event.getLocation())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void gadgetBlock(GadgetBlockEvent event) + { + event.getBlocks().removeIf(block -> isNearSpawn(block.getLocation().add(0.5, 0.5, 0.5))); + } + + @EventHandler + public void gadgetEntity(GadgetCollideEntityEvent event) + { + if (isNearSpawn(event.getEntity().getLocation())) + { + event.setCancelled(true); + } + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/world/HubWorldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/world/HubWorldManager.java index 03af80bdd..1c706d73c 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/world/HubWorldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/world/HubWorldManager.java @@ -180,6 +180,10 @@ public class HubWorldManager extends MiniPlugin event.getEntity().remove(); } } + else if (event.getCause() == DamageCause.SUFFOCATION) + { + event.setCancelled(true); + } event.setCancelled(true); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 95268f24d..18ca4d9c4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -203,6 +203,7 @@ public class Arcade extends JavaPlugin cosmeticManager.setInterfaceSlot(6); gadgetManager.setActiveItemSlot(3); cosmeticManager.disableTeamArmor(); + achievementManager.setGadgetManager(gadgetManager); CustomDataManager customDataManager = require(CustomDataManager.class); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 5520e0089..26c537065 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -1434,7 +1434,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation return; } - if (GetGame().GetState() == GameState.End || GetGame().GetState() == GameState.WinRoom) + if (GetGame().GetState() == GameState.End) { UtilPlayer.message(event.getPlayer(), F.main("Game", "The game is already ending, it cannot be ended again")); return; @@ -1679,7 +1679,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation } if (!event.GetGame().AllowParticles) + { getCosmeticManager().setHideParticles(true); + } + + if (event.GetGame().ShowWeaponNames) + { + getCosmeticManager().getGadgetManager().setShowWeaponNames(true); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StopCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StopCommand.java index e4af7ab35..799126cca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StopCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/StopCommand.java @@ -31,7 +31,7 @@ public class StopCommand extends CommandBase return; } - if (Plugin.GetGame().GetState() == GameState.End || Plugin.GetGame().GetState() == GameState.WinRoom) + if (Plugin.GetGame().GetState() == GameState.End) { UtilPlayer.message(caller, F.main("Game", "The game is already ending, it cannot be ended again")); return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 1c2035728..e70f4c7fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -145,7 +145,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed public enum GameState { - Loading, Recruit, Prepare, Live, End, WinRoom, Dead + Loading, Recruit, Prepare, Live, End, Dead } public ArcadeManager Manager; @@ -308,6 +308,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed public boolean GiveClock = true; public boolean AllowParticles = true; + public boolean ShowWeaponNames = true; public boolean Prepare = true; public long PrepareTime = 9000; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/CakeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/CakeWars.java index b19f43475..429bc928b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/CakeWars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/CakeWars.java @@ -226,7 +226,6 @@ public class CakeWars extends TeamGame case Live: writeLive(player, scoreboard); break; - case WinRoom: case End: writeEnd(player, scoreboard); default: diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/ChristmasNew.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/ChristmasNew.java index 8abdd97c5..cd4f958d2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/ChristmasNew.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmasnew/ChristmasNew.java @@ -171,7 +171,7 @@ public class ChristmasNew extends ChristmasCommon @EventHandler public void gameEndUpdate(UpdateEvent event) { - if (event.getType() != UpdateType.FAST || GetState() != GameState.End && GetState() != GameState.WinRoom || WinnerTeam == null) + if (event.getType() != UpdateType.FAST || GetState() != GameState.End || WinnerTeam == null) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNew.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNew.java index 51017493d..aaad2b287 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNew.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNew.java @@ -227,7 +227,6 @@ public abstract class SurvivalGamesNew extends Game writeLive(player, scoreboard); break; case End: - case WinRoom: writeEnd(player, scoreboard); break; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLeap.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLeap.java index 54d7574b7..30343b972 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLeap.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLeap.java @@ -124,10 +124,10 @@ public class PerkLeap extends Perk UtilPlayer.message(player, F.main("Skill", "You used " + F.skill(_name) + ".")); - player.playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0); + player.playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 8); - PerkLeapEvent leapEvent = new PerkLeapEvent(player); - UtilServer.getServer().getPluginManager().callEvent(leapEvent); + UtilServer.CallEvent(new PerkLeapEvent(player)); + Manager.getCosmeticManager().getGadgetManager().playLeapEffect(player); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java index bf344df69..9446072c6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java @@ -1,7 +1,6 @@ package nautilus.game.arcade.managers; import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.common.timing.TimingManager; @@ -13,12 +12,10 @@ import nautilus.game.arcade.GameMode; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.stats.StatTracker; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import java.lang.reflect.Array; @@ -158,8 +155,8 @@ public class GameCreationManager implements Listener Manager.GetCreature().SetDisableCustomDrops(false); Manager.GetDamage().resetConfiguration(); Manager.GetExplosion().resetConfiguration(); -// Manager.GetAntiStack().SetEnabled(true); Manager.getCosmeticManager().setHideParticles(false); + Manager.getCosmeticManager().getGadgetManager().setShowWeaponNames(false); Manager.GetDamage().GetCombatManager().setUseWeaponName(AttackReason.CustomWeaponName); ItemStackFactory.Instance.SetUseCustomNames(false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index a2069084b..10bab87ce 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -36,6 +36,7 @@ import mineplex.core.gadget.gadgets.morph.MorphWither; import mineplex.core.gadget.gadgets.mount.types.MountDragon; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; +import mineplex.core.gadget.types.WinEffectGadget; import mineplex.core.portal.GenericServer; import mineplex.core.portal.Intent; import mineplex.core.updater.UpdateType; @@ -58,7 +59,6 @@ public class GameManager implements Listener ArcadeManager Manager; private int _colorId = 0; - private int _animationIndex = 0; public GameManager(ArcadeManager manager) { @@ -339,17 +339,12 @@ public class GameManager implements Listener } else if (game.GetState() == GameState.End) { - if (UtilTime.elapsed(game.GetStateTime(), 3000)) + WinEffectGadget winEffectGadget = game.WinEffectManager.getWinEffect(); + + if (UtilTime.elapsed(game.GetStateTime(), winEffectGadget == null ? 10000 : winEffectGadget.getLength())) { - game.SetState(GameState.WinRoom); - } - } - else if (game.GetState() == GameState.WinRoom) - { - if (UtilTime.elapsed(game.GetStateTime(), 12000)) - { - game.SetState(GameState.Dead); game.WinEffectManager.end(); + game.SetState(GameState.Dead); } } } @@ -469,15 +464,13 @@ public class GameManager implements Listener @EventHandler(priority = EventPriority.HIGH) public void KitDeregister(GameStateChangeEvent event) { - if (event.GetState() != GameState.WinRoom) + if (event.GetState() != GameState.End) return; event.GetGame().DeregisterKits(); event.GetGame().deRegisterStats(); } - - @EventHandler public void ScoreboardTitle(UpdateEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/wineffect/WinEffectManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/wineffect/WinEffectManager.java index 013f2e192..e98d06c8c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/wineffect/WinEffectManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/wineffect/WinEffectManager.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.wineffect; import java.util.List; import org.bukkit.Location; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import mineplex.core.common.util.UtilEnt; @@ -12,6 +13,7 @@ import mineplex.core.gadget.gadgets.wineffect.WinEffectPodium; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.WinEffectGadget; + import nautilus.game.arcade.game.Game; public class WinEffectManager @@ -33,7 +35,7 @@ public class WinEffectManager public void playWinEffect(Location loc) { buildWinnerRoom(loc); - UtilEnt.getAllInRadius(loc, 20).keySet().stream().filter(e-> !(e instanceof Player)).forEach(e->e.remove()); + UtilEnt.getAllInRadius(loc, 20).keySet().stream().filter(e-> !(e instanceof Player)).forEach(Entity::remove); _game.CreatureAllowOverride = true; for(Player p : UtilServer.getPlayers()) { @@ -46,6 +48,12 @@ public class WinEffectManager protected void buildWinnerRoom(Location loc) { WinEffectGadget effect = getWinEffect(); + + if (effect == null) + { + return; + } + _game.WorldTimeSet = effect.getGameTime(); effect.setup(_winner, _team, _nonTeam, loc); effect.buildWinnerRoom(); @@ -53,6 +61,11 @@ public class WinEffectManager protected void playEffect() { + if (_game == null) + { + return; + } + _game.getArcadeManager().getCosmeticManager().getGadgetManager().setHideParticles(true); WinEffectGadget effect = getWinEffect(); effect.teleport(); @@ -61,7 +74,10 @@ public class WinEffectManager public void end() { - if (_game == null) return; + if (_game == null) + { + return; + } WinEffectGadget effect = getWinEffect(); effect.runFinish(); @@ -71,15 +87,25 @@ public class WinEffectManager public WinEffectGadget getWinEffect() { + if (_game == null) + { + return null; + } + GadgetManager manager = _game.getArcadeManager().getCosmeticManager().getGadgetManager(); Gadget winEffect = manager.getGadget(WinEffectPodium.class); - for (Gadget gadget : manager.getGadgets(GadgetType.WIN_EFFECT)) + + if (_winner != null) { - if (gadget.isActive(_winner)) + for (Gadget gadget : manager.getGadgets(GadgetType.WIN_EFFECT)) { - winEffect = gadget; + if (gadget.isActive(_winner)) + { + winEffect = gadget; + } } } + return (WinEffectGadget) winEffect; }