diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java index 3e4c49575..55d6fd4ab 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java @@ -65,6 +65,8 @@ public class SkinData public final static SkinData GINGERBREAD = new SkinData("eyJ0aW1lc3RhbXAiOjE0ODAxOTk5MjM0NTUsInByb2ZpbGVJZCI6IjRjOGQ1NjllZWZlMTRkOGE4YzJmMmM4ODA3ODA3ODRmIiwicHJvZmlsZU5hbWUiOiJHaW5nZXJicmVhZE1hbiIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzAyM2IxZGQ5MWQyYjM2Y2FkZTU2NjVjM2Y3ODk3ZmNiOGRlMWFlNjE5YTRlOTYxODU2MzdiMTliZGNmZjQ3In19fQ==", "lND5lQCzd5DKdn+ps82zn55hrSDr12bBLFoSbxetOj7MaYAuHCkJPQQOXdcMh3TLLSgxmQzEWkIHSUo760/2Qfd2uDDOTVfZZqiFjiOwDQ7YQjkokqNaC3U9gEq+LBJ+IgEkwaCsluXYMIK0Wvqx1DFa82pg8bSYGczJfTw/1kQsUUTpmao6ChZw3yrHTPow38onD95f9i6yVcnhSpPfM/JTQuL4N6Jdcql6VRJNSvCHJvEgh6R2p0w7DJhEGIzkFaF3lPdBqw+Mm97fBPvznscd4s6gpH07gUl/T+vlyHyRBLm85Pgm70r4MQ+c/nGOQOXzFMNpO8RIot/uhd7t3bvSi6yFzZQm7P9QLCLm/0C84x0sCugjeN/hVA347FWnuRPcya5xPzlpTWAW7pCjheAz0mvnPUMYT6Wp4CJx6bPdePnaiLFSeK8EyQIU9IUQJgXqMA3cOwqMBdh/0r71fTInPdgXsVxabmGbCgIuK3A2hSgxpcZv9412T0NIJYSTi0s2B3dyAaZJrdF5wa1hIr8au63SWFJww3GEEOF5YObEyVvKj2yS40iaHaRrfn1DeALT0eD0oN1zzK66FKbFuDmZmm4Thel9gKt+QcnR2uHlFLEBUogpIXyeC8zca7SOppANloOpO4mBbf22dXBJogenVd425JWaXOHJ6NVqIBw="); public final static SkinData LOVE_DOCTOR = new SkinData("eyJ0aW1lc3RhbXAiOjE0ODQ0MzM1MjQxMjAsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9iY2RiZTM2OTM1NGZjMzUxY2RhNGRmY2Y2OWM0MzY3ODcwYjI4ZWE3NDUzYWVjM2IzMjgyM2YyMWMzNTJlNTUifX19", "KD0NsKFlS+9/JpPQdT0Lq2jo942WeHpFevJPR3T9JO/5NVmNprupsWuTgepw14iHoax8/xyP8S4XksYq8hJ30e+gRKXVReqtq4l8JetXJILI7JTL6EHj/Flg4t0O6ASIm3Hr+w86IKrPb0NwHTjHJHvbf0r7k3E/TMLbq0/c7Xgi+JgC0uQd+wIPZhQe92P3O7eGH858X0vsxG0FVzgnEAlHVLmqBCwqxMU5CsBp0JCTVIbtp+JNmveCsfLagP6mi39rUudbueXJQgqLv7H7Zw+ZNINLLaKPNVO6Od8sX3c+CSUQ+Bm9bakYr628k/z0krTdNpLG7OGXWoT3XShW6HXB/z7o7hpuDXJW7HdyvmWv9GVyWLm2USNe7/3Ugs2zWZI1f+t6t+V3EVr3T+nR4zpY/ISdlTsLtV/Daebr0v/V0YlaM0UaASzz16ob3p1cfao7C7BZwKqOBKoSyHpnuLhd70wOtNrhhPDU9dWQBC/l6uojcMJ9lQMsxFmHj4JFqJYl7p/UXnq1vnYBo1P3A//IGl4gL1Hv8U0I14LT77/AMYH57mItgD0/VnE4bvPIFML/4cX7L9qpdLoOAAyfa5P9cAfzhUnVnRRLM016MpGtvY8SfbZ68Of1Xjz/dZ9/fBEcObXPHGX2QNuJRFiWJjRVKjO7ok0qfiVUEmuZr6I="); public final static SkinData LEPRECHAUN = new SkinData("eyJ0aW1lc3RhbXAiOjE0ODc4NzI5Mjg1ODIsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS80ZTBkZjZhZGNiNzkzMzM5ZjFhOGNkM2E0ZGQ2ZThjNGQ2ZWFjYmU5NWMzZDA5OTI4NDMyMWFiZGI5MTgwOSJ9fX0=", "cyIYHTdzvVBOyYoiJZTvNS8Et5pzqBNxuz6GQspE2lBkW2Bj82JNv5oczsf3oxYAG4zxdb96G8+7UKBmoJdvx0x6UD7Dk0dnKrwpXfOhe+jRxtwMGMsdYCb8URWaoIoeKpxdCmAtjgV6FI8zDy2Yzi+MF4O9e4VqH0tMBoD2/CZScQwNEzc4YXf2M2fglKn9uK2+xrgLV+XS+SNdIn7BRiNlQf96u6N2G0lO+eb09LbIfIgAgfnyLiARccWa+VNo6gwlCFyRMnwOlgqxL5XA5Um4kkx2ZReRRCDFQ4NV5eLBktLd5wpECyOuY7v7S3zLqwbhwG47gS8hnXqmtHG5RW0RUQZEryg638Cw7hwr2k09iStfok8WeZUIJ+fuUWgdArvbtN36a2pCXyFdqzp+E8xzSF4E9SQv0K+1lNj+w4L58dh8pddeKK8m5bpjINj4xZ6nf7reWYQAX/imVNYTXTW8JqYnF+++xViBwmfeeM3PmEg+wyTduh+M25nyhGcqn5l+UyQ9aMzzdNs2aEdx12fOm1sOFXjHrHWeo6ciEm7sY1SDjiJ99VVXuGHCJWBtxq/B+c+vC/Cj8itEYOetwe5NKrgI99pZjG+KiRr4L0n8/NA3Px7SbKUUpHse80pNMjGfFW4pAOyFXJaKHrObWT2iL2AnTe+yfdY4sf/JZT4="); + public final static SkinData BUGS_BUNNY = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTA0NzE5MDU2MTgsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS84MmUyMjRkMGJkZGJmNjRiODIzMmUxNWRhNGRkN2NjN2NiYTYzM2NiODkyMTFhYjVjNDRhODU0ZjM1NDhlZWRiIn19fQ==", "QtM7YGNpqGcTnlUCTtQsQIEc8VGvL8cxWzAvN4LjYZrY4Fv15ysEVSPWPmRL/FJTRyUFCrJFO/0miVbuIEsGyUnsgHJAr9qkeyMvfD3+pZtKU1FkS58VNQkL/YaPDms7XPy1BPNo+ynQnVevdVCNDOvs2244Px3UljtuReBteKqL8QGMR1K6FFCQuKKvcvYsljdM8RV91r2yuT9UDxnzMRghWyRZuthvCeGL85g1LQxCnzJ0NUqIqCDrTWa8jeuncLnmRooKZYGsQjCAVOSFRk4KytD+fv8xgNK2igqBgVcqAINl5IjrFt7yyPQ2FVBbshETsjewusa6eZSBoy1Lc17G7bcndoOdwGMuztLjHPMzxFpIV1RkbZrngjcSTE/IQdSw79NlzMOEMKjE/34M7xcSnSZA1xwW33g+/xq+pNbqcXu85e7VXkziWDhHREp9ITT4YjrVdrss1yfYBzZgRmmLyaMpVmVsecKB9adpuZkhGzKIVrQHDGYEHoqoRnsRGJREdZQPxaSWp4+DSxpV/0oJXJWDz+XFztbcVbBcjBOD9kpFP0s+R5t1WA2B+jsf9J3LdsUUDbBiWikBwbAXKhHxTWWKv6OZLZovhgvGnW2lXQsHglEKuD7jE/mnFj4SF2qRO2N37AUjaG8AGQtTVhxW5JneIiBA0dbKIk06yoY="); + public final static SkinData SLENDERMAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTA0NzUyNzk4NTUsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9hMWNkOTI5OTFmYTRjZGQ2MGVlZDNhZTM3ZmI5NWRmZjFkNWNkOGNiZmYwYWFjMzE4MmQ0ODU2NDU5NTIzYyJ9fX0=", "OVqWFLCekyZcdGli6kPBKNh8/VYPhKZGNqlAvSOKc3RLgh4pIkI6TDPr/Y+VQdhz1wZozARFYSeoDJJJ4nZTi7gi3rVPG2rL1ZnKo7so5hdT8caEzSTRmgwPKzo03ZhEEsW9AEJo9mpiUxGSJdBlgEb9UgodpYFW1IjRC09CcBUqzRWP8QGZTSFSN5x9emQ97DyiFmt0NFWubHCKHdb7CExhchPRtbahL3hOEzPY8/Y+Irl9OZjx7jONE7O/sYItCuZoXc3FaTgCV0riiXHCgH2eA54s5TQVWumtp3FU7VIcKR6pm/o61+GusvqhNgdFNk9XSHWMUyp+HNU0R8sConZQN/eaVx9laJmUUb4zNZ7hX/hLYV+r9LFU1NXOeIZWJPShD+bYfZgEorIpD+EAL4BHht/f5e6a1IZUDBWb001PFibby2t9WWjoDVKz4McbxZ2Xui7EHKFG1K3biPibhWx6fvnOeJ2xW6UDIZcD+TCXwlW/knkFt44Xpyv3oNHk3UNkyrQgghd6qkc3gZHxP8PQCNvKIyK1I+pHR6JMZvSStp7ZQRDpvsvIUyOJvq+7Bs7lFYs8hcJHMzEB+8PYlH2k7P7iLuA6ZYFUmvOW1LLq0+hvxK96ZdNEsJdmMkVVTZBRw7vsZ4GPbkdp2cMOFH2lHcQj80xKqVbd43IqFDA="); // Comments this out for now, so it doesn't load the player profile // A better way to do this would check for the properties when getting the skull or the skin diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java index 49da7d9cf..4240b9a9b 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java @@ -57,6 +57,11 @@ public class F { return C.mElem + elem + C.mBody; } + + public static String count(int elem) + { + return count(String.valueOf(elem)); + } public static String count(String elem) { diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java index 6a43363de..91c93c620 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java @@ -7,6 +7,16 @@ import java.util.HashSet; import java.util.Set; import java.util.UUID; +import net.minecraft.server.v1_8_R3.BlockPosition; +import net.minecraft.server.v1_8_R3.Blocks; +import net.minecraft.server.v1_8_R3.IBlockData; +import net.minecraft.server.v1_8_R3.Item; +import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.MinecraftKey; +import net.minecraft.server.v1_8_R3.NBTTagCompound; +import net.minecraft.server.v1_8_R3.TileEntityFlowerPot; +import net.minecraft.server.v1_8_R3.WorldServer; + import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.SkullType; @@ -35,15 +45,6 @@ import com.mojang.authlib.GameProfile; import mineplex.core.common.Pair; import mineplex.core.common.block.MultiBlockUpdaterAgent; import mineplex.core.common.skin.SkinData; -import net.minecraft.server.v1_8_R3.BlockPosition; -import net.minecraft.server.v1_8_R3.Blocks; -import net.minecraft.server.v1_8_R3.IBlockData; -import net.minecraft.server.v1_8_R3.Item; -import net.minecraft.server.v1_8_R3.MathHelper; -import net.minecraft.server.v1_8_R3.MinecraftKey; -import net.minecraft.server.v1_8_R3.NBTTagCompound; -import net.minecraft.server.v1_8_R3.TileEntityFlowerPot; -import net.minecraft.server.v1_8_R3.WorldServer; public class UtilBlock { @@ -394,7 +395,17 @@ public class UtilBlock { return blockUseSet.contains(block); } - + + public static Set getBlocksInRadius(Location loc, double radius) + { + return getInRadius(loc, radius).keySet(); + } + + public static Set getBlocksInRadius(Location loc, double radius, int maxHeight) + { + return getInRadius(loc, radius, maxHeight).keySet(); + } + public static HashMap getInRadius(Location loc, double dR) { return getInRadius(loc, dR, 9999); diff --git a/Plugins/Mineplex.Core/pom.xml b/Plugins/Mineplex.Core/pom.xml index afbd561ec..a59a05b9b 100644 --- a/Plugins/Mineplex.Core/pom.xml +++ b/Plugins/Mineplex.Core/pom.xml @@ -43,7 +43,7 @@ com.mineplex anticheat - 1.3 + 1.5 org.tukaani diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 745df2fee..419b8b977 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -56,6 +56,13 @@ public enum Achievement "during Thanksgiving 2016!"}, new int[]{200}, AchievementCategory.HOLIDAY), + + GLOBAL_EGG_HUNTER_2017("2017 Egg Hunter", 4000, + new String[]{"Global.Easter Eggs 2017"}, + new String[]{"Find 200 Easter Egg Baskets,", + "during Easter 2017"}, + new int[]{200}, + AchievementCategory.HOLIDAY), //Bridges BRIDGES_WINS("Bridge Champion", 600, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 22cfcc59d..37805a3be 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -209,7 +209,7 @@ public enum AchievementCategory StatDisplay.fromGame("Wins", GameDisplay.SkyfallTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SkyfallTeams, "Wins", "Losses"), StatDisplay.fromGame("Kills", GameDisplay.SkyfallTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SkyfallTeams, "Deaths"), StatDisplay.fromGame("Gems Earned", GameDisplay.SkyfallTeams, "GemsEarned"), null, StatDisplay.fromGame("Booster Rings", GameDisplay.SkyfallTeams, "Rings")}, - Material.BOW, 0, GameCategory.SURVIVAL, null, false, GameDisplay.Skyfall.getGameId(), GameDisplay.SkyfallTeams.getGameId()); + Material.DIAMOND_BOOTS, 0, GameCategory.SURVIVAL, null, false, GameDisplay.Skyfall.getGameId(), GameDisplay.SkyfallTeams.getGameId()); private String _name; private String[] _statsToPull; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java index 1c2ac0f69..0be8e250e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java @@ -208,9 +208,6 @@ public class AchievementManager extends MiniPlugin return level; } - if (sender.getName().equalsIgnoreCase("B2_mp")) - return 101; - if (rank.has(Rank.MODERATOR)) level = Math.max(level, 5); if (rank.has(Rank.SNR_MODERATOR)) @@ -221,9 +218,6 @@ public class AchievementManager extends MiniPlugin level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel()); if (rank.has(Rank.OWNER)) level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel()); - - if (sender.getName().equalsIgnoreCase("Phinary")) - level = 0; return level; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 96af06514..b59982c6f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -1,5 +1,6 @@ package mineplex.core.antihack; +import javax.xml.bind.DatatypeConverter; import java.util.Collections; import java.util.HashSet; import java.util.Map; @@ -9,7 +10,11 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; -import javax.xml.bind.DatatypeConverter; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -43,6 +48,7 @@ import com.mineplex.anticheat.checks.combat.KillauraTypeF; import com.mineplex.anticheat.checks.move.Glide; import com.mineplex.anticheat.checks.move.HeadRoll; import com.mineplex.anticheat.checks.move.Speed; +import com.mineplex.anticheat.checks.move.Toggle; import com.mineplex.anticheat.checks.player.BadPackets; import mineplex.core.MiniPlugin; @@ -76,37 +82,34 @@ import mineplex.core.punish.Category; import mineplex.core.punish.Punish; import mineplex.core.punish.PunishmentResponse; import mineplex.serverdata.commands.ServerCommandManager; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; @ReflectivelyCreateMiniPlugin public class AntiHack extends MiniPlugin { private static final Map, CheckThresholds> CHECKS = ImmutableMap., CheckThresholds>builder() - .put(KillauraTypeA.class, new CheckThresholds("Kill Aura", 0, 25, 50)) + .put(KillauraTypeA.class, new CheckThresholds("Kill Aura", 25, 45, 60)) .put(KillauraTypeB.class, new CheckThresholds("High CPS", 0, 0, Integer.MAX_VALUE)) - .put(KillauraTypeC.class, new CheckThresholds("Reach", 0, Integer.MAX_VALUE, Integer.MAX_VALUE)) + .put(KillauraTypeC.class, new CheckThresholds("Reach", 25, Integer.MAX_VALUE, Integer.MAX_VALUE)) .put(KillauraTypeD.class, new CheckThresholds("Kill Aura", 500, 1000, 1500)) - .put(KillauraTypeE.class, new CheckThresholds("Kill Aura", 300, 700, 2000)) - .put(KillauraTypeF.class, new CheckThresholds("Kill Aura", 150, 250, 350)) + .put(KillauraTypeE.class, new CheckThresholds("Kill Aura", 1000, 2000, 5000)) + .put(KillauraTypeF.class, new CheckThresholds("Kill Aura", 200, 300, 400)) .put(BadPackets.class, new CheckThresholds("Regen", 500, 1000, 2000)) - .put(Glide.class, new CheckThresholds("Flying", 150, 250, 500)) - .put(Speed.class, new CheckThresholds("Speed", 150, 250, 500)) - .put(HeadRoll.class, new CheckThresholds("Illegal Movement", 0, 0, 0)) + .put(Glide.class, new CheckThresholds("Flying", 1000, 2000, 3500)) + .put(Speed.class, new CheckThresholds("Speed", 1000, 2000, 3500)) + .put(HeadRoll.class, new CheckThresholds("Illegal Movement", 0, 0, 1000)) + .put(Toggle.class, new CheckThresholds("AutoSneak", 100, 200, 300)) .build(); - private static final CheckThresholds NOOP_THRESHOLD = new CheckThresholds("Unknown", 0, Integer.MAX_VALUE, Integer.MAX_VALUE); + private static final CheckThresholds NOOP_THRESHOLD = new CheckThresholds("Unknown", Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); private static final Map, AntiHackAction> ACTIONS = ImmutableMap., AntiHackAction>builder() .put(KillauraTypeA.class, new ImmediateBanAction(200)) .put(KillauraTypeD.class, new BanwaveAction(1500)) + .put(KillauraTypeF.class, new BanwaveAction(600)) .put(Glide.class, new ImmediateBanAction(10000)) .put(Speed.class, new ImmediateBanAction(10000)) -// .put(HeadRoll.class, new ImmediateBanAction(200)) - .put(HeadRoll.class, new GEPBanAction(1)) + .put(HeadRoll.class, new ImmediateBanAction(2000)) + .put(Toggle.class, new ImmediateBanAction(500)) .put(BadPackets.class, new GEPBanAction(300)) .put(KillauraTypeB.class, new GEPBanAction(100)) .build(); @@ -368,26 +371,23 @@ public class AntiHack extends MiniPlugin ACTIONS.getOrDefault(event.getCheckClass(), NOOP_ACTION).handle(event); - if (event.shouldTellStaff()) + CheckThresholds thresholds = CHECKS.getOrDefault(event.getCheckClass(), NOOP_THRESHOLD); + CheckThresholds.Severity severity = thresholds.getSeverity(event.getViolations()); + + if (severity == CheckThresholds.Severity.NONE) { - CheckThresholds thresholds = CHECKS.getOrDefault(event.getCheckClass(), NOOP_THRESHOLD); - CheckThresholds.Severity severity = thresholds.getSeverity(event.getViolations()); + return; + } - if (severity == CheckThresholds.Severity.NONE) - { - return; - } + String key = event.getPlayer().getName() + "." + event.getHackType() + "." + severity.toString(); - String key = event.getPlayer().getName() + "." + event.getHackType() + "." + severity.toString(); + Integer pastVl = this._cooldown.getIfPresent(key); + if (pastVl == null) + { + MajorViolationCommand command = new MajorViolationCommand(_thisServer, event.getPlayer().getName(), CheckManager.getCheckSimpleName(event.getCheckClass()), event.getViolations(), event.getMessage()); + ServerCommandManager.getInstance().publishCommand(command); - Integer pastVl = this._cooldown.getIfPresent(key); - if (pastVl == null) - { - MajorViolationCommand command = new MajorViolationCommand(_thisServer, event.getPlayer().getName(), CheckManager.getCheckSimpleName(event.getCheckClass()), event.getViolations(), event.getMessage()); - ServerCommandManager.getInstance().publishCommand(command); - - this._cooldown.put(key, event.getViolations()); - } + this._cooldown.put(key, event.getViolations()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/MineplexLinkImpl.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/MineplexLinkImpl.java index 6195a3fd2..4294d1988 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/MineplexLinkImpl.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/MineplexLinkImpl.java @@ -1,14 +1,20 @@ package mineplex.core.antihack; import net.minecraft.server.v1_8_R3.MinecraftServer; +import net.minecraft.server.v1_8_R3.MobEffect; +import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import org.bukkit.plugin.RegisteredServiceProvider; +import org.bukkit.potion.PotionEffectType; import com.mineplex.anticheat.api.MineplexLink; import mineplex.core.Managers; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.disguises.DisguiseBase; @@ -17,6 +23,8 @@ public class MineplexLinkImpl implements MineplexLink { private final DisguiseManager _disguiseManager = Managers.require(DisguiseManager.class); + private final RegisteredServiceProvider _relationProvider = Bukkit.getServicesManager().getRegistration(RelationProvider.class); + @Override public EntityType getActiveDisguise(Player player) { @@ -47,4 +55,29 @@ public class MineplexLinkImpl implements MineplexLink { return ((CraftPlayer) player).getHandle().bS(); // See Anticheat javadoc } + + @Override + public int allocateNewEntityID() + { + return UtilEnt.getNewEntityId(); + } + + @Override + public boolean isUsingElytra(Player player) + { + return ((CraftPlayer) player).getHandle().isGliding(); + } + + @Override + public int getLevitationAmplifier(Player player) + { + MobEffect effect = ((CraftPlayer) player).getHandle().effects.get(PotionEffectType.LEVITATION.getId()); + return effect == null ? -1 : effect.getAmplifier(); + } + + @Override + public boolean canDamage(Player attacker, Entity target) + { + return _relationProvider != null && _relationProvider.getProvider().canDamage(attacker, target); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/RelationProvider.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/RelationProvider.java new file mode 100644 index 000000000..0a4b741d1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/RelationProvider.java @@ -0,0 +1,9 @@ +package mineplex.core.antihack; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +public interface RelationProvider +{ + boolean canDamage(Player player, Entity target); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/BanwaveAction.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/BanwaveAction.java index 694c75488..6840ec600 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/BanwaveAction.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/actions/BanwaveAction.java @@ -1,5 +1,7 @@ package mineplex.core.antihack.actions; +import java.util.concurrent.TimeUnit; + import com.mineplex.anticheat.api.PlayerViolationEvent; import mineplex.core.Managers; @@ -10,8 +12,8 @@ import mineplex.core.common.util.UtilServer; public class BanwaveAction extends AntiHackAction { - private static final int BAN_DELAY_AVERAGE = 6 * 60 * 60 * 1000; // 6 hours - private static final int BAN_DELAY_VARIANCE_SPAN = 4 * 60 * 60 * 1000; // 4 hours total; 2 on either side + private static final int BAN_DELAY_MINIMUM_MINUTES = 30; + private static final int BAN_DELAY_MAXIMUM_MINUTES = (int) TimeUnit.MINUTES.convert(2, TimeUnit.HOURS); public BanwaveAction(int vl) { @@ -28,8 +30,9 @@ public class BanwaveAction extends AntiHackAction } if (event.getViolations() >= this.getMinVl()) { - // Delay bans by 6 hours +/- 2 hours for fuzzing - long banTime = System.currentTimeMillis() + BAN_DELAY_AVERAGE + (UtilMath.r(BAN_DELAY_VARIANCE_SPAN) - (BAN_DELAY_VARIANCE_SPAN / 2)); + // Delay bans by 1.25 hours +/- .75 hours for fuzzing + long banDelayMinutes = UtilMath.r(BAN_DELAY_MAXIMUM_MINUTES - BAN_DELAY_MINIMUM_MINUTES) + BAN_DELAY_MINIMUM_MINUTES; + long banTime = System.currentTimeMillis() + TimeUnit.MILLISECONDS.convert(banDelayMinutes, TimeUnit.MINUTES); Managers.get(BanWaveManager.class).insertBanWaveInfo( event.getPlayer(), banTime, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/arcadeevents/CoreGameStartEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/arcadeevents/CoreGameStartEvent.java new file mode 100644 index 000000000..2a6fd4fc6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/arcadeevents/CoreGameStartEvent.java @@ -0,0 +1,43 @@ +package mineplex.core.arcadeevents; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import mineplex.core.game.GameDisplay; + +/** + * This event is called when a game starts in arcade + * It's called inside Arcade and handled inside Core, + * so we can track game events in core + */ +public class CoreGameStartEvent extends Event +{ + + private static final HandlerList handlers = new HandlerList(); + + private GameDisplay _gameDisplay; + + /** + * @param gameDisplay the type of the game + */ + public CoreGameStartEvent(GameDisplay gameDisplay) + { + _gameDisplay = gameDisplay; + } + + public GameDisplay getGameDisplay() + { + return _gameDisplay; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/arcadeevents/CoreGameStopEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/arcadeevents/CoreGameStopEvent.java new file mode 100644 index 000000000..6c4729ca5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/arcadeevents/CoreGameStopEvent.java @@ -0,0 +1,43 @@ +package mineplex.core.arcadeevents; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import mineplex.core.game.GameDisplay; + +/** + * This event is called when a game stops in arcade + * It's called inside Arcade and handled inside Core, + * so we can track game events in core + */ +public class CoreGameStopEvent extends Event +{ + + private static final HandlerList handlers = new HandlerList(); + + private GameDisplay _gameDisplay; + + /** + * @param gameDisplay the type of the game + */ + public CoreGameStopEvent(GameDisplay gameDisplay) + { + _gameDisplay = gameDisplay; + } + + public GameDisplay getGameDisplay() + { + return _gameDisplay; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + +} 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 9c0138469..7a47b9aa2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/CosmeticShop.java @@ -1,17 +1,19 @@ package mineplex.core.cosmetic.ui; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +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.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; import mineplex.core.shop.page.ShopPageBase; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.plugin.messaging.PluginMessageListener; public class CosmeticShop extends ShopBase implements PluginMessageListener { @@ -43,6 +45,16 @@ 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/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index 713429dc6..3d8aedbb7 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 @@ -180,6 +180,11 @@ public class GadgetPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in St Patrick's Chests"); } + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -19) + { + itemLore.add(C.cBlack); + itemLore.add(C.cBlue + "Found in Spring Chests"); + } //Rank Unlocks else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -10) 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 3152a8fd0..37d7190f4 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 @@ -6,7 +6,7 @@ import java.util.List; import java.util.Map; import org.bukkit.Material; -import org.bukkit.entity.Creature; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; @@ -142,7 +142,7 @@ public class Menu extends ShopPageBase petMax++; } - Creature petActive = getPlugin().getPetManager().getPet(getPlayer()); + Entity petActive = getPlugin().getPetManager().getPet(getPlayer()); GadgetType type = GadgetType.PARTICLE; String[] lore = getLore(ownedCount.get(type), maxCount.get(type), "Show everyone how cool you are with swirly particles that follow you when you walk!", VISIBILITY_EVERYWHERE, enabled.get(type)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java index f7b831eca..e7bf684cb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java @@ -21,7 +21,6 @@ import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -40,7 +39,6 @@ import mineplex.core.cosmetic.ui.button.deactivate.DeactivatePetButton; import mineplex.core.donation.DonationManager; import mineplex.core.pet.PetExtra; import mineplex.core.pet.PetType; -import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.AnvilContainer; import mineplex.core.shop.page.ShopPageBase; @@ -63,7 +61,7 @@ public class PetPage extends ShopPageBase for (PetType pet : pets) { - List itemLore = new ArrayList(); + List itemLore = new ArrayList<>(); itemLore.add(C.cBlack); if (pet.getLore().isPresent()) @@ -118,6 +116,11 @@ public class PetPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in St Patrick's Chests"); } + else if (pet.getPrice() == -19) + { + itemLore.add(C.cBlack); + itemLore.add(C.cBlue + "Found in Spring Chests"); + } else if (pet.getPrice() == -14) { itemLore.add(C.cBlack); @@ -254,14 +257,14 @@ public class PetPage extends ShopPageBase slot++; } + + // Custom pet + /*addButton(50, new ShopItem(Material.GLASS, C.cGreen + "Custom", new String[]{}, 1, false), (player, clickType) -> + getShop().openPageForPlayer(getPlayer(), new CustomPetBasePage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Custom Pet", player)));*/ + - addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() - { - public void onClick(Player player, ClickType clickType) - { - getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); - } - }); + 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))); } public void purchasePet(final Player player, final PetType petType) 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 new file mode 100644 index 000000000..7a090129e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/ActivateCustomPetButton.java @@ -0,0 +1,25 @@ +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 new file mode 100644 index 000000000..8b52b34a8 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/CustomPetBasePage.java @@ -0,0 +1,62 @@ +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 new file mode 100644 index 000000000..965a1d6ef --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/CustomPetConfirmPage.java @@ -0,0 +1,59 @@ +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 new file mode 100644 index 000000000..70feb8529 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/age/CustomPetAgePage.java @@ -0,0 +1,61 @@ +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 new file mode 100644 index 000000000..edfc55ece --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/equipment/CustomPetBootsPage.java @@ -0,0 +1,89 @@ +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 new file mode 100644 index 000000000..d9da369f4 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/equipment/CustomPetChestplatePage.java @@ -0,0 +1,88 @@ +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 new file mode 100644 index 000000000..dc90f4c9c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/equipment/CustomPetHelmetPage.java @@ -0,0 +1,88 @@ +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 new file mode 100644 index 000000000..eaa0fdf9a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/equipment/CustomPetLeggingsPage.java @@ -0,0 +1,88 @@ +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 new file mode 100644 index 000000000..d2bef0f22 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CloseCustomPetButton.java @@ -0,0 +1,16 @@ +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 new file mode 100644 index 000000000..60d71a10d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetNamePage.java @@ -0,0 +1,63 @@ +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 new file mode 100644 index 000000000..774ecf2d0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/CustomPetTagPage.java @@ -0,0 +1,95 @@ +package mineplex.core.cosmetic.ui.page.custompet.name; + +import net.minecraft.server.v1_8_R3.ItemStack; +import net.minecraft.server.v1_8_R3.Items; + +import org.bukkit.ChatColor; +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 new file mode 100644 index 000000000..c934f7648 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/name/SelectCustomPetTagButton.java @@ -0,0 +1,21 @@ +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 new file mode 100644 index 000000000..70f017744 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/custompet/zombie/CustomPetZombieTypePage.java @@ -0,0 +1,61 @@ +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/disguise/playerdisguise/DisguiseCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java index ac7443d69..e0c544659 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java @@ -1,5 +1,7 @@ package mineplex.core.disguise.playerdisguise; +import java.util.UUID; + import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; @@ -17,11 +19,14 @@ public class DisguiseCommand extends CommandBase implemen @Override public void Execute(final Player caller, final String[] args) { + String realName = Plugin.getRealName(caller); + String currentName = caller.getName(); + UUID currentUUID = caller.getUniqueId(); if (args == null || args.length == 0) { Plugin.runAsync(() -> { - new PlayerDisguiseNotification(Plugin.getRealName(caller), caller.getUniqueId(), caller.getName()).publish(); + new PlayerDisguiseNotification(realName, currentUUID, currentName).publish(); }); Plugin.undisguise(caller); return; @@ -34,7 +39,7 @@ public class DisguiseCommand extends CommandBase implemen Plugin.runAsync(() -> { - new PlayerDisguiseNotification(Plugin.getRealName(caller), caller.getUniqueId(), args[0], args.length > 1 ? args[1] : args[0]).publish(); + new PlayerDisguiseNotification(realName, currentUUID, args[0], args.length > 1 ? args[1] : args[0]).publish(); }); Plugin.disguise(caller, args[0], args.length > 1 ? args[1] : args[0]); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java index caf2b5b1d..a650df7ec 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java @@ -1,7 +1,36 @@ package mineplex.core.disguise.playerdisguise; +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.Collections; +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 java.util.function.Consumer; + +import net.minecraft.server.v1_8_R3.MinecraftServer; +import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; +import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; +import net.minecraft.server.v1_8_R3.PlayerList; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import com.google.common.collect.ImmutableSet; import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.properties.Property; + import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClient; @@ -33,33 +62,60 @@ import mineplex.serverdata.Region; import mineplex.serverdata.data.PlayerStatus; import mineplex.serverdata.redis.RedisDataRepository; import mineplex.serverdata.servers.ServerManager; -import net.minecraft.server.v1_8_R3.MinecraftServer; -import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; -import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; -import net.minecraft.server.v1_8_R3.PlayerList; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import java.lang.reflect.Field; -import java.util.Collections; -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 java.util.function.Consumer; @ReflectivelyCreateMiniPlugin public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler { + private static final Set MOJANG; + private static final Set ILLEGAL_USERNAMES; + private static final Set ILLEGAL_CAPES; + + private static final Set VERY_SPECIAL_PEOPLE; + + static + { + MOJANG = ImmutableSet.copyOf(Arrays.asList("____fox____", "_tommo_", "aeplh", "amir343", "angryem", "ashrafi", + "binni", "blurpi", "bopogamel", "c418", "carlmanneh", "carnalizer", "darngeek", "dinnerbone", "eldrone", + "elevenen", "engst", "excitedze", "frukthamster", "geuder", "grumm", "hampus", "helloiammarsh", "hey", + "hoodad", "jeb_", "jonkagstrom", "kappe", "klumpig", "krisjelbring", "ladyagnes", "lisa", "mahuldur", + "mansolson", "marc", "marc_irl", "masseffect", "midnightenforcer", "minecraftchick", "modhelius", + "mojangjonas", "mojangsta", "mollstam", "neonmaster", "notch", "olle", "olofcarlson", "phreakholm", + "poipoichen", "pretto", "profmobius", "razzleberryfox", "searge", "searge_dp", "shoghicp", "slicedlime", + "sockerpappan", "themogminer", "vaktis", "vubui", "xlson", "xsson", "yoloswag4lyfe", "zeeraw") + ); + + ILLEGAL_USERNAMES = ImmutableSet.copyOf(Arrays.asList("hypixel", "chiss", "dctr", "blondebug", "dooskee", + "tomcallister", "jessiemarcia", "spu_", "sp614x", "deadmau5", "gwen", "mineplex", "samczsun", "sethbling", + "xisuma", "cubehamster", "natet_bird", "qwertyuiopthepie" + )); + + VERY_SPECIAL_PEOPLE = ImmutableSet.copyOf(Arrays.asList( + "5399b615-3440-4c66-939d-ab1375952ac3", // Drullkus (Prismarine Cape) + "7f0eda55-7034-4dc8-886d-d94321cdedcf", // MrMessiah (Personal Cape) + "d90b68bc-8172-4329-a047-f1186dcd4336", // akronman1 (Millionth Customer) + "144ad5f0-e879-4141-a489-8ed5d496cab9", // JulianClark (Personal Cape) + "1c063715-395b-4db9-bc2a-d5dfd20366f7", // dannyBstyle (Personal Cape) + "5797c479-ad5a-43b0-87ca-8852d65ac639" // cheapsh0t (Personal Cape) + )); + + ILLEGAL_CAPES = ImmutableSet.copyOf(Arrays.asList( + "http://textures.minecraft.net/texture/eec3cabfaeed5dafe61c6546297e853a547c39ec238d7c44bf4eb4a49dc1f2c0", // Mojang + "http://textures.minecraft.net/texture/43a51d34b076f9ada555dca562206bd942e46a3c4d5f83c2c29e5b9c3d7dbcb", // Realms + "http://textures.minecraft.net/texture/2ffda25cf1a4ed8996b767c8d16d450ba22fee7b5e416299f88a65ec5a", // Translator + "http://textures.minecraft.net/texture/f8b55ca322e64a381b6484dac2d8aa42c78c6129336ea3ef4596f1d31b27ef", // Mojira Mod + "http://textures.minecraft.net/texture/1672c9f13ece9c4f39a96fe22638ecd513fbe7099ca4354d3176d3793d8e9c7", // Cobalt + "http://textures.minecraft.net/texture/86e841dcb6465d1f95a56270243d23c596da4721acd9ca2d95927b1b8535dc54", // Scrolls + "http://textures.minecraft.net/texture/c9c058adf4a2526aa5493cf6fe37f5dbdfde7b3d4fe4df982b7bee8329e64bd", // Translator (Chinese) + "http://textures.minecraft.net/texture/eec3cabfaeed5dafe61c6546297e853a547c39ec238d7c44bf4eb4a49dc1f2c0", // Mojang (Old) + "http://textures.minecraft.net/texture/2897938eb320cfd8eed6fd75d42db7a9f8e2e4a3c8da1c91f6f8e1ff18c5f4", // cheapsh0t + "http://textures.minecraft.net/texture/1658fd5989db3caffdeae2a5a70b2d0a531a7fae7401e7caef7645bccf3c", // dannyBstyle + "http://textures.minecraft.net/texture/3d991748ae6e1cfe10f34d532748b1911b1e82b5a110ae89c34f9a2295902e", // JulianClark + "http://textures.minecraft.net/texture/ec80a225b145c812a6ef1ca29af0f3ebf02163874d1a66e53bac99965225e0", // Millionth Customer + "http://textures.minecraft.net/texture/b8ff4a34df87fc7d8bf1bb77bd88ac34d16c3ff52985c128e71dbc3ccd19a028" // MrMessiah + // "//textures.minecraft.net/texture/?", // Drullkus?? + )); + } + public static final String ORIGINAL_UUID_KEY = "originalUUID"; private CoreClientManager _clients = require(CoreClientManager.class); @@ -161,7 +217,7 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler { CoreClient client = _clients.Get(event.getPlayer()); - if (!client.GetRank().has(event.getPlayer(), Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.TWITCH}, false)) + if (!client.GetRank().has(event.getPlayer(), Rank.ADMIN, new Rank[]{Rank.YOUTUBE, Rank.YOUTUBE_SMALL, Rank.TWITCH}, false)) return; if (_redis.elementExists(client.getAccountId() + client.getName())) @@ -578,13 +634,23 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler public void disguise(Player caller, String requestedUsername, String requestedSkin) { - if (!validateUsername(caller, requestedUsername)) return; - if (!validateUsername(caller, requestedSkin)) return; + if (!validateUsername(caller, requestedUsername, true)) return; + if (!validateUsername(caller, requestedSkin, false)) return; UtilGameProfile.getProfileByName(requestedUsername, true, requestedProfile -> { + if (VERY_SPECIAL_PEOPLE.contains(requestedProfile.getId().toString().toLowerCase())) + { + UtilPlayer.message(caller, F.main("Disguise", "The chosen username of " + F.elem(requestedUsername) + " is not valid")); + return; + } + + if (!verifyProfile(caller, requestedProfile)) return; + Consumer skinConsumer = requestedProfileSkin -> { + if (!verifyProfile(caller, requestedProfileSkin)) return; + SkinData skinData = SkinData.constructFromGameProfile(requestedProfileSkin, true, true); requestedProfile.getProperties().clear(); requestedProfile.getProperties().put("textures", skinData.getProperty()); @@ -603,27 +669,66 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler }); } - private boolean validateUsername(Player caller, String username) + private boolean validateUsername(Player caller, String username, boolean isUsername) { String replaced = UtilGameProfile.legalize(username); if (!replaced.equals(username)) { - UtilPlayer.message(caller, F.main(getName(), "The chosen username of '" + username + "' is not valid")); + UtilPlayer.message(caller, F.main("Disguise", "The chosen username of " + F.elem(username) + " is not valid")); return false; } if (username.length() > 16) { - UtilPlayer.message(caller, F.main("Disguise", "The chosen username of '" + username + "' is " + F.count(String.valueOf(username.length() - 16)) + " characters too long!")); + UtilPlayer.message(caller, F.main("Disguise", "The chosen username of " + F.elem(username) + " is " + F.count(String.valueOf(username.length() - 16)) + " characters too long!")); return false; } if (username.length() <= 0) { - UtilPlayer.message(caller, F.main("Disguise", "The chosen username of '" + username + "' must be longer than 0 characters")); + UtilPlayer.message(caller, F.main("Disguise", "The chosen username of " + F.elem(username) + " must be longer than " + F.count("0") + " characters")); return false; } + if (isUsername) + { + if (ILLEGAL_USERNAMES.contains(username.toLowerCase()) || MOJANG.contains(username.toLowerCase())) + { + if (!UtilServer.isTestServer()) + { + UtilPlayer.message(caller, F.main("Disguise", "The chosen username of " + F.elem(username) + " is not valid")); + return false; + } + } + if (username.length() < 3) + { + if (!_clients.Get(caller).GetRank().has(Rank.ADMIN)) + { + UtilPlayer.message(caller, F.main("Disguise", "The chosen username of " + F.elem(username) + " must be longer than " + F.count("2") + " letters")); + return false; + } + } + } + + return true; + } + + private boolean verifyProfile(Player caller, GameProfile requestedProfile) + { + Map map = MinecraftServer.getServer().aD().getTextures(requestedProfile, false); + + if (map.containsKey(MinecraftProfileTexture.Type.CAPE)) + { + MinecraftProfileTexture texture = map.get(MinecraftProfileTexture.Type.CAPE); + if (ILLEGAL_CAPES.contains(texture.getUrl().toLowerCase())) + { + if (!UtilServer.isTestServer()) + { + UtilPlayer.message(caller, F.main("Disguise", "The chosen username of " + F.elem(requestedProfile.getName()) + " is not valid")); + return false; + } + } + } return true; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index afedd8807..498bb6ae9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -45,7 +45,7 @@ import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.event.PlayerToggleSwimEvent; import mineplex.core.gadget.event.TauntCommandEvent; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHalloween; +import mineplex.core.gadget.gadgets.arrowtrail.halloween.ArrowTrailHalloween; import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid; import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald; @@ -55,6 +55,7 @@ import mineplex.core.gadget.gadgets.arrowtrail.howlingwinds.ArrowTrailStorm; import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic; import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti; import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow; +import mineplex.core.gadget.gadgets.arrowtrail.spring.ArrowTrailSpring; import mineplex.core.gadget.gadgets.arrowtrail.titan.ArrowTrailTitan; import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood; import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant; @@ -70,10 +71,11 @@ import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm; import mineplex.core.gadget.gadgets.death.music.DeathMusic; import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst; import mineplex.core.gadget.gadgets.death.shadow.DeathShadow; +import mineplex.core.gadget.gadgets.death.spring.DeathSpring; import mineplex.core.gadget.gadgets.death.titan.DeathTitan; import mineplex.core.gadget.gadgets.death.vampire.DeathBlood; import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHalloween; +import mineplex.core.gadget.gadgets.doublejump.halloween.DoubleJumpHalloween; import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings; import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald; @@ -83,6 +85,7 @@ import mineplex.core.gadget.gadgets.doublejump.howlingwinds.DoubleJumpStorm; import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic; import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker; import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow; +import mineplex.core.gadget.gadgets.doublejump.spring.DoubleJumpSpring; import mineplex.core.gadget.gadgets.doublejump.titan.DoubleJumpTitan; import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood; import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant; @@ -113,6 +116,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.morph.MorphAwkwardRabbit; import mineplex.core.gadget.gadgets.morph.MorphBat; import mineplex.core.gadget.gadgets.morph.MorphBlaze; import mineplex.core.gadget.gadgets.morph.MorphBlock; @@ -164,6 +168,7 @@ import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes; import mineplex.core.gadget.gadgets.particle.ParticleFairy; import mineplex.core.gadget.gadgets.particle.ParticleFireRings; import mineplex.core.gadget.gadgets.particle.ParticleLegend; +import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; import mineplex.core.gadget.gadgets.particle.ParticleWingsAngel; import mineplex.core.gadget.gadgets.particle.ParticleWingsBee; import mineplex.core.gadget.gadgets.particle.ParticleWingsDemons; @@ -207,6 +212,7 @@ import mineplex.core.gadget.set.SetHowlingWinds; import mineplex.core.gadget.set.SetMusic; import mineplex.core.gadget.set.SetParty; import mineplex.core.gadget.set.SetShadow; +import mineplex.core.gadget.set.SetSpring; import mineplex.core.gadget.set.SetTitan; import mineplex.core.gadget.set.SetVampire; import mineplex.core.gadget.set.SetWisdom; @@ -238,6 +244,7 @@ import mineplex.core.mount.MountManager; import mineplex.core.mount.event.MountActivateEvent; 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; import mineplex.core.treasure.TreasureManager; @@ -337,6 +344,7 @@ public class GadgetManager extends MiniPlugin addSet(new SetVampire(this)); addSet(new SetMusic(this)); addSet(new SetFreedom(this)); + addSet(new SetSpring(this)); } private void createGadgets() @@ -425,6 +433,7 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphDinnerbone(this)); addGadget(new MorphLoveDoctor(this)); addGadget(new MorphGoldPot(this)); + addGadget(new MorphAwkwardRabbit(this)); // Particles addGadget(new ParticleFoot(this)); @@ -450,6 +459,7 @@ public class GadgetManager extends MiniPlugin addGadget(new ParticleFreedom(this)); addGadget(new ParticleChristmasTree(this)); addGadget(new ParticleWingsLove(this)); + addGadget(new ParticleSpringHalo(this)); addGadget(new ParticleWingsBee(this)); // Arrow Trails @@ -466,6 +476,7 @@ public class GadgetManager extends MiniPlugin addGadget(new ArrowTrailMusic(this)); addGadget(new ArrowTrailFreedom(this)); addGadget(new ArrowTrailHalloween(this)); + addGadget(new ArrowTrailSpring(this)); // Death Effect addGadget(new DeathFrostLord(this)); @@ -481,6 +492,7 @@ public class GadgetManager extends MiniPlugin addGadget(new DeathMusic(this)); addGadget(new DeathFreedom(this)); addGadget(new DeathPresentDanger(this)); + addGadget(new DeathSpring(this)); // Double Jump addGadget(new DoubleJumpFrostLord(this)); @@ -496,6 +508,7 @@ public class GadgetManager extends MiniPlugin addGadget(new DoubleJumpMusic(this)); addGadget(new DoubleJumpFreedom(this)); addGadget(new DoubleJumpHalloween(this)); + addGadget(new DoubleJumpSpring(this)); // Hat for (HatType hatType : HatType.values()) @@ -1004,6 +1017,9 @@ 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 @@ -1369,7 +1385,7 @@ public class GadgetManager extends MiniPlugin if (!event.isGameInProgress() && event.getState().equals(TauntCommandEvent.TauntState.NONE)) event.setState(TauntCommandEvent.TauntState.NOT_IN_GAME); - if (taunt.isGameDisabled(event.getGameType()) && event.getState().equals(TauntCommandEvent.TauntState.NONE)) + if (taunt.isGameDisabled(event.getGameDisplay()) && event.getState().equals(TauntCommandEvent.TauntState.NONE)) event.setState(TauntCommandEvent.TauntState.GAME_DISABLED); if (!event.isAlive() && event.getState().equals(TauntCommandEvent.TauntState.NONE)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/TauntCommandEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/TauntCommandEvent.java index e803d54e2..ef6624b46 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/TauntCommandEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/event/TauntCommandEvent.java @@ -5,7 +5,7 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import mineplex.core.common.util.UtilTime; -import mineplex.core.gadget.gadgets.taunts.GameType; +import mineplex.core.game.GameDisplay; public class TauntCommandEvent extends Event { @@ -18,16 +18,16 @@ public class TauntCommandEvent extends Event private boolean _spectator; private long _lastPvp; private TauntState _state = TauntState.NONE; - private GameType _gameType; + private GameDisplay _gameDisplay; - public TauntCommandEvent(Player player, boolean gameInProgress, boolean alive, boolean spectator, long lastPvp, GameType gameType) + public TauntCommandEvent(Player player, boolean gameInProgress, boolean alive, boolean spectator, long lastPvp, GameDisplay gameDisplay) { _player = player; _gameInProgress = gameInProgress; _alive = alive; _spectator = spectator; _lastPvp = lastPvp; - _gameType = gameType; + _gameDisplay = gameDisplay; } public Player getPlayer() @@ -60,9 +60,9 @@ public class TauntCommandEvent extends Event return _state; } - public GameType getGameType() + public GameDisplay getGameDisplay() { - return _gameType; + return _gameDisplay; } public void setState(TauntState state) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/cupidslove/ArrowTrailCupid.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/cupidslove/ArrowTrailCupid.java index 813147704..c10562f6d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/cupidslove/ArrowTrailCupid.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/cupidslove/ArrowTrailCupid.java @@ -27,7 +27,6 @@ public class ArrowTrailCupid extends ArrowEffectGadget @Override public void doTrail(Arrow arrow) { - arrow.setCritical(false); Vector color = arrow.getTicksLived()%2 == 0? UtilColor.colorToVector(Color.RED) : UtilColor.colorToVector(Color.fromRGB(16738740)); UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, arrow.getLocation(), color, 1, 0, ViewDist.LONG); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHalloween.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/halloween/ArrowTrailHalloween.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHalloween.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/halloween/ArrowTrailHalloween.java index bd5b62563..112f272ad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/ArrowTrailHalloween.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/halloween/ArrowTrailHalloween.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.arrowtrail; +package mineplex.core.gadget.gadgets.arrowtrail.halloween; import java.awt.Color; import java.util.HashMap; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/spring/ArrowTrailSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/spring/ArrowTrailSpring.java new file mode 100644 index 000000000..c335ce062 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/spring/ArrowTrailSpring.java @@ -0,0 +1,73 @@ +package mineplex.core.gadget.gadgets.arrowtrail.spring; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Item; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.ItemStack; + +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.ArrowEffectGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class ArrowTrailSpring extends ArrowEffectGadget +{ + + private List _items = new ArrayList<>(); + + public ArrowTrailSpring(GadgetManager manager) + { + super(manager, "Flower Arrows", UtilText.splitLineToArray(C.cGray + "Send the power of Spring flying at your foes!", LineFormat.LORE), + -19, Material.YELLOW_FLOWER, (byte) 0); + } + + @Override + public void doTrail(Arrow arrow) + { + Item sunflower = arrow.getWorld().dropItem(arrow.getLocation(), new ItemStack(Material.DOUBLE_PLANT)); + _items.add(sunflower); + } + + @Override + public void doHitEffect(Arrow arrow) + { + + } + + @EventHandler + public void onPickup(PlayerPickupItemEvent event) + { + if (_items.contains(event.getItem())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void removeFlowers(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + Iterator iterator = _items.iterator(); + while (iterator.hasNext()) + { + Item item = iterator.next(); + if (item.getTicksLived() >= 20) + { + item.remove(); + iterator.remove(); + } + } + } + +} 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 index be3382dc6..67ea7e618 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/balloons/BalloonItem.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/balloons/BalloonItem.java @@ -68,7 +68,10 @@ public class BalloonItem extends BalloonGadget 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); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/spring/DeathSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/spring/DeathSpring.java new file mode 100644 index 000000000..eb15f5986 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/death/spring/DeathSpring.java @@ -0,0 +1,103 @@ +package mineplex.core.gadget.gadgets.death.spring; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.bukkit.Bukkit; +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.event.player.PlayerPickupItemEvent; +import org.bukkit.util.Vector; + +import mineplex.core.blood.BloodEvent; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.DeathEffectGadget; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class DeathSpring extends DeathEffectGadget +{ + + private List _items = new ArrayList<>(); + + public DeathSpring(GadgetManager manager) + { + super(manager, "Funeral Bouquet", + UtilText.splitLineToArray(C.cGray + "Leave a rose to pay respects", LineFormat.LORE), + -19, + Material.YELLOW_FLOWER, (byte) 0); + } + + @Override + public void onBlood(Player player, BloodEvent event) + { + event.setCancelled(true); + + final Location location = event.getLocation(); + while (location.getBlock().getType() != Material.AIR + && location.clone().add(0, 1, 0).getBlock().getType() != Material.AIR) + { + location.add(0, 1, 0); + } + + location.getBlock().setType(Material.DOUBLE_PLANT); + location.getBlock().setData((byte) 4); + + Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + location.getBlock().setType(Material.AIR); + + // Creates red rose explosion + for (int i = 50; i < 60; i++) + { + Item rose = location.getWorld().dropItem(location.add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.RED_ROSE, (byte) 0, 1, " " + i)); + _items.add(rose); + + Vector vel = new Vector(Math.sin(i * 9/5d), 0, Math.cos(i * 9/5d)); + UtilAction.velocity(rose, vel, Math.abs(Math.sin(i * 12/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i * 12/3000d))*0.6, 1, false); + + } + } + }, 60L); + } + + @EventHandler + public void onPickup(PlayerPickupItemEvent event) + { + if (_items.contains(event.getItem())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void removeFlowers(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + Iterator iterator = _items.iterator(); + while (iterator.hasNext()) + { + Item item = iterator.next(); + if (item.getTicksLived() >= 20) + { + item.remove(); + iterator.remove(); + } + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHalloween.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/halloween/DoubleJumpHalloween.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHalloween.java rename to Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/halloween/DoubleJumpHalloween.java index 0f2cc13e8..10155afbd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/DoubleJumpHalloween.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/halloween/DoubleJumpHalloween.java @@ -1,4 +1,4 @@ -package mineplex.core.gadget.gadgets.doublejump; +package mineplex.core.gadget.gadgets.doublejump.halloween; import java.awt.Color; import java.util.HashMap; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/spring/DoubleJumpSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/spring/DoubleJumpSpring.java new file mode 100644 index 000000000..63dabdaf9 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/doublejump/spring/DoubleJumpSpring.java @@ -0,0 +1,77 @@ +package mineplex.core.gadget.gadgets.doublejump.spring; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.DoubleJumpEffectGadget; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class DoubleJumpSpring extends DoubleJumpEffectGadget +{ + + private List _items = new ArrayList<>(); + + public DoubleJumpSpring(GadgetManager manager) + { + // TODO NAME LORE ICON + super(manager, "Flower Power", UtilText.splitLineToArray(C.cGray + "Be like a bouncing bee and pollinate everywhere you go!", LineFormat.LORE), -19, + Material.YELLOW_FLOWER, (byte) 0); + } + + @Override + public void doEffect(Player player) + { + for (int i = 50; i < 60; i++) + { + Item sunflower = player.getWorld().dropItem(player.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i)); + _items.add(sunflower); + + Vector vel = new Vector(Math.sin(i * 9/5d), 0, Math.cos(i * 9/5d)); + UtilAction.velocity(sunflower, vel, Math.abs(Math.sin(i * 12/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i * 12/3000d))*0.6, 1, false); + + } + } + + @EventHandler + public void onPickup(PlayerPickupItemEvent event) + { + if (_items.contains(event.getItem())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void removeFlowers(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + Iterator iterator = _items.iterator(); + while (iterator.hasNext()) + { + Item item = iterator.next(); + if (item.getTicksLived() >= 20) + { + item.remove(); + iterator.remove(); + } + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphAwkwardRabbit.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphAwkwardRabbit.java new file mode 100644 index 000000000..dc2b7446b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphAwkwardRabbit.java @@ -0,0 +1,105 @@ +package mineplex.core.gadget.gadgets.morph; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +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 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.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.hologram.Hologram; +import mineplex.core.recharge.Recharge; +import mineplex.core.utils.UtilGameProfile; + +public class MorphAwkwardRabbit extends MorphGadget +{ + + private List _quotes = new ArrayList<>(); + + private static final long COOLDOWN = 10000; + private static final long HOLOGRAM_TIME = 3000; + + public MorphAwkwardRabbit(GadgetManager manager) + { + super(manager, "Wascally Wabbit Morph", + UtilText.splitLinesToArray(new String[]{C.cGray + "Be absolutely silent my friends we are searching for rabbits currently!"}, LineFormat.LORE), + -19, Material.SKULL_ITEM, (byte) 0); + _quotes.addAll(Arrays.asList( + "Eh, what's up, doc?", + "That's all, folks.", + "Gee, ain't I a stinker?", + "Carrots are devine...", + "I know this defies the\n law of gravity,\n but I never studied law!", + "I don’t ask questions,\n I just have fun", + "Hey, just a minute you!\n Them’s fightin’ words!")); + setDisplayItem(SkinData.BUGS_BUNNY.getSkull()); + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + GameProfile gameProfile = UtilGameProfile.getGameProfile(player); + gameProfile.getProperties().clear(); + gameProfile.getProperties().put("textures", SkinData.BUGS_BUNNY.getProperty()); + + DisguisePlayer disguisePlayer = new DisguisePlayer(player, gameProfile); + disguisePlayer.showInTabList(true, 0); + UtilMorph.disguise(player, disguisePlayer, Manager); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + } + + @EventHandler + public void spawnHolograms(PlayerToggleSneakEvent event) + { + if (!isActive(event.getPlayer())) + return; + + if (event.isSneaking()) + return; + + if (!Recharge.Instance.use(event.getPlayer(), getName(), COOLDOWN, true, false, "Cosmetics")) + return; + + Location randomLoc = event.getPlayer().getLocation().clone(); + int[] rPos = new int[]{-2, -1, 0, 1, 2}; + int rX = rPos[UtilMath.random.nextInt(rPos.length)], rZ = rPos[UtilMath.random.nextInt(rPos.length)]; + + randomLoc.add(rX, 1, rZ); + + String quote = _quotes.get(UtilMath.random.nextInt(_quotes.size())); + Hologram hologram; + if (quote.contains("\n")) + { + String[] lines = quote.split("\n"); + hologram = new Hologram(Manager.getHologramManager(), randomLoc, true, HOLOGRAM_TIME, lines); + } + else + { + hologram = new Hologram(Manager.getHologramManager(), randomLoc, true, HOLOGRAM_TIME, quote); + } + hologram.start(); + } + +} 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 new file mode 100644 index 000000000..cab1f0ac1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/spring/ParticleSpringHalo.java @@ -0,0 +1,184 @@ +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 org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +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; + + public ParticleSpringHalo(GadgetManager manager) + { + 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); + } + + @Override + public void enableCustom(Player player, boolean message) + { + super.enableCustom(player, message); + Manager.removeGadgetType(player, GadgetType.MORPH, this); + Manager.removeOutfit(player, OutfitGadget.ArmorSlot.HELMET); + ColoredCircleEffect circleEffect = new ColoredCircleEffect(Manager.getPlugin(), player, 0.7d, false); + RGBData colorA = UtilColor.hexToRgb(0x5a92ed); + RGBData colorB = UtilColor.hexToRgb(0xdb5aed); + RGBData colorC = UtilColor.hexToRgb(0xd2cdf2); + RGBData colorD = UtilColor.hexToRgb(0x7c6df2); + RGBData colorE = UtilColor.hexToRgb(0xedeb97); + RGBData colorF = UtilColor.hexToRgb(0xeac07c); + circleEffect.addColors(colorA, colorB, colorC, colorD, colorE, colorF); + circleEffect.setYOffset(2.3d); + circleEffect.start(); + _effects.put(player, circleEffect); + player.getEquipment().setHelmet(new ItemStack(Material.RED_ROSE, 1, (byte) 8)); + } + + @Override + public void disableCustom(Player player, boolean message) + { + super.disableCustom(player, message); + if (_effects.containsKey(player)) + { + ColoredCircleEffect circleEffect = _effects.get(player); + if (circleEffect != null) + { + circleEffect.stop(); + } + } + _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 + public void playParticle(Player player, UpdateEvent event) + { + } + + @EventHandler + public void spawnFlowers(PlayerMoveEvent event) + { + if (!isActive(event.getPlayer())) + return; + + if (!_enableTrail) + return; + + Player player = event.getPlayer(); + + Block block = event.getFrom().getBlock(); + if (block.getType() != Material.AIR) + return; + + 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); + } + } + + 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 new file mode 100644 index 000000000..c497b99a9 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/spring/SpringHaloData.java @@ -0,0 +1,34 @@ +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/EternalTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java index 53e6a7793..103efacd2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/EternalTaunt.java @@ -30,6 +30,7 @@ import mineplex.core.events.EnableArcadeSpawnEvent; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.TauntGadget; +import mineplex.core.game.GameDisplay; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -53,7 +54,7 @@ public class EternalTaunt extends TauntGadget setPvpCooldown(PVP_COOLDOWN); setShouldPlay(true); setEventType(UpdateType.FAST); - addDisabledGames(GameType.SMASH, GameType.SMASHTEAMS, GameType.SMASHDOMINATION); + addDisabledGames(GameDisplay.Smash, GameDisplay.SmashTeams, GameDisplay.SmashDomination); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/GameType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/GameType.java deleted file mode 100644 index a0fe9230b..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/GameType.java +++ /dev/null @@ -1,84 +0,0 @@ -package mineplex.core.gadget.gadgets.taunts; - -public enum GameType -{ - - BACONBRAWL, - BARBARIANS, - BASKETBALL, - BOSSBATTLES, - BRIDGE, - CASTLESIEGE, - CHAMPIONSCTF, - CHAMPIONSDOMINATE, - CHAMPIONSTDM, - CHRISTMAS, - DEATHTAG, - DRAGONESCAPE, - DRAGONESCAPETEAMS, - DRAGONRIDERS, - DRAGONS, - DRAGONSTEAMS, - DRAW, - ELYTRARINGS, - EVOLUTION, - GRAVITY, - HALLOWEEN, - HALLOWEEN2016, - HIDESEEK, - HOLEINTHEWALL, - HORSE, - LOBBERS, - MICRO, - MILKCOW, - MINESTRIKE, - BAWKBAWKBATTLES, - MINECRAFTLEAGUE, - OLDMINEWARE, - PAINTBALL, - QUIVER, - QUIVERPAYLOAD, - QUIVERTEAMS, - RUNNER, - SEARCHANDDESTROY, - SHEEP, - TYPEWARS, - SMASH, - SMASHDOMINATION, - SMASHTEAMS, - SNAKE, - SNEAKYASSASSINS, - SNOWFIGHT, - SPEEDBUILDERS, - SPLEEF, - SPLEEFTEAMS, - SQUIDSHOOTER, - STACKER, - SURVIVALGAMES, - SURVIVALGAMESTEAMS, - TUG, - TURFWARS, - UHC, - UHCSOLO, - UHCSOLOSPEED, - UHCTEAMSSPEED, - WITHERASSAULT, - WIZARDS, - ZOMBIESURVIVAL, - BUILD, - BUILDMAVERICKS, - CARDS, - SKYWARS, - SKYWARSTEAMS, - MONSTERMAZE, - MONSTERLEAGUE, - GLADIATORS, - SKYFALL, - SKYFALLTEAMS, - BOUNCYBALLS, - VALENTINES, - EVENT, - BRAWL, - NONE - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java new file mode 100644 index 000000000..77727b480 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/SetSpring.java @@ -0,0 +1,23 @@ +package mineplex.core.gadget.set; + +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.arrowtrail.spring.ArrowTrailSpring; +import mineplex.core.gadget.gadgets.death.spring.DeathSpring; +import mineplex.core.gadget.gadgets.doublejump.spring.DoubleJumpSpring; +import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; +import mineplex.core.gadget.types.GadgetSet; + +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), + manager.getGadget(DoubleJumpSpring.class), + manager.getGadget(ParticleSpringHalo.class)); + } + +} 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 4a5ad6f60..feb632597 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/BalloonGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/BalloonGadget.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerTeleportEvent; import mineplex.core.common.util.F; @@ -114,6 +115,19 @@ public abstract class BalloonGadget extends Gadget { Map.Entry> entry = iterator.next(); for (BalloonData balloonData : entry.getValue().values()) + { + balloonData.teleport(); + } + } + } + + @EventHandler + public void onPlayerMove(PlayerMoveEvent event) + { + if (PLAYER_BALLOONS.containsKey(event.getPlayer().getUniqueId())) + { + Map balloons = PLAYER_BALLOONS.get(event.getPlayer().getUniqueId()); + for (BalloonData balloonData : balloons.values()) { balloonData.update(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ParticleGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ParticleGadget.java index 01d6e22a8..e04db2a61 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ParticleGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ParticleGadget.java @@ -32,7 +32,7 @@ public abstract class ParticleGadget extends Gadget super(manager, GadgetType.PARTICLE, name, desc, cost, mat, data, 1, altNames); } - public ParticleGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, YearMonth yearMonth, String...altNames) + public ParticleGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, YearMonth yearMonth, String... altNames) { super(manager, GadgetType.PARTICLE, name, desc, cost, mat, data, yearMonth, 1, altNames); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java index 0cca83b9f..991a7425b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java @@ -13,7 +13,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.taunts.GameType; +import mineplex.core.game.GameDisplay; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -32,7 +32,7 @@ public abstract class TauntGadget extends Gadget /** Sets when the taunt will run, if set above */ private UpdateType _updateType = UpdateType.TICK; /** List of games where this item is disabled */ - private List _disabledGames = new ArrayList<>(); + private List _disabledGames = new ArrayList<>(); /** The ticks that passed since the player started the effect */ private Map _ticksPerPlayer = new HashMap<>(); @@ -119,7 +119,7 @@ public abstract class TauntGadget extends Gadget _updateType = updateType; } - public void addDisabledGames(GameType... disabledGames) + public void addDisabledGames(GameDisplay... disabledGames) { _disabledGames.addAll(Arrays.asList(disabledGames)); } @@ -129,9 +129,9 @@ public abstract class TauntGadget extends Gadget return _canPlayWithPvp; } - public boolean isGameDisabled(GameType gameType) + public boolean isGameDisabled(GameDisplay gameDisplay) { - return _disabledGames.contains(gameType); + return _disabledGames.contains(gameDisplay); } public long getPvpCooldown() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/util/BalloonData.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/util/BalloonData.java index fe81e2d15..8ac58de85 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/util/BalloonData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/util/BalloonData.java @@ -50,6 +50,12 @@ public class BalloonData ((LivingEntity) _balloon).setLeashHolder(_player); } + public void teleport() + { + _balloon.teleport(_balloonLoc); + _balloon.setVelocity(new Vector(0, 3, 0)); + } + public void update() { if (_leash == null) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/locations/LocationConstants.java b/Plugins/Mineplex.Core/src/mineplex/core/locations/LocationConstants.java index 554be4a57..db103c12c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/locations/LocationConstants.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/locations/LocationConstants.java @@ -25,15 +25,15 @@ public class LocationConstants public static final Location[] CHEST_LOCATIONS = { new Location(WORLD, 34, 72, -15), - new Location(WORLD, 23, 72, -31), + new Location(WORLD, 26, 72, -35), new Location(WORLD, -23, 72, -31), new Location(WORLD, -34, 72, -15) }; //new Location(world, -25.5, 73, 19.5), new Location(world, -35.5, 69, 1.5) - public static final Location FOUNTAIN_SCHEMATIC = new Location(WORLD, -35.5, 68, 1.5); - public static final Location FOUNTAIN_LOCATION = new Location(WORLD, -24.5, 72, 24.5); + public static final Location FOUNTAIN_SCHEMATIC = new Location(WORLD, -41.5, 68, 5.5); + public static final Location FOUNTAIN_LOCATION = new Location(WORLD, -30.5, 72, 28.5); public static Location getResetLocation(Location chestLocation) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/loot/ChestLoot.java b/Plugins/Mineplex.Core/src/mineplex/core/loot/ChestLoot.java index 4dcf4eab3..39b89cfa2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/loot/ChestLoot.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/loot/ChestLoot.java @@ -1,6 +1,7 @@ package mineplex.core.loot; import java.util.ArrayList; +import java.util.Iterator; import mineplex.core.common.util.UtilMath; @@ -32,9 +33,32 @@ public class ChestLoot public ItemStack getLoot() { - int no = UtilMath.r(_totalLoot); + return getLoot(new ArrayList<>()); + } + + public ItemStack getLoot(ArrayList exclude) + { + int totalLoot = _totalLoot; + ArrayList items = (ArrayList) _randomItems.clone(); + + Iterator rItems = items.iterator(); + while (rItems.hasNext()) + { + RandomItem item = rItems.next(); + + for (Material mat : exclude) + { + if (item.getItemStack().getType() == mat) + { + totalLoot -= item.getAmount(); + rItems.remove(); + } + } + } + + int no = UtilMath.r(totalLoot); - for (RandomItem item : _randomItems) + for (RandomItem item : items) { no -= item.getAmount(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/loot/RandomItem.java b/Plugins/Mineplex.Core/src/mineplex/core/loot/RandomItem.java index c903c6fa3..7e7eef062 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/loot/RandomItem.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/loot/RandomItem.java @@ -48,4 +48,15 @@ public class RandomItem return _item; } + + @Override + public boolean equals(Object obj) + { + if (!(obj instanceof RandomItem)) + return false; + + RandomItem item = (RandomItem) obj; + + return _item.getType() == item.getItemStack().getType(); + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java index 802b3d643..e9f920567 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java @@ -123,6 +123,11 @@ public class LagMeter extends MiniPlugin return _ticksPerSecond; } + public double getRecentTicksPercentageAverage() + { + return _ticksPerSecondAverage; + } + private void sendUpdates() { for (Player player : _monitoring) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/CircleEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/CircleEffect.java index 8d1ae23d1..f9ff7b3a3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/CircleEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/CircleEffect.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.List; import org.bukkit.Location; +import org.bukkit.entity.Entity; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; @@ -23,6 +24,7 @@ public class CircleEffect extends Effect private List _randomColors = new ArrayList<>(); private int _maxCircles = -1; private int _totalCircles = 0; + private double _yOffset = 0.0; private static final double RANDOM_COLOR_CHANCE = 0.5; private static final int PARTICLES_PER_CIRCLE = 20; @@ -40,6 +42,14 @@ public class CircleEffect extends Effect _instantly = instantly; } + public CircleEffect(JavaPlugin plugin, Entity entity, double radius, Color color, boolean instantly) + { + super(-1, new EffectLocation(entity), plugin); + _radius = radius; + _color = color; + _instantly = instantly; + } + public void addRandomColor(Color color) { _randomColors.add(color); @@ -50,6 +60,11 @@ public class CircleEffect extends Effect _maxCircles = circles; } + public void setYOffset(double yOffset) + { + _yOffset = yOffset; + } + @Override public void runEffect() { @@ -57,7 +72,7 @@ public class CircleEffect extends Effect { for (int i = 0; i < PARTICLES_PER_CIRCLE; i++) { - Location location = getEffectLocation().getFixedLocation(); + Location location = getEffectLocation().getLocation().add(0, _yOffset, 0); double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE; double angle = _steps * increment; Vector vector = new Vector(Math.cos(angle) * _radius, 0, Math.sin(angle) * _radius); @@ -86,7 +101,7 @@ public class CircleEffect extends Effect return; } } - Location location = getEffectLocation().getFixedLocation(); + Location location = getEffectLocation().getLocation().add(0, _yOffset, 0); double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE; double angle = _steps * increment; Vector vector = new Vector(Math.cos(angle) * _radius, 0, Math.sin(angle) * _radius); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/ColoredCircleEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/ColoredCircleEffect.java new file mode 100644 index 000000000..51851e40b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/ColoredCircleEffect.java @@ -0,0 +1,122 @@ +package mineplex.core.particleeffects; + +import java.awt.Color; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.RGBData; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; + +public class ColoredCircleEffect extends Effect +{ + + private double _radius; + private List _colors; + private int _steps = 0; + private boolean _instantly = true; + private int _maxCircles = -1; + private int _totalCircles = 0; + private double _yOffset = 0.0; + + private static final int PARTICLES_PER_CIRCLE = 20; + + public ColoredCircleEffect(JavaPlugin plugin, Entity entity, double radius, boolean instantly, Color... colors) + { + super(-1, new EffectLocation(entity), plugin); + _radius = radius; + _colors = new ArrayList<>(); + _instantly = instantly; + Collections.addAll(_colors, colors); + } + + public void setMaxCircles(int circles) + { + _maxCircles = circles; + } + + public void setYOffset(double yOffset) + { + _yOffset = yOffset; + } + + public void addColor(Color color) + { + _colors.add(color); + } + + public void addColors(Color... colors) + { + Collections.addAll(_colors, colors); + } + + public void addColor(RGBData rgbData) + { + _colors.add(new Color(rgbData.getFullRed(), rgbData.getFullGreen(), rgbData.getFullBlue())); + } + + public void addColors(RGBData... rgbDatas) + { + for (RGBData rgbData : rgbDatas) + { + addColor(rgbData); + } + } + + @Override + public void runEffect() + { + if (_instantly) + { + for (int i = 0; i < PARTICLES_PER_CIRCLE; i++) + { + Location location = getEffectLocation().getLocation().add(0, _yOffset, 0); + double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE; + double angle = _steps * increment; + Vector vector = new Vector(Math.cos(angle) * _radius, 0, Math.sin(angle) * _radius); + ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(getNextColor()), location.add(vector)); + coloredParticle.display(); + _steps++; + } + stop(); + } + else + { + if (_maxCircles != -1) + { + if (_totalCircles >= _maxCircles) + { + stop(); + return; + } + } + Location location = getEffectLocation().getLocation().add(0, _yOffset, 0); + double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE; + double angle = _steps * increment; + Vector vector = new Vector(Math.cos(angle) * _radius, 0, Math.sin(angle) * _radius); + ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(getNextColor()), location.add(vector)); + coloredParticle.display(); + _steps++; + if (_steps >= PARTICLES_PER_CIRCLE) + { + _totalCircles++; + _steps = 0; + } + } + } + + private Color getNextColor() + { + int r = UtilMath.random.nextInt(_colors.size()); + return _colors.get(r); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/FlyingPetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/FlyingPetManager.java index 1779e723c..c144a93ab 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/FlyingPetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/FlyingPetManager.java @@ -1,7 +1,7 @@ package mineplex.core.pet; import org.bukkit.Location; -import org.bukkit.entity.Creature; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -17,13 +17,13 @@ public class FlyingPetManager */ private Player _player; - private Creature _pet; + private Entity _pet; private Location _grimReaperLoc, _target; private Vector _direction; private double _speed; private long _idleTime; - public FlyingPetManager(Player player, Creature pet) + public FlyingPetManager(Player player, Entity pet) { _player = player; _pet = pet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index 72186e7bb..47c79138d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -22,6 +22,7 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPigZombie; import org.bukkit.entity.Ageable; import org.bukkit.entity.Blaze; import org.bukkit.entity.Creature; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.PigZombie; import org.bukkit.entity.Player; @@ -54,7 +55,6 @@ import mineplex.core.common.Rank; import mineplex.core.common.shape.ShapeWings; import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; @@ -88,17 +88,17 @@ public class PetManager extends MiniClientPlugin private BlockRestore _blockRestore; private Map _activePetOwnerTypes = new HashMap<>(); - private NautHashMap _activePetOwners; - private NautHashMap _failedAttempts; + private Map _activePetOwners; + private Map _failedAttempts; private Map _petOwnerQueue = new HashMap<>(); - private NautHashMap _petRenameQueue = new NautHashMap(); + private Map _petRenameQueue = new HashMap<>(); private DonationManager _donationManager; private CoreClientManager _clientManager; private InventoryManager _inventoryManager; - private Map _flyingPets = new HashMap<>(); - private Map _trueLovePets = new HashMap<>(); + private Map _flyingPets = new HashMap<>(); + private Map _trueLovePets = new HashMap<>(); private ShapeWings _grimReaperWings = new ShapeWings(ParticleType.RED_DUST.particleName, new org.bukkit.util.Vector(0.2, 0.2, 0.2), 1, 0, false, ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_ANGEL_WING_PATTERN); private ShapeWings _grimReaperWingsEdge = new ShapeWings(ParticleType.RED_DUST.particleName, new org.bukkit.util.Vector(0.1, 0.1, 0.1), 1, 0, true, ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_ANGEL_WING_PATTERN); @@ -120,8 +120,8 @@ public class PetManager extends MiniClientPlugin _clientManager = clientManager; _inventoryManager = inventoryManager; - _activePetOwners = new NautHashMap(); - _failedAttempts = new NautHashMap(); + _activePetOwners = new HashMap<>(); + _failedAttempts = new HashMap<>(); } public void addPetOwnerToQueue(String playerName, PetType petType) @@ -169,7 +169,7 @@ public class PetManager extends MiniClientPlugin if (player != null && player.isOnline()) { - Creature activePet = getActivePet(playerName); + Entity activePet = getActivePet(playerName); if (activePet != null) { activePet.setCustomNameVisible(true); @@ -213,7 +213,7 @@ public class PetManager extends MiniClientPlugin return; } - Creature pet; + Entity pet; EntityType entityType = petType.getEntityType(); //Wither Spawn @@ -221,7 +221,7 @@ public class PetManager extends MiniClientPlugin { _creatureModule.SetForce(true); - pet = (Creature) location.getWorld().spawnEntity(location, EntityType.SILVERFISH); + pet = location.getWorld().spawnEntity(location, EntityType.SILVERFISH); UtilEnt.silence(pet, true); DisguiseWither witherDisguise = new DisguiseWither(pet); @@ -258,33 +258,35 @@ public class PetManager extends MiniClientPlugin } } } - pet = (Creature)_creatureModule.SpawnEntity(location, petType.getEntityType()); + pet = _creatureModule.SpawnEntity(location, petType.getEntityType()); } //Default Spawn else { - pet = (Creature)_creatureModule.SpawnEntity(location, petType.getEntityType()); + pet = _creatureModule.SpawnEntity(location, petType.getEntityType()); } //Named Pet if (Get(player).getPets().get(petType) != null && Get(player).getPets().get(petType).length() > 0) { - //pet.setCustomNameVisible(true); + pet.setCustomNameVisible(true); pet.setCustomName(Get(player).getPets().get(petType)); } if (petType.equals(PetType.ZOMBIE)) { - ((Zombie) pet).setBaby(true); - pet.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); - pet.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 0)); + Zombie zombie = (Zombie) pet; + zombie.setBaby(true); + zombie.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); + zombie.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 0)); UtilEnt.silence(pet, true); } if (pet instanceof PigZombie) { - ((PigZombie)pet).setBaby(true); - pet.getEquipment().setHelmet(new ItemStack(Material.SKULL_ITEM, 1, (short)0, (byte) 1)); - pet.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 0)); + PigZombie pigZombie = (PigZombie) pet; + pigZombie.setBaby(true); + pigZombie.getEquipment().setHelmet(new ItemStack(Material.SKULL_ITEM, 1, (short)0, (byte) 1)); + pigZombie.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 0)); } else if (pet instanceof Villager) { @@ -293,10 +295,11 @@ public class PetManager extends MiniClientPlugin } else if (pet instanceof Skeleton) { - pet.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); //stop burning + Skeleton skeleton = (Skeleton) pet; + skeleton.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); //stop burning UtilEnt.silence(pet, true); - DisguiseGuardian disguise = new DisguiseGuardian(pet); + DisguiseGuardian disguise = new DisguiseGuardian(skeleton); if (Get(player).getPets().get(petType) != null && Get(player).getPets().get(petType).length() > 0) { @@ -306,7 +309,7 @@ public class PetManager extends MiniClientPlugin _disguiseManager.disguise(disguise); } - else if (pet instanceof Rabbit) + else if (petType.equals(PetType.RABBIT)) { UtilEnt.silence(pet, true); DisguiseChicken disguise = new DisguiseChicken(pet); @@ -410,6 +413,12 @@ public class PetManager extends MiniClientPlugin zombie.getEquipment().setLeggings(ItemStackFactory.Instance.createColoredLeatherArmor(2, org.bukkit.Color.fromRGB(0, 153, 0))); zombie.getEquipment().setBoots(ItemStackFactory.Instance.createColoredLeatherArmor(3, org.bukkit.Color.fromRGB(0, 153, 0))); } + else if (petType.equals(PetType.KILLER_BUNNY)) + { + Rabbit rabbit = (Rabbit) pet; + rabbit.setAdult(); + rabbit.setRabbitType(Rabbit.Type.THE_KILLER_BUNNY); + } _activePetOwnerTypes.put(player.getName(), petType); _activePetOwners.put(player.getName(), pet); @@ -424,7 +433,7 @@ public class PetManager extends MiniClientPlugin UtilEnt.vegetate(pet); } - public Creature getPet(Player player) + public Entity getPet(Player player) { return _activePetOwners.get(player.getName()); } @@ -433,7 +442,7 @@ public class PetManager extends MiniClientPlugin { if (_activePetOwners.containsKey(player.getName())) { - final Creature pet = _activePetOwners.get(player.getName()); + final Entity pet = _activePetOwners.get(player.getName()); //Wither Silverfish if (pet.getPassenger() != null) @@ -494,7 +503,7 @@ public class PetManager extends MiniClientPlugin { String playerName = null; - for (Entry entry : _activePetOwners.entrySet()) + for (Entry entry : _activePetOwners.entrySet()) { if (entry.getValue() == event.getEntity()) playerName = entry.getKey(); @@ -518,28 +527,28 @@ public class PetManager extends MiniClientPlugin public void onUpdate(UpdateEvent event) { - for (Entry entry : _activePetOwners.entrySet()) + for (Entry entry : _activePetOwners.entrySet()) { String playerName = entry.getKey(); - Creature creature = entry.getValue(); + Entity entity = entry.getValue(); if (event.getType() == UpdateType.TICK) { - if (creature instanceof PigZombie) + if (entity instanceof PigZombie) { - UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, creature.getLocation(), 0.2f, 0.0f, 0.2f, 0.0f, 4, ViewDist.NORMAL); - if(event.getTick() % 3 == 0) creature.getWorld().playSound(creature.getLocation(), Sound.BLAZE_BREATH, 0.03f, 0f); - if(!((CraftPigZombie) creature).getHandle().isSilent()) + UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, entity.getLocation(), 0.2f, 0.0f, 0.2f, 0.0f, 4, ViewDist.NORMAL); + if(event.getTick() % 3 == 0) entity.getWorld().playSound(entity.getLocation(), Sound.BLAZE_BREATH, 0.03f, 0f); + if(!((CraftPigZombie) entity).getHandle().isSilent()) { - ((CraftPigZombie) creature).getHandle().setSilent(true); + ((CraftPigZombie) entity).getHandle().setSilent(true); } } } else if (event.getType() == UpdateType.FAST) { - if (creature instanceof Blaze) + if (entity instanceof Blaze) { - Location loc = creature.getLocation().clone().add(0, .5, 0).add(creature.getLocation().getDirection().multiply(-0.2)); + Location loc = entity.getLocation().clone().add(0, .5, 0).add(entity.getLocation().getDirection().multiply(-0.2)); _grimReaperWings.display(loc); _grimReaperWingsEdge.display(loc); } @@ -548,7 +557,7 @@ public class PetManager extends MiniClientPlugin PetType petType = getActivePetType(playerName); if (petType == PetType.CUPID_PET) { - Location loc = creature.getLocation().clone().add(0, .5, 0).add(creature.getLocation().getDirection().multiply(-0.2)); + Location loc = entity.getLocation().clone().add(0, .5, 0).add(entity.getLocation().getDirection().multiply(-0.2)); _cupidWings.displayColored(loc, Color.PINK); _cupidWingsWhite.displayColored(loc, Color.WHITE); @@ -561,7 +570,7 @@ public class PetManager extends MiniClientPlugin PetType petType = getActivePetType(playerName); if (petType == PetType.CUPID_PET) { - Location loc = creature.getLocation().clone().add(0, .5, 0); + Location loc = entity.getLocation().clone().add(0, .5, 0); UtilParticle.PlayParticle(ParticleType.HEART, loc, 0.25f, 0.25f, 0.25f, 0.25f, 3, ViewDist.NORMAL); } } @@ -581,7 +590,7 @@ public class PetManager extends MiniClientPlugin String playerName = ownerIterator.next(); Player owner = Bukkit.getPlayer(playerName); - Creature pet = _activePetOwners.get(playerName); + Entity pet = _activePetOwners.get(playerName); Location petSpot = pet.getLocation(); Location ownerSpot = owner.getLocation(); xDiff = Math.abs(petSpot.getBlockX() - ownerSpot.getBlockX()); @@ -657,7 +666,7 @@ public class PetManager extends MiniClientPlugin @EventHandler public void grimReaperFly(UpdateEvent event) { - for (Entry entry : _flyingPets.entrySet()) + for (Entry entry : _flyingPets.entrySet()) { FlyingPetManager flyingPetManager = entry.getValue(); flyingPetManager.update(); @@ -670,11 +679,11 @@ public class PetManager extends MiniClientPlugin if (event.getType() != UpdateType.FASTEST) return; - Iterator> iterator = _trueLovePets.entrySet().iterator(); + Iterator> iterator = _trueLovePets.entrySet().iterator(); while (iterator.hasNext()) { - Entry entry = iterator.next(); - Creature zombie = entry.getKey(); + Entry entry = iterator.next(); + Entity zombie = entry.getKey(); UtilParticle.PlayParticle(ParticleType.HEART, zombie.getLocation().add(0, 0.25, 0), 0.25f, 0.25f, 0.25f, 0, 1, ViewDist.NORMAL); TrueLoveData trueLoveData = entry.getValue(); trueLoveData.update(); @@ -690,7 +699,7 @@ public class PetManager extends MiniClientPlugin { if (event.getEntity() instanceof Zombie) { - if (_activePetOwners.containsValue((Creature) event.getEntity())) + if (_activePetOwners.containsValue(event.getEntity())) { event.setCancelled(true); } @@ -718,7 +727,7 @@ public class PetManager extends MiniClientPlugin return _activePetOwnerTypes.get(name); } - public Creature getActivePet(String name) + public Entity getActivePet(String name) { return _activePetOwners.get(name); } @@ -734,7 +743,7 @@ public class PetManager extends MiniClientPlugin removePet(player, true); } - public Collection getPets() + public Collection getPets() { return _activePetOwners.values(); } @@ -744,4 +753,9 @@ public class PetManager extends MiniClientPlugin return _creatureModule; } + public DisguiseManager getDisguiseManager() + { + return _disguiseManager; + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetType.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetType.java index e5453d7fe..6503db11e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetType.java @@ -33,7 +33,8 @@ public enum PetType GINGERBREAD_MAN("Gingerbread Man", EntityType.ZOMBIE, -16, "Looks like you can catch him after all."), CUPID_PET("Cupid", EntityType.ZOMBIE, -17, "Sometimes you need a little extra help finding true Love. Why not have Cupid help you out?", Material.BOW, (byte) 0), TRUE_LOVE_PET("True Love", EntityType.ZOMBIE, -14, "Sometimes love means chasing the person of your dreams until you catch them.", Material.APPLE, YearMonth.of(2017, Month.FEBRUARY)), - LEPRECHAUN("Leprechaun", EntityType.ZOMBIE, -18, "Apparently this little guy lost his Pot of Gold in the war.", SkinData.LEPRECHAUN.getSkull()) + LEPRECHAUN("Leprechaun", EntityType.ZOMBIE, -18, "Apparently this little guy lost his Pot of Gold in the war.", SkinData.LEPRECHAUN.getSkull()), + KILLER_BUNNY("Killer Bunny", EntityType.RABBIT, -19, "The Easter Bunny's less talked about brother Devin was a bit less fun to hang out with.", Material.RABBIT_FOOT, (byte) 0) // TODO CHECK IF LOBBY IS 1.9+ // Not in this update //SHULKER("Shulker Pet", EntityType.BAT, 0, "Is it a turtle or an alien? Either way its shot can be really UPLIFTING.") diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPet.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPet.java new file mode 100644 index 000000000..d46290c2f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPet.java @@ -0,0 +1,168 @@ +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 new file mode 100644 index 000000000..9744b784b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPetAgeable.java @@ -0,0 +1,28 @@ +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 new file mode 100644 index 000000000..60ea7224b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPetEquipment.java @@ -0,0 +1,66 @@ +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 new file mode 100644 index 000000000..b45c57f6d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/custom/CustomPetZombie.java @@ -0,0 +1,149 @@ +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/rankGiveaway/redis/GiveawayMessageHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java index ccea12e19..8bf01da12 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java @@ -50,7 +50,7 @@ public class GiveawayMessageHandler implements CommandCallback String playerName = message.getPlayerName(); int count = message.getEternalCount(); String countString = count + UtilTime.getDayOfMonthSuffix(count); - String chatMessage = C.cPurple + playerName + C.cWhite + " found Eternal Rank in a " + C.cPurple + "Thanksgiving Chicken"; + String chatMessage = C.cPurple + playerName + C.cWhite + " found Eternal Rank in an " + C.cPurple + "Easter Egg Basket"; UtilTextMiddle.display(C.cDPurple + C.Bold + "ETERNAL", chatMessage, 20, 80, 20, UtilServer.getPlayers()); World world = UtilServer.getPlayers().length > 0 ? UtilServer.getPlayers()[0].getWorld() : Bukkit.getWorlds().get(0); LightFlicker lightFlicker = new LightFlicker(world); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index 855d747d7..171bfa55e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -15,7 +15,7 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.banner.CountryFlag; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHalloween; +import mineplex.core.gadget.gadgets.arrowtrail.halloween.ArrowTrailHalloween; import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid; import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald; @@ -25,6 +25,7 @@ import mineplex.core.gadget.gadgets.arrowtrail.howlingwinds.ArrowTrailStorm; import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic; import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti; import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow; +import mineplex.core.gadget.gadgets.arrowtrail.spring.ArrowTrailSpring; import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood; import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.balloons.BalloonType; @@ -38,9 +39,10 @@ import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm; import mineplex.core.gadget.gadgets.death.music.DeathMusic; import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst; import mineplex.core.gadget.gadgets.death.shadow.DeathShadow; +import mineplex.core.gadget.gadgets.death.spring.DeathSpring; import mineplex.core.gadget.gadgets.death.vampire.DeathBlood; import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHalloween; +import mineplex.core.gadget.gadgets.doublejump.halloween.DoubleJumpHalloween; import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings; import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald; @@ -50,6 +52,7 @@ import mineplex.core.gadget.gadgets.doublejump.howlingwinds.DoubleJumpStorm; import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic; import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker; import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow; +import mineplex.core.gadget.gadgets.doublejump.spring.DoubleJumpSpring; import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood; import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant; import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin; @@ -67,6 +70,7 @@ import mineplex.core.gadget.gadgets.item.ItemPaintballGun; 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.morph.MorphAwkwardRabbit; import mineplex.core.gadget.gadgets.morph.MorphBat; import mineplex.core.gadget.gadgets.morph.MorphBlock; import mineplex.core.gadget.gadgets.morph.MorphBunny; @@ -115,6 +119,7 @@ import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; import mineplex.core.gadget.gadgets.particle.music.ParticleMusic; import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime; import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; @@ -565,7 +570,7 @@ public class RewardManager addReward(Type.TRICK_OR_TREAT, new SpinTicketReward(_clientManager, 1, 3, rarity, 150, 0)); addReward(Type.TRICK_OR_TREAT, new GameAmplifierReward(_inventoryManager, 1, 2, rarity, 150, 0)); addReward(Type.TRICK_OR_TREAT, new RuneAmplifierReward(_inventoryManager, 20, 1, 3, rarity, 120, 0)); - addReward(Type.TRICK_OR_TREAT, new UnknownPackageReward(_donationManager, "Clan Banner Access", "Wear/Place Clan Banner", "Clan Banner Usage", new ItemStack(Material.BANNER), rarity, 110, 0)); + addReward(Type.TRICK_OR_TREAT, new UnknownPackageReward(_donationManager, _inventoryManager, "Clan Banner Access", "Wear/Place Clan Banner", "Clan Banner Usage", new ItemStack(Material.BANNER), rarity, 110, 0)); addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.OLD, 1, 5, rarity, 150, 0)); addReward(Type.TRICK_OR_TREAT, new ChestReward(_inventoryManager, TreasureType.ANCIENT, 1, 5, rarity, 80, 0)); @@ -578,7 +583,7 @@ public class RewardManager // THANKFUL addReward(Type.THANKFUL, new SpinTicketReward(_clientManager, 1, 3, rarity, 150, 0)); addReward(Type.THANKFUL, new RuneAmplifierReward(_inventoryManager, 20, 1, 3, rarity, 120, 0)); - addReward(Type.THANKFUL, new UnknownPackageReward(_donationManager, "Clan Banner Access", "Wear/Place Clan Banner", "Clan Banner Usage", new ItemStack(Material.BANNER), rarity, 110, 0)); + addReward(Type.THANKFUL, new UnknownPackageReward(_donationManager, _inventoryManager, "Clan Banner Access", "Wear/Place Clan Banner", "Clan Banner Usage", new ItemStack(Material.BANNER), rarity, 110, 0)); addReward(Type.THANKFUL, new ChestReward(_inventoryManager, TreasureType.OLD, 1, 5, rarity, 150, 0)); addReward(Type.THANKFUL, new ChestReward(_inventoryManager, TreasureType.ANCIENT, 1, 5, rarity, 80, 0)); @@ -599,6 +604,11 @@ public class RewardManager addGadget(Type.STPATRICKS, getGadget(OutfitStPatricksChestplate.class), rarity, 50); addGadget(Type.STPATRICKS, getGadget(OutfitStPatricksLeggings.class), rarity, 50); addGadget(Type.STPATRICKS, getGadget(OutfitStPatricksBoots.class), rarity, 50); + + // SPRING + addGadget(Type.SPRING, getGadget(ArrowTrailSpring.class), rarity, 100); + addGadget(Type.SPRING, getGadget(DeathSpring.class), rarity, 100); + addGadget(Type.SPRING, getGadget(DoubleJumpSpring.class), rarity, 100); } public void addLegendary() @@ -856,6 +866,12 @@ public class RewardManager addPetReward(Type.STPATRICKS, PetType.LEPRECHAUN, rarity, 30); addMount(Type.STPATRICKS, getMount(MountStPatricksHorse.class), rarity, 30); + + // SPRING + addGadget(Type.SPRING, getGadget(ParticleSpringHalo.class), rarity, 100); + addGadget(Type.SPRING, getGadget(MorphAwkwardRabbit.class), rarity, 25); + + addPetReward(Type.SPRING, PetType.KILLER_BUNNY, rarity, 50); } public UnknownPackageReward addMount(Type type, Mount mount, RewardRarity rarity, int weight) @@ -865,7 +881,7 @@ public class RewardManager public UnknownPackageReward addMount(Type type, Mount mount, RewardRarity rarity, int weight, int shards) { - UnknownPackageReward reward = new UnknownPackageReward(_donationManager, "Mount", mount.getDisplayName(), mount.getName(), + UnknownPackageReward reward = new UnknownPackageReward(_donationManager, _inventoryManager, "Mount", mount.getDisplayName(), mount.getName(), new ItemStack(mount.getDisplayMaterial(), 1, (short) 0, (byte) mount.getDisplayData()), rarity, weight, shards); addReward(type, reward); return reward; @@ -891,7 +907,7 @@ public class RewardManager public UnknownPackageReward addHatReward(RewardPool.Type type, HatGadget gadget, RewardRarity rarity, int weight) { UnknownPackageReward reward = - new UnknownPackageReward(_donationManager, gadget.getGadgetType().getCategoryType(), gadget.getDisplayName(), + new UnknownPackageReward(_donationManager, _inventoryManager, gadget.getGadgetType().getCategoryType(), gadget.getDisplayName(), gadget.getName(), gadget.getHelmetItem(), rarity, weight, getShards(rarity)); addReward(type, reward); return reward; @@ -918,7 +934,7 @@ public class RewardManager display = gadget.getDisplayItem(); } UnknownPackageReward reward = - new UnknownPackageReward(_donationManager, gadget.getGadgetType().getCategoryType(), displayName, + new UnknownPackageReward(_donationManager, _inventoryManager, gadget.getGadgetType().getCategoryType(), displayName, gadget.getName(), display, rarity, weight, shards, gadget.getAlternativePackageNames()); addReward(type, reward); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java index 623552350..50b237313 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java @@ -65,6 +65,7 @@ public class RewardPool MINESTRIKE(true, 2), LOVECHEST(false, 1), STPATRICKS(false, 1), + SPRING(false, 1), CARL_SPINNER(true); private boolean _useDuplicates; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java index 33381f37e..3442977b6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java @@ -22,6 +22,7 @@ public enum RewardType LOVE_CHEST( 0, 6, 18, 0), VALENTINES_GIFT( 0, 7, 20, 20), ST_PATRICKS( 0, 6, 18, 0), + SPRING( 0, 6, 18, 0), SPINNER_FILLER( 0.1, 1, 4, 20), SPINNER_REAL( 0.000001, 0.05, 0.4, 5); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java index 23e4e179a..0f6839279 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java @@ -26,7 +26,7 @@ public class PetReward extends UnknownPackageReward public PetReward(PetManager petManager, InventoryManager inventoryManager, DonationManager donationManager, String name, String packageName, PetType petType, RewardRarity rarity, int weight, int shardValue) { - super(donationManager, "Pet", name, packageName, new ItemStack(Material.MONSTER_EGG, 1, petType.getEntityType().getTypeId()), rarity, weight, shardValue); + super(donationManager, inventoryManager, "Pet", name, packageName, new ItemStack(Material.MONSTER_EGG, 1, petType.getEntityType().getTypeId()), rarity, weight, shardValue); _petManager = petManager; _inventoryManager = inventoryManager; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java index 48ce5dc23..c14cbe35d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java @@ -1,13 +1,15 @@ package mineplex.core.reward.rewards; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.donation.DonationManager; +import mineplex.core.inventory.InventoryManager; import mineplex.core.reward.Reward; import mineplex.core.reward.RewardData; import mineplex.core.reward.RewardRarity; import mineplex.core.reward.RewardType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; /** * Created by shaun on 14-09-12. @@ -15,16 +17,18 @@ import org.bukkit.inventory.ItemStack; public class UnknownPackageReward extends Reward { protected DonationManager _donationManager; + protected InventoryManager _inventoryManager; private ItemStack _itemStack; private String _header; private String _name; private String _packageName; private String[] _alternativeNames; - public UnknownPackageReward(DonationManager donationManager, String header, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight, int shardValue) + public UnknownPackageReward(DonationManager donationManager, InventoryManager inventoryManager, String header, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight, int shardValue) { super(rarity, weight, shardValue); _donationManager = donationManager; + _inventoryManager = inventoryManager; _header = header; _name = name; _packageName = packageName; @@ -32,10 +36,11 @@ public class UnknownPackageReward extends Reward _alternativeNames = new String[]{}; } - public UnknownPackageReward(DonationManager donationManager, String header, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight, int shardValue, String... alternativeNames) + public UnknownPackageReward(DonationManager donationManager, InventoryManager inventoryManager, String header, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight, int shardValue, String... alternativeNames) { super(rarity, weight, shardValue); _donationManager = donationManager; + _inventoryManager = inventoryManager; _header = header; _name = name; _packageName = packageName; @@ -64,6 +69,10 @@ public class UnknownPackageReward extends Reward { hasItem = true; } + else if (_inventoryManager.Get(player).getItemCount(_packageName) > 0) + { + hasItem = true; + } else { for (String altName : _alternativeNames) @@ -72,6 +81,10 @@ public class UnknownPackageReward extends Reward { hasItem = true; } + if (_inventoryManager.Get(player).getItemCount(altName) > 0) + { + hasItem = true; + } } } return !hasItem; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java index 596ab3aa5..69a8a4e65 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java @@ -1,9 +1,7 @@ package mineplex.core.status; import java.io.File; -import java.lang.reflect.Constructor; import java.util.Collection; -import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -11,12 +9,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.plugin.java.JavaPlugin; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.PropertyMap; -import com.mojang.util.UUIDTypeAdapter; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Constants; @@ -166,7 +158,7 @@ public class ServerStatusManager extends MiniPlugin String motd = _enabled ? event.getMotd() : "Restarting"; int playerCount = _clientManager.getPlayerCountIncludingConnecting(); int maxPlayerCount = event.getMaxPlayers(); - int tps = (int) _lagMeter.getTicksPerSecond(); + int tps = (int) Math.max(_lagMeter.getRecentTicksPercentageAverage(), _lagMeter.getTicksPerSecond()); String address = Bukkit.getServer().getIp().isEmpty() ? "localhost" : Bukkit.getServer().getIp(); int port = _plugin.getServer().getPort(); String group = _plugin.getConfig().getString("serverstatus.group") + ""; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/HolidayCheerTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/HolidayCheerTrack.java index ecfc2ba3c..7a88cb9f4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/HolidayCheerTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/HolidayCheerTrack.java @@ -22,6 +22,7 @@ import mineplex.core.gadget.gadgets.item.ItemSnowball; import mineplex.core.gadget.set.SetCupidsLove; import mineplex.core.gadget.set.SetFreedom; import mineplex.core.gadget.set.SetFrostLord; +import mineplex.core.gadget.set.SetSpring; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetSet; import mineplex.core.titles.tracks.Track; @@ -52,10 +53,12 @@ public class HolidayCheerTrack extends Track HOLIDAY_CHESTS.add(TreasureType.GINGERBREAD); HOLIDAY_CHESTS.add(TreasureType.LOVE_CHEST); HOLIDAY_CHESTS.add(TreasureType.ST_PATRICKS); + HOLIDAY_CHESTS.add(TreasureType.SPRING); HOLIDAY_SETS.add(SetFreedom.class); HOLIDAY_SETS.add(SetCupidsLove.class); HOLIDAY_SETS.add(SetFrostLord.class); + HOLIDAY_SETS.add(SetSpring.class); } private final GadgetManager _gadgetManager = Managers.require(GadgetManager.class); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/LuckyTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/LuckyTrack.java index 7bbf3bb83..9de427d99 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/LuckyTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/LuckyTrack.java @@ -39,6 +39,7 @@ public class LuckyTrack extends Track MULTIPLIER.put(TreasureType.TRICK_OR_TREAT, 2); MULTIPLIER.put(TreasureType.LOVE_CHEST, 2); MULTIPLIER.put(TreasureType.ST_PATRICKS, 2); + MULTIPLIER.put(TreasureType.SPRING, 2); MULTIPLIER.put(TreasureType.OMEGA, 3); IRON.add(Material.IRON_SPADE); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/TreasureHunterTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/TreasureHunterTrack.java index 30e7d193c..b7faf7d89 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/TreasureHunterTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/TreasureHunterTrack.java @@ -31,6 +31,7 @@ public class TreasureHunterTrack extends Track POINTS.put(TreasureType.GINGERBREAD, 25); POINTS.put(TreasureType.LOVE_CHEST, 25); POINTS.put(TreasureType.ST_PATRICKS, 25); + POINTS.put(TreasureType.SPRING, 25); POINTS.put(TreasureType.OMEGA, 50); POINTS.put(TreasureType.MINESTRIKE, 3); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java index f1e489390..cb408fd84 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java @@ -224,6 +224,15 @@ public class Treasure block.getLocation().add(.5 + rX, .7, .5 + rZ)); coloredParticle.display(); } + else if (_treasureType == TreasureType.SPRING) + { + int r = (int) (Math.random() * 2); + double rX = Math.random() * 2 - 1, rZ = Math.random() * 2 - 1; + ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, + new DustSpellColor((r == 0) ? Color.RED : Color.YELLOW), + block.getLocation().add(.5 + rX, .7, .5 + rZ)); + coloredParticle.display(); + } else { UtilParticle.PlayParticle(type, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.2F, 0, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java index b29622c3d..581ce9b47 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java @@ -97,6 +97,13 @@ public enum TreasureStyle ParticleType.HAPPY_VILLAGER, Sound.VILLAGER_YES, Sound.VILLAGER_YES + ), + SPRING( + ParticleType.RED_DUST, + ParticleType.RED_DUST, + ParticleType.RED_DUST, + Sound.STEP_GRASS, + Sound.STEP_GRASS ); private ParticleType _secondaryParticle; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java index c81c578c6..a9d3bf5c1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java @@ -34,7 +34,9 @@ public enum TreasureType LOVE_CHEST(C.cRed + "Love Treasure", "Love Chest", "LoveChest", RewardType.LOVE_CHEST, Material.CHEST, TreasureStyle.LOVECHEST, RewardPool.Type.LOVECHEST, true, 20000), - ST_PATRICKS(C.cGreen + "St Patrick's Treasure", "St Patricks Chest", "StPatricksChest", RewardType.ST_PATRICKS, Material.CHEST, TreasureStyle.STPATRICKS,RewardPool.Type.STPATRICKS, true, 20000); + ST_PATRICKS(C.cGreen + "St Patrick's Treasure", "St Patricks Chest", "StPatricksChest", RewardType.ST_PATRICKS, Material.CHEST, TreasureStyle.STPATRICKS,RewardPool.Type.STPATRICKS, true, 20000), + + SPRING(C.cGreen + "Spring Treasure", "Spring Chest", "SpringChest", RewardType.SPRING, Material.CHEST, TreasureStyle.SPRING, RewardPool.Type.SPRING, true, 20000); private final String _name; private final RewardType _rewardType; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java index f2629eb1f..066f34b48 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java @@ -1,5 +1,6 @@ package mineplex.core.treasure.animation; +import java.util.ArrayList; import java.util.List; import org.bukkit.Material; @@ -7,8 +8,10 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Skull; +import mineplex.core.common.MaterialData; import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; import mineplex.core.treasure.BlockInfo; import mineplex.core.treasure.Treasure; import mineplex.core.treasure.TreasureType; @@ -99,6 +102,10 @@ public class BlockChangeAnimation extends Animation mat = Material.WOOL; data = 13; } + else if (getTreasure().getTreasureType() == TreasureType.SPRING) + { + mat = Material.GRASS; + } else continue; @@ -151,6 +158,11 @@ public class BlockChangeAnimation extends Animation mat = Material.GOLD_BLOCK; data = 0; } + else if (getTreasure().getTreasureType() == TreasureType.SPRING) + { + mat = Material.DIRT; + data = 2; + } else continue; @@ -245,6 +257,27 @@ public class BlockChangeAnimation extends Animation } } } + else if (getTreasure().getTreasureType() == TreasureType.SPRING) + { + List materials = new ArrayList<>(); + materials.add(MaterialData.of(Material.LEAVES, (byte) 0)); + materials.add(MaterialData.of(Material.LEAVES, (byte) 1)); + materials.add(MaterialData.of(Material.LEAVES, (byte) 2)); + materials.add(MaterialData.of(Material.LEAVES, (byte) 3)); + materials.add(MaterialData.of(Material.LEAVES_2, (byte) 0)); + materials.add(MaterialData.of(Material.LEAVES_2, (byte) 1)); + for (Block c : _chests) + { + if (c.equals(b)) + { + _blockInfoList.add(new BlockInfo(b)); + int r = UtilMath.random.nextInt(materials.size()); + MaterialData materialData = materials.get(r); + b.setType(materialData.getMaterial()); + b.setData(materialData.getData()); + } + } + } } } @@ -256,7 +289,6 @@ public class BlockChangeAnimation extends Animation @Override protected void onFinish() { - } private byte getDirection(Block block) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java index 80eab149e..5a4378a48 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java @@ -1,22 +1,32 @@ package mineplex.core.treasure.animation; import java.awt.Color; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import net.minecraft.server.v1_8_R3.BlockPosition; import net.minecraft.server.v1_8_R3.MathHelper; +import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Item; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; import com.google.common.collect.Lists; import mineplex.core.Managers; +import mineplex.core.common.MaterialData; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; @@ -30,13 +40,14 @@ import mineplex.core.common.util.particles.ColoredParticle; import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.disguises.DisguiseBat; +import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.particleeffects.BabyFireworkEffect; import mineplex.core.particleeffects.CircleEffect; import mineplex.core.treasure.BlockInfo; import mineplex.core.treasure.Treasure; import mineplex.core.treasure.TreasureType; -public class ChestSpawnAnimation extends Animation +public class ChestSpawnAnimation extends Animation implements Listener { private static final int ANIMATION_DURATION = 80; @@ -47,6 +58,8 @@ public class ChestSpawnAnimation extends Animation private Location _particleLocation; private Vector _particleDirection; + private Location _openingCenter; + private List _chestBlockInfo; private double _radialOffset; @@ -58,6 +71,8 @@ public class ChestSpawnAnimation extends Animation private int _currentHauntedColor = 0; private List _bats = Lists.newArrayList(); + private List _flowers = new ArrayList<>(); + private List _droppedFlowers = new ArrayList<>(); public ChestSpawnAnimation(Treasure treasure, Block block, List chestBlockInfo, Block openingCenter, double radialOffset, JavaPlugin javaPlugin) { @@ -83,8 +98,10 @@ public class ChestSpawnAnimation extends Animation _centerLocation = block.getLocation().clone().add(0.5, 0.5, 0.5); _chestBlockInfo = chestBlockInfo; - _particleLocation = openingCenter.getLocation().add(0.5, 4, 0.5); - + _particleLocation = openingCenter.getLocation().clone().add(0.5, 4, 0.5); + + _openingCenter = openingCenter.getLocation(); + _particleDirection = UtilAlg.getTrajectory(_particleLocation, _centerLocation); _particleDirection.multiply(UtilMath.offset(_particleLocation, _centerLocation) / (double)ANIMATION_DURATION); @@ -103,6 +120,8 @@ public class ChestSpawnAnimation extends Animation _radialOffset = radialOffset; _javaPlugin = javaPlugin; + + Bukkit.getPluginManager().registerEvents(this, javaPlugin); } @Override @@ -112,7 +131,18 @@ public class ChestSpawnAnimation extends Animation //Move Particle Forwards _particleLocation.add(_particleDirection); - + + Iterator droppedFlowersIterator = _droppedFlowers.iterator(); + while (droppedFlowersIterator.hasNext()) + { + Item flower = droppedFlowersIterator.next(); + if (flower.getTicksLived() >= 20) + { + flower.remove(); + droppedFlowersIterator.remove(); + } + } + //Play Particles if (getTreasure().getTreasureType() == TreasureType.OLD || getTreasure().getTreasureType() == TreasureType.LOVE_CHEST) { @@ -246,10 +276,20 @@ public class ChestSpawnAnimation extends Animation doBats(true, _centerLocation.clone().add(0, 6, 0), _bats); } } - else if (getTreasure().getTreasureType() == TreasureType.ST_PATRICKS) + else if (getTreasure().getTreasureType() == TreasureType.SPRING) { - Location location = _centerLocation.clone().add(0, 5, 0); + if (getTicks() % 5 == 0) + { + if (_flowers.size() == 0) + generateFlowerList(); + int r = UtilMath.random.nextInt(_flowers.size()); + MaterialData materialData = _flowers.get(r); + Item flower = _openingCenter.getWorld().dropItem(_openingCenter.clone().add(0.5, 0, 0.5), ItemStackFactory.Instance.CreateStack(materialData.getMaterial(), materialData.getData(), 1, "Flower" + getTicks())); + Vector vel = new Vector(_openingCenter.getX() - _centerLocation.getX(), 0, _openingCenter.getZ() - _centerLocation.getZ()); + UtilAction.velocity(flower, vel, 0.1, false, 0, 0.2 + 1 * 0.4, 1, false); + _droppedFlowers.add(flower); + } } //Spawn Chest @@ -338,7 +378,12 @@ public class ChestSpawnAnimation extends Animation @Override protected void onFinish() { - + HandlerList.unregisterAll(this); + for (Item item : _droppedFlowers) + { + item.remove(); + } + _droppedFlowers.clear(); } private void doBats(boolean initial, Location center, List bats) @@ -372,4 +417,34 @@ public class ChestSpawnAnimation extends Animation } } } + + private void generateFlowerList() + { + _flowers.add(MaterialData.of(Material.LONG_GRASS, (byte) 1)); + _flowers.add(MaterialData.of(Material.LONG_GRASS, (byte) 2)); + _flowers.add(MaterialData.of(Material.DEAD_BUSH, (byte) 0)); + _flowers.add(MaterialData.of(Material.YELLOW_FLOWER, (byte) 0)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 0)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 1)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 2)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 3)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 4)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 5)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 6)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 7)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 8)); + _flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 0)); + _flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 1)); + _flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 2)); + _flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 3)); + _flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 4)); + _flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 5)); + } + + @EventHandler + public void onPickup(PlayerPickupItemEvent event) + { + if (_droppedFlowers.contains(event.getItem())) + event.setCancelled(true); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/TreasureRemoveAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/TreasureRemoveAnimation.java index c0ada9705..21bbad471 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/TreasureRemoveAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/TreasureRemoveAnimation.java @@ -1,5 +1,6 @@ package mineplex.core.treasure.animation; +import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -9,7 +10,9 @@ import org.bukkit.entity.Item; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import mineplex.core.common.MaterialData; import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilMath; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.treasure.BlockInfo; import mineplex.core.treasure.Treasure; @@ -20,6 +23,7 @@ public class TreasureRemoveAnimation extends Animation private Random _random = new Random(); private List _otherChests; private int _count = 0; + private List _flowers = new ArrayList<>(); public TreasureRemoveAnimation(Treasure treasure, List otherChests) { @@ -42,6 +46,19 @@ public class TreasureRemoveAnimation extends Animation dropItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_NUGGET, (byte) 0, 1, "DroppedNugget" + _count), info); _count++; } + else if (getTreasure().getTreasureType() == TreasureType.SPRING) + { + // Drops random flower + if (_flowers.size() == 0) + generateFlowerList(); + + int r = UtilMath.random.nextInt(_flowers.size()); + MaterialData materialData = _flowers.get(r); + dropItem(ItemStackFactory.Instance.CreateStack(materialData.getMaterial(), materialData.getData(), 1, "Flower" + _count), info); + _count++; + info.getBlock().setType(Material.AIR); + info.getBlock().setData((byte) 0); + } } else { @@ -60,6 +77,29 @@ public class TreasureRemoveAnimation extends Animation getTreasure().getTreasureManager().addItem(item); } + private void generateFlowerList() + { + _flowers.add(MaterialData.of(Material.LONG_GRASS, (byte) 1)); + _flowers.add(MaterialData.of(Material.LONG_GRASS, (byte) 2)); + _flowers.add(MaterialData.of(Material.DEAD_BUSH, (byte) 0)); + _flowers.add(MaterialData.of(Material.YELLOW_FLOWER, (byte) 0)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 0)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 1)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 2)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 3)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 4)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 5)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 6)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 7)); + _flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 8)); + _flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 0)); + _flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 1)); + _flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 2)); + _flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 3)); + _flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 4)); + _flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 5)); + } + @Override protected void onFinish() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java index 087374d5d..c119b1ae2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java @@ -83,6 +83,32 @@ public class BuyChestButton implements IButton return; } } + if (_chestType == TreasureType.ST_PATRICKS) + { + if (!new File("../../update/files/EnableStPatricksChest.dat").exists()) + { + player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); + return; + } + if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) + { + player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!")); + return; + } + } + if (_chestType == TreasureType.SPRING) + { + if (!new File("../../update/files/EnableSpringChest.dat").exists()) + { + player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!")); + return; + } + if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) + { + player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!")); + return; + } + } if (_chestType == TreasureType.FREEDOM || _chestType == TreasureType.HAUNTED) { if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java index ac82b4b25..030e3dc1d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -138,6 +138,7 @@ public class TreasurePage extends ShopPageBase int minestrikeCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.MINESTRIKE.getItemName()); int loveCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.LOVE_CHEST.getItemName()); int stpatricksCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.ST_PATRICKS.getItemName()); + int springCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.SPRING.getItemName()); boolean availableChristmas = false; boolean availableFreedom = false; @@ -147,6 +148,7 @@ public class TreasurePage extends ShopPageBase boolean availableGingerbread = false; boolean availableLove = false; boolean availableStPatricks = new File("../../update/files/EnableStPatricksChest.dat").exists(); + boolean availableSpring = new File("../../update/files/EnableSpringChest.dat").exists(); List shardLore = new ArrayList<>(); shardLore.add(" "); @@ -427,12 +429,36 @@ public class TreasurePage extends ShopPageBase } else { - stpatricksLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + TreasureType.LOVE_CHEST.getPurchasePrice() + " Treasure Shards"); + stpatricksLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + TreasureType.ST_PATRICKS.getPurchasePrice() + " Treasure Shards"); stpatricksLore.add(" "); stpatricksLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop"); } } + List springLore = Lists.newArrayList(); + springLore.add(" "); + springLore.add(F.value("Spring Chests Owned", "" + springCount)); + springLore.add(" "); + springLore.addAll(UtilText.splitLines(new String[]{C.cGray + "Spring is here! Find 6 limited edition Spring Cosmetics in the Spring Chest! Only available for a limited time. Guaranteed no Duplicate items!"}, LineFormat.LORE)); + springLore.add(" "); + if (springCount > 0) + { + springLore.add(C.cGreen + "Click to Open!"); + } + else + { + if (!availableSpring) + { + springLore.add(C.cRed + "This item is no longer available"); + } + else + { + springLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + TreasureType.SPRING.getPurchasePrice() + " Treasure Shards"); + springLore.add(" "); + springLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop"); + } + } + ShopItem shards = new ShopItem(Material.PRISMARINE_SHARD, C.cAqua + C.Bold + treasureShards + " Treasure Shards", shardLore.toArray(new String[0]), 0, false); // Normal chests @@ -452,6 +478,7 @@ public class TreasurePage extends ShopPageBase ItemStack gingerbread = SkinData.GINGERBREAD.getSkull(C.cRedB + "Gingerbread" + C.cGreenB + " Treasure", gingerbreadLore); ItemStack lovechest = new ShopItem(Material.WOOL, (byte) 6, C.cRedB + "Love Chest", lovechestLore.toArray(new String[0]), 0, false, false); ItemStack stpatricks = SkinData.LEPRECHAUN.getSkull(C.cGreenB + "St Patrick's Treasure", stpatricksLore); + ItemStack spring = new ShopItem(Material.DOUBLE_PLANT, (byte) 4, C.cGreenB + "Spring Treasure", springLore.toArray(new String[0]), 1, false, false); // Adds shard item addItem(49, shards); @@ -475,6 +502,7 @@ public class TreasurePage extends ShopPageBase TreasurePageItem gingerbreadTreasureItem = new TreasurePageItem(gingerbread, gingerbreadCount, TreasureType.GINGERBREAD); TreasurePageItem loveChestItem = new TreasurePageItem(lovechest, loveCount, TreasureType.LOVE_CHEST); TreasurePageItem stPatricksItem = new TreasurePageItem(stpatricks, stpatricksCount, TreasureType.ST_PATRICKS); + TreasurePageItem springItem = new TreasurePageItem(spring, springCount, TreasureType.SPRING); _normalTreasures.add(oldTreasureItem); _normalTreasures.add(ancientTreasureItem); @@ -483,6 +511,12 @@ public class TreasurePage extends ShopPageBase _normalTreasures.add(omegaTreasureItem); _normalTreasures.add(minestrikeTreasureItem); + + if (availableSpring) + _specialTreasures.add(springItem); + else + _seasonalTreasures.add(springItem); + if (availableStPatricks) _specialTreasures.add(stPatricksItem); else diff --git a/Plugins/Mineplex.Core/src/mineplex/core/utils/UtilGameProfile.java b/Plugins/Mineplex.Core/src/mineplex/core/utils/UtilGameProfile.java index 5ee0a41ce..17a6bc447 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/utils/UtilGameProfile.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/utils/UtilGameProfile.java @@ -110,7 +110,7 @@ public class UtilGameProfile } // Pattern to remove all non alphanumeric + underscore letters - private static final Pattern LEGAL_USERNAME = Pattern.compile("[^A-Za-z0-9_]"); + private static final Pattern LEGAL_USERNAME = Pattern.compile("[^a-z0-9_]", Pattern.CASE_INSENSITIVE); /** * Convert a string to a legal username equivalent diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index 565300ef3..4ce00640d 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -19,9 +19,9 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.entity.Creature; import org.bukkit.entity.Egg; import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -1005,14 +1005,17 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter UtilTextTop.display(text, UtilServer.getPlayers()); //Fix Entity Names - for (Creature pet : _petManager.getPets()) + for (Entity pet : _petManager.getPets()) { - DisguiseBase disguise = _disguiseManager.getDisguise(pet); - - if (disguise instanceof DisguiseWither) + if (pet instanceof LivingEntity) { - ((DisguiseWither) disguise).setName(text); - disguise.resendMetadata(); + DisguiseBase disguise = _disguiseManager.getDisguise((LivingEntity) pet); + + if (disguise instanceof DisguiseWither) + { + ((DisguiseWither) disguise).setName(text); + disguise.resendMetadata(); + } } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index c01ec5d2b..1e7dfd060 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -4,13 +4,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.UUID; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.HoverEvent.Action; -import net.md_5.bungee.api.chat.TextComponent; -import net.minecraft.server.v1_8_R3.EntityInsentient; -import net.minecraft.server.v1_8_R3.EntityPlayer; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -48,7 +41,6 @@ import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antispam.AntiSpamManager; -import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.benefit.BenefitManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.bonuses.BonusManager; @@ -121,6 +113,7 @@ import mineplex.hub.commands.ForcefieldRadius; import mineplex.hub.commands.GadgetToggle; import mineplex.hub.commands.GameModeCommand; import mineplex.hub.commands.NewsCommand; +import mineplex.hub.modules.EasterEggHunt; import mineplex.hub.modules.ForcefieldManager; import mineplex.hub.modules.HubVisibilityManager; import mineplex.hub.modules.JumpManager; @@ -138,6 +131,12 @@ import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.condition.ConditionManager; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.HoverEvent.Action; +import net.md_5.bungee.api.chat.TextComponent; +import net.minecraft.server.v1_8_R3.EntityInsentient; +import net.minecraft.server.v1_8_R3.EntityPlayer; public class HubManager extends MiniClientPlugin implements IChatMessageFormatter { @@ -177,6 +176,8 @@ public class HubManager extends MiniClientPlugin implements IChatMess // private TrickOrTreatManager _trickOrTreatManager; private MavericksManager _mavericksManager; private final TwoFactorAuth _twofactor = Managers.require(TwoFactorAuth.class); + + private HologramManager _hologramManager; private Location _spawn; @@ -283,6 +284,10 @@ public class HubManager extends MiniClientPlugin implements IChatMess new SalesAnnouncementManager(plugin); new CommunityManager(plugin, _clientManager); + + _hologramManager = hologramManager; + + new EasterEggHunt(plugin, _clientManager); ScoreboardManager scoreboardManager = new ScoreboardManager(plugin) { @@ -781,6 +786,11 @@ public class HubManager extends MiniClientPlugin implements IChatMess { return _disguiseManager; } + + public HologramManager getHologram() + { + return _hologramManager; + } public GadgetManager GetGadget() { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/EggAddCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/EggAddCommand.java new file mode 100644 index 000000000..277136334 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/EggAddCommand.java @@ -0,0 +1,28 @@ +package mineplex.hub.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.hub.modules.EasterEggHunt; + +public class EggAddCommand extends CommandBase +{ + public EggAddCommand(EasterEggHunt plugin) + { + super(plugin, Rank.ADMIN, "addegg"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: /addegg ")); + return; + } + Plugin.addEgg(caller, args[0]); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/EasterEggHunt.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/EasterEggHunt.java new file mode 100644 index 000000000..29db6d3fc --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/EasterEggHunt.java @@ -0,0 +1,390 @@ +package mineplex.hub.modules; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.SkullType; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.Skull; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; + +import mineplex.core.Managers; +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.donation.DonationManager; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.HologramInteraction; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.HubManager; +import mineplex.hub.commands.EggAddCommand; +import mineplex.hub.modules.EasterEggHunt.EasterEggHunter; +import mineplex.serverdata.database.DBPool; + +public class EasterEggHunt extends MiniDbClientPlugin +{ + private static final int SHARD_REWARD = 500; + private static final String ITEM_REWARD = "Omega Chest"; + private static final int EGGS_PER_DAY = 30; + + private static final BlockFace[] BLOCK_FACES = { + BlockFace.NORTH, + BlockFace.EAST, + BlockFace.SOUTH, + BlockFace.WEST, + BlockFace.NORTH_EAST, + BlockFace.SOUTH_EAST, + BlockFace.SOUTH_WEST, + BlockFace.NORTH_WEST + }; + + private static final String[] EGG_SKINS = { + "KingCrazy_", + "Trajectories" + }; + + private final DonationManager _donationManager; + private final InventoryManager _inventoryManager; + private final List _possibleEggs; + + public EasterEggHunt(JavaPlugin plugin, CoreClientManager clientManager) + { + super("Egg Hunt", plugin, clientManager); + + _donationManager = Managers.get(DonationManager.class); + _inventoryManager = Managers.get(InventoryManager.class); + + _possibleEggs = new ArrayList<>(); + runAsync(() -> + { + final List fetch = new ArrayList<>(); + loadEggs(fetch); + runSync(() -> + { + fetch.stream().peek(EasterEgg::setup).forEach(_possibleEggs::add); + }); + }); + + addCommand(new EggAddCommand(this)); + } + + private String vecToStr(Vector vec) + { + return vec.getX() + "," + vec.getY() + "," + vec.getZ(); + } + + private Vector strToVec(String str) + { + String[] coords = str.split(","); + double x = Double.parseDouble(coords[0]); + double y = Double.parseDouble(coords[1]); + double z = Double.parseDouble(coords[2]); + + return new Vector(x, y, z); + } + + private void loadEggs(List eggs) + { + try (Connection c = DBPool.getAccount().getConnection()) + { + ResultSet rs = c.prepareStatement("SELECT * FROM easterEggs;").executeQuery(); + while (rs.next()) + { + EasterEgg egg = new EasterEgg(rs.getInt("id"), strToVec(rs.getString("eggLocation")), rs.getDate("eggDate")); + eggs.add(egg); + } + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + + private void addEggToInventory(int accountId, int eggId) + { + runAsync(() -> + { + try (Connection c = DBPool.getAccount().getConnection()) + { + PreparedStatement ps = c.prepareStatement("INSERT INTO accountEggs (accountId, eggId) VALUES (?, ?);"); + ps.setInt(1, accountId); + ps.setInt(2, eggId); + ps.execute(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + }); + } + + @EventHandler + public void interactBlock(PlayerInteractEvent event) + { + if (event.getClickedBlock() == null) + { + return; + } + + Player player = event.getPlayer(); + + for (EasterEgg egg : _possibleEggs) + { + if (egg.isMe(event.getClickedBlock())) + { + findEgg(player, egg.getId()); + event.setCancelled(true); + break; + } + } + } + + @EventHandler + public void refreshEggs(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC) + { + LocalDate currentDate = LocalDate.now(); + + _possibleEggs.stream().filter(EasterEgg::isSpawned).filter(egg -> + { + LocalDate eggDate = egg.getDate().toLocalDate(); + + return eggDate.getDayOfYear() != currentDate.getDayOfYear(); + }).forEach(egg -> + { + egg.despawn(); + GetValues().forEach(hunter -> hunter.getEggs().remove(egg.getId())); + }); + _possibleEggs.stream().filter(egg -> !egg.isSpawned()).filter(egg -> + { + LocalDate eggDate = egg.getDate().toLocalDate(); + + return eggDate.getDayOfYear() == currentDate.getDayOfYear(); + }).forEach(EasterEgg::spawn); + } + } + + public void addEgg(Player player, String date) + { + final Date parsed = Date.valueOf(date); + final Vector loc = player.getLocation().toVector(); + runAsync(() -> + { + try (Connection c = DBPool.getAccount().getConnection()) + { + PreparedStatement ps = c.prepareStatement("INSERT INTO easterEggs (eggLocation, eggDate) VALUES (?, ?);"); + ps.setString(1, vecToStr(loc)); + ps.setDate(2, parsed); + ps.execute(); + + PreparedStatement ret = c.prepareStatement("SELECT COUNT(id) FROM easterEggs WHERE eggDate=?;"); + ret.setDate(1, parsed); + ResultSet rs = ret.executeQuery(); + if (rs.next()) + { + UtilPlayer.message(player, F.main(getName(), "There are " + rs.getInt(1) + " eggs saved for " + date + "!")); + } + } + catch (SQLException e) + { + e.printStackTrace(); + } + }); + } + + private void findEgg(Player player, Integer eggId) + { + if (Get(player).getEggs().contains(eggId)) + { + UtilPlayer.message(player, F.main(getName(), "You have already found this egg! There are " + F.count(EGGS_PER_DAY - Get(player).getEggs().size()) + " more eggs to find today!")); + return; + } + player.playSound(player.getLocation(), Sound.CAT_MEOW, 1, 0.7F); + Get(player).findEgg(eggId); + UtilPlayer.message(player, F.main(getName(), "Found " + F.count(Get(player).getEggs().size()) + "/" + F.count(EGGS_PER_DAY) + " Easter Eggs +" + F.currency(GlobalCurrency.TREASURE_SHARD, SHARD_REWARD) + ".")); + _donationManager.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, player, "", SHARD_REWARD); + addEggToInventory(ClientManager.getAccountId(player), eggId); + + if (Get(player).getEggs().size() == 1) + { + UtilPlayer.message(player, F.main(getName(), "There are " + F.count(EGGS_PER_DAY) + " hidden " + F.elem("Easter Eggs") + " to find through the lobby each day.")); + UtilPlayer.message(player, F.main(getName(), "Each one is worth " + F.currency(GlobalCurrency.TREASURE_SHARD, SHARD_REWARD) + ".")); + UtilPlayer.message(player, F.main(getName(), "If you find all " + F.count(EGGS_PER_DAY) + " you will receive an " + C.cAqua + "Omega Chest for that day!")); + } + else if (Get(player).getEggs().size() == EGGS_PER_DAY) + { + UtilPlayer.message(player, F.main(getName(), "You have found all the eggs available today!")); + + _inventoryManager.addItemToInventory(success -> + { + if (success) + { + UtilPlayer.message(player, F.main(getName(), "+1 " + C.cAqua + ITEM_REWARD + C.mBody + "!")); + } + else + { + UtilPlayer.message(player, F.main(getName(), "Oh no! An error occurred while trying to give you your chest! Go find a staff member ASAP!")); + } + }, player, ITEM_REWARD, 1); + } + } + + public static class EasterEggHunter + { + private List _found; + + public EasterEggHunter() + { + this(new ArrayList<>()); + } + + public EasterEggHunter(List foundEggs) + { + _found = foundEggs; + } + + public List getEggs() + { + return _found; + } + + public void findEgg(Integer id) + { + _found.add(id); + } + } + + public static class EasterEgg + { + private final Integer _id; + private final Vector _loc; + private final Date _date; + private boolean _spawned; + private Location _spawn; + private Hologram _holo; + + public EasterEgg(Integer id, Vector loc, Date date) + { + _id = id; + _loc = loc; + _date = date; + _spawned = false; + } + + public Integer getId() + { + return _id; + } + + public Date getDate() + { + return _date; + } + + public boolean isSpawned() + { + return _spawned; + } + + public boolean isMe(Block block) + { + return isSpawned() && UtilWorld.locToStr(block.getLocation()).equals(UtilWorld.locToStr(_spawn.getBlock().getLocation())); + } + + public void setup() + { + _spawn = _loc.toLocation(Managers.get(HubManager.class).GetSpawn().getWorld()); + _spawned = false; + _holo = new Hologram(Managers.get(HubManager.class).getHologram(), _spawn.clone().add(0, 1.5, 0), C.cDPurple + C.Scramble + "ABC " + C.cPurpleB + "Easter Egg Hunt" + C.cDPurple + C.Scramble + " ABC"); + _holo.setViewDistance(4); + _holo.setInteraction(new HologramInteraction() + { + @Override + public void onClick(Player player, ClickType clickType) + { + Managers.get(EasterEggHunt.class).findEgg(player, getId()); + } + }); + _holo.stop(); + } + + @SuppressWarnings("deprecation") + public void spawn() + { + if (isSpawned()) + { + return; + } + _spawn.getBlock().setType(Material.SKULL); + _spawn.getBlock().setData((byte) 1); + Skull skull = (Skull) _spawn.getBlock().getState(); + skull.setSkullType(SkullType.PLAYER); + skull.setOwner(EGG_SKINS[UtilMath.r(EGG_SKINS.length)]); + skull.setRotation(BLOCK_FACES[UtilMath.r(BLOCK_FACES.length)]); + skull.update(); + _holo.start(); + _spawned = true; + } + + public void despawn() + { + if (isSpawned()) + { + _spawn.getBlock().setType(Material.AIR); + _spawned = false; + _holo.stop(); + } + } + } + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT ae.eggId, ee.eggDate FROM accountEggs AS ae INNER JOIN easterEggs AS ee ON ae.eggId=ee.id WHERE ae.accountId=" + accountId + ";"; + } + + @Override + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException + { + List found = new ArrayList<>(); + while (resultSet.next()) + { + if (resultSet.getDate("eggDate").toLocalDate().getDayOfYear() == LocalDate.now().getDayOfYear()) + { + found.add(resultSet.getInt("eggId")); + } + } + + Set(uuid, new EasterEggHunter(found)); + } + + @Override + protected EasterEggHunter addPlayer(UUID uuid) + { + return new EasterEggHunter(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java index 0679e29ba..74febb1a9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java @@ -3,6 +3,14 @@ package mineplex.hub.modules; import java.util.HashMap; import java.util.Iterator; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; + import mineplex.core.MiniPlugin; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -26,13 +34,6 @@ import mineplex.hub.HubManager; import mineplex.hub.HubRepository; import mineplex.hub.HubType; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Creature; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; - public class NewsManager extends MiniPlugin { public HubManager Manager; @@ -347,14 +348,17 @@ public class NewsManager extends MiniPlugin UtilTextTop.display(text, UtilServer.getPlayers()); //Fix Entity Names - for (Creature pet : Manager.getPetManager().getPets()) + for (Entity pet : Manager.getPetManager().getPets()) { - DisguiseBase disguise = Manager.GetDisguise().getDisguise(pet); - - if (disguise instanceof DisguiseWither) + if (pet instanceof LivingEntity) { - ((DisguiseWither) disguise).setName(text); - disguise.resendMetadata(); + DisguiseBase disguise = Manager.GetDisguise().getDisguise((LivingEntity) pet); + + if (disguise instanceof DisguiseWither) + { + ((DisguiseWither) disguise).setName(text); + disguise.resendMetadata(); + } } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index 97e5c11a0..a305c124b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -747,7 +747,7 @@ public class ServerManager extends MiniPlugin implements BrawlShopProvider public ServerNpcShop getBetaShop() { - return _serverNpcShopMap.get("Skyfall BETA"); + return _serverNpcShopMap.get("Skyfall"); } public ServerNpcShop getUHCShop() diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index 33c41236a..0253eaa66 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -3,20 +3,40 @@ package mineplex.hub.server.ui; import java.util.ArrayList; import java.util.List; -import mineplex.core.boosters.Booster; -import mineplex.core.shop.item.IButton; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; +import mineplex.core.boosters.Booster; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.shop.item.IButton; import mineplex.core.shop.page.ShopPageBase; import mineplex.hub.server.ServerManager; -import mineplex.hub.server.ui.button.*; +import mineplex.hub.server.ui.button.SelectBETAButton; +import mineplex.hub.server.ui.button.SelectBHButton; +import mineplex.hub.server.ui.button.SelectBLDButton; +import mineplex.hub.server.ui.button.SelectBRButton; +import mineplex.hub.server.ui.button.SelectBawkButton; +import mineplex.hub.server.ui.button.SelectCLANSButton; +import mineplex.hub.server.ui.button.SelectCSButton; +import mineplex.hub.server.ui.button.SelectCTFButton; +import mineplex.hub.server.ui.button.SelectDMTButton; +import mineplex.hub.server.ui.button.SelectDOMButton; +import mineplex.hub.server.ui.button.SelectFEATButton; +import mineplex.hub.server.ui.button.SelectMINButton; +import mineplex.hub.server.ui.button.SelectMSButton; +import mineplex.hub.server.ui.button.SelectPLAYERButton; +import mineplex.hub.server.ui.button.SelectSBButton; +import mineplex.hub.server.ui.button.SelectSGButton; +import mineplex.hub.server.ui.button.SelectSKYButton; +import mineplex.hub.server.ui.button.SelectSSMButton; +import mineplex.hub.server.ui.button.SelectTDMButton; +import mineplex.hub.server.ui.button.SelectUHCButton; +import mineplex.hub.server.ui.button.SelectWIZButton; public class ServerGameMenu extends ShopPageBase { @@ -94,13 +114,13 @@ public class ServerGameMenu extends ShopPageBase C.Reset + "Win! Fight! Send enemies flying in Skywars!", }, new String[] {"SKY", "SKY2"}, "Skywars", new SelectSKYButton(this)); - add(15, Material.GOLDEN_APPLE, C.cYellowB + "UHC " + C.cGray + "Ultra Hardcore Mode", new String[] + add(15, Material.GOLDEN_APPLE, (byte) 0, C.cYellowB + "UHC " + C.cGray + "Ultra Hardcore Mode", new String[] { C.Reset + "", C.Reset + "Extremely hard team-based survival ", C.Reset + "Gather materials and fight your way", C.Reset + "to become the last team standing!", - }, "UHC", "UHC", new SelectUHCButton(this)); + }, new String[] {"UHC", "UHC2", "UHCS", "UHCS2"}, "UHC", new SelectUHCButton(this)); add(17, Material.BLAZE_ROD, C.cYellowB + "Wizards " + C.cGray + "Last Man Standing", new String[] { @@ -197,15 +217,14 @@ public class ServerGameMenu extends ShopPageBase C.Reset + "and raid others!", }, "Clans", null, new SelectCLANSButton(this)); - add(41, Material.BREWING_STAND_ITEM, C.cYellowB + "Skyfall " + C.cGray + "Elytra Game", new String[] + add(41, Material.DIAMOND_BOOTS, (byte)0, C.cYellowB + "Skyfall " + C.cGray + "Elytra Game", new String[] { - (_extraValue ? C.cAquaB : C.cWhiteB) + "BETA GAME", C.Reset + "", C.Reset + "1.9 Game, 1.8 PVP", C.Reset + "Fly through sky islands,", C.Reset + "collect gear and defeat", C.Reset + "all enemies.", - }, "BETA", "Beta_Games", new SelectBETAButton(this)); + }, new String[]{"SF","SF2"}, "Beta_Games", new SelectBETAButton(this)); } private void add(int slot, Material material, String title, String[] lore, String serverTag, String boosterGroup, IButton button) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java index 107f9fb16..eb087afa5 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java @@ -36,6 +36,9 @@ public class ServerNpcShop extends ShopBase case "UHC": return new UHCServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player); + case "SF": + return new SkyfallServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player); + default: return new ServerNpcPage(getPlugin(), this, getClientManager(), getDonationManager(), _serverGroup.getServerNpcName(), player, _serverGroup.getPrefix()); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SkyfallServerTypePage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SkyfallServerTypePage.java new file mode 100644 index 000000000..893437bce --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/SkyfallServerTypePage.java @@ -0,0 +1,48 @@ +package mineplex.hub.server.ui; + +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.hub.server.ServerManager; + +public class SkyfallServerTypePage extends ShopPageBase +{ + public SkyfallServerTypePage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Skyfall", player, 27); + + buildPage(); + } + + @Override + protected void buildPage() + { + setItem(12, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.Reset + C.cYellow + "Skyfall Solo") + .addLore(new String[] + { + C.Reset + "", + C.Reset + C.cGreen + "Click to Play", + }).build()); + + setItem(14, new ItemBuilder(Material.SKULL_ITEM, 2, (byte) 3).setTitle(C.Reset + C.cYellow + "Skyfall Teams") + .addLore(new String[] + { + C.Reset + "", + C.Reset + C.cGreen + "Click to Play" + }).build()); + + getButtonMap().put(12, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Skyfall Solo", player, "SF"))); + getButtonMap().put(14, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Skyfall Teams", player, "SF2"))); + } + + public void Update() + { + getButtonMap().clear(); + buildPage(); + } +} diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index 78526833a..c6597f877 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -92,12 +92,12 @@ public class StaffServer extends JavaPlugin ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("377bdea3-badc-448d-81c1-65db43b17ea4"), "Strutt20")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("cf1b629c-cc55-4eb4-be9e-3ca86dfc7b9d"), "mannalou")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("adaa7613-6683-400f-baf8-7272c04b2cb4"), "Tmmy")); - ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("231fb752-9556-489b-8428-f47c7598e061"), "Nuclear_Poptart")); - ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("492ff708-fe76-4c5a-b9ed-a747b5fa20a0"), "Cherdy8s")); + ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("492ff708-fe76-4c5a-b9ed-a747b5fa20a0"), "cherdy")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("6edf17d5-6bb2-4ed9-92e9-bed8e96fff68"), "BlueBeetleHD")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("a47a4d04-9f51-44ba-9d35-8de6053e9289"), "AlexTheCoder")); ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("63ad2db3-7c62-4a10-ac58-d267973190ce"), "Crumplex")); + ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("a47a4d04-9f51-44ba-9d35-8de6053e9289"), "AlexTheCoder")); ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("cf1b629c-cc55-4eb4-be9e-3ca86dfc7b9d"), "mannalou")); ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("377bdea3-badc-448d-81c1-65db43b17ea4"), "Strutt20")); ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("6edf17d5-6bb2-4ed9-92e9-bed8e96fff68"), "BlueBeetleHD")); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index c5b819fcf..dceba28ab 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -167,6 +167,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable int minestrikeChestsReceived = 0; int loveChestsReceived = 0; int stPatricksChestReceived = 0; + int springChestsReceived = 0; for (CoinTransactionToken transaction : donor.getCoinTransactions()) { @@ -330,6 +331,16 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable stPatricksChestReceived += 1; } } + if (transaction.SalesPackageName.startsWith("Spring Chest")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 3) + springChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]); + else if (transaction.SalesPackageName.split(" ").length == 2) + springChestsReceived += 1; + } + } if (transaction.SalesPackageName.startsWith("Valentines Gift")) { if (transaction.Coins == 0 && transaction.Gems == 0) @@ -403,6 +414,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cBlue + "Gingerbread Chests Received: " + C.cYellow + gingerbreadChestsReceived + " " + C.cBlue + "Minestrike Chests Received: " + C.cYellow + minestrikeChestsReceived); caller.sendMessage(C.cBlue + "Love Chests Received: " + C.cYellow + loveChestsReceived); caller.sendMessage(C.cBlue + "St Patrick's Chests Received: " + C.cYellow + stPatricksChestReceived); + caller.sendMessage(C.cBlue + "Spring Chests Received: " + C.cYellow + springChestsReceived); caller.sendMessage(C.cBlue + "Game Amplifiers Received: " + C.cYellow + boostersReceived); caller.sendMessage(C.cBlue + "Rune Amplifiers (20 min/60 min) Received: " + C.cYellow + runeAmplifier20 + "/" + runeAmplifier60); caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Usage") + " " + C.cBlue + "Clan Banner Editor: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Editor")); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java index c1809951d..2f8d3f15f 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/SalesPackageManager.java @@ -39,6 +39,7 @@ import mineplex.staffServer.salespackage.salespackages.Pet; import mineplex.staffServer.salespackage.salespackages.PowerPlayClub; import mineplex.staffServer.salespackage.salespackages.RuneAmplifier; import mineplex.staffServer.salespackage.salespackages.SalesPackageBase; +import mineplex.staffServer.salespackage.salespackages.SpringChest; import mineplex.staffServer.salespackage.salespackages.StPatricksChest; import mineplex.staffServer.salespackage.salespackages.ThankfulChest; import mineplex.staffServer.salespackage.salespackages.TrickOrTreatChest; @@ -102,6 +103,7 @@ public class SalesPackageManager extends MiniPlugin AddSalesPackage(new MinestrikeChest(this)); AddSalesPackage(new LoveChest(this)); AddSalesPackage(new StPatricksChest(this)); + AddSalesPackage(new SpringChest(this)); AddSalesPackage(new TrickOrTreatChest(this)); AddSalesPackage(new ThankfulChest(this)); @@ -173,7 +175,8 @@ public class SalesPackageManager extends MiniPlugin coinBuilder = coinBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); } else if (salesPackage instanceof MythicalChest || salesPackage instanceof AncientChest || salesPackage instanceof OldChest || salesPackage instanceof IlluminatedChest || salesPackage instanceof FreedomChest || salesPackage instanceof HauntedChest || salesPackage instanceof TrickOrTreatChest - || salesPackage instanceof ThankfulChest || salesPackage instanceof GingerbreadChest || salesPackage instanceof MinestrikeChest || salesPackage instanceof LoveChest || salesPackage instanceof StPatricksChest) + || salesPackage instanceof ThankfulChest || salesPackage instanceof GingerbreadChest || salesPackage instanceof MinestrikeChest || salesPackage instanceof LoveChest || salesPackage instanceof StPatricksChest + || salesPackage instanceof SpringChest) { chestBuilder = chestBuilder.extra("[").color("gray").extra(salesPackage.getName()).color("green").click("run_command", "/display " + playerName + " " + salesPackage.getName()).extra("] ").color("gray"); } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/SpringChest.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/SpringChest.java new file mode 100644 index 000000000..181fe34e6 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/SpringChest.java @@ -0,0 +1,21 @@ +package mineplex.staffServer.salespackage.salespackages; + +import org.bukkit.entity.Player; + +import mineplex.staffServer.salespackage.SalesPackageManager; + +public class SpringChest extends SalesPackageBase +{ + public SpringChest(SalesPackageManager manager) + { + super(manager, "1 Spring Chest"); + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales item " + playerName + " 1 Item Spring Chest", "Give 1 Spring Chest."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} + 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 68e92af90..26a762345 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -7,7 +7,10 @@ import mineplex.core.aprilfools.AprilFoolsManager; import net.minecraft.server.v1_8_R3.MinecraftServer; import org.bukkit.Bukkit; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.plugin.ServicePriority; import org.bukkit.plugin.java.JavaPlugin; import org.spigotmc.SpigotConfig; @@ -19,6 +22,7 @@ import mineplex.core.TwitchIntegrationFix; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; +import mineplex.core.antihack.RelationProvider; import mineplex.core.antihack.logging.AntihackLogger; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; @@ -80,6 +84,7 @@ import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; import nautilus.game.arcade.anticheatmetadata.GameInfoMetadata; +import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameServerConfig; import static mineplex.core.Managers.require; @@ -97,6 +102,26 @@ public class Arcade extends JavaPlugin @Override public void onEnable() { + getServer().getServicesManager().register(RelationProvider.class, new RelationProvider() + { + @Override + public boolean canDamage(Player player, Entity target) + { + if (target instanceof Player) + { + return _gameManager.canHurt(player, (Player) target); + } + else if (target instanceof LivingEntity) + { + return _gameManager.GetGame() != null && _gameManager.GetGame().GetState() == Game.GameState.Live; + } + else + { + return false; + } + } + }, this, ServicePriority.Normal); + Bukkit.setSpawnRadius(0); //Delete Old Games Folders DeleteFolders(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/TauntCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/TauntCommand.java index bc17eb83d..af64ce746 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/TauntCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/TauntCommand.java @@ -7,9 +7,8 @@ import mineplex.core.Managers; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; import mineplex.core.gadget.event.TauntCommandEvent; -import mineplex.core.gadget.gadgets.taunts.GameType; +import mineplex.core.game.GameDisplay; import mineplex.minecraft.game.core.combat.CombatManager; import nautilus.game.arcade.ArcadeManager; @@ -29,21 +28,16 @@ public class TauntCommand extends CommandBase @Override public void Execute(Player player, String[] args) { - boolean pvp = false; CombatManager combatManager = Managers.get(CombatManager.class); - if (combatManager != null) - { - pvp = UtilTime.elapsed(combatManager.Get(player).GetLastCombatEngaged(), 5000 * 60); - } Game game = _arcadeManager.GetGame(); - GameType gameType = GameType.NONE; + GameDisplay gameDisplay = null; if (game != null) { - gameType = GameType.valueOf(game.GetType().toString().toUpperCase()); + gameDisplay = game.GetType().getDisplay(); } TauntCommandEvent event = new TauntCommandEvent(player, _arcadeManager.isGameInProgress(), _arcadeManager.GetGame().IsAlive(player), UtilPlayer.isSpectator(player), combatManager.Get(player).GetLastCombatEngaged(), - gameType); + gameDisplay); Bukkit.getPluginManager().callEvent(event); } 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 458b9aedb..89fe831d5 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 @@ -13,9 +13,9 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; -import mineplex.core.lifetimes.Lifetimed; -import mineplex.core.lifetimes.ListenerComponent; -import mineplex.core.lifetimes.PhasedLifetime; +import net.minecraft.server.v1_8_R3.EntityItem; +import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; + import org.apache.commons.lang3.tuple.Triple; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -33,7 +33,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.ItemSpawnEvent; @@ -52,6 +51,8 @@ import com.mojang.authlib.GameProfile; import mineplex.core.Managers; import mineplex.core.antihack.AntiHack; +import mineplex.core.arcadeevents.CoreGameStartEvent; +import mineplex.core.arcadeevents.CoreGameStopEvent; import mineplex.core.command.CommandCenter; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -68,8 +69,10 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.elo.EloPlayer; import mineplex.core.elo.EloTeam; -import mineplex.core.gadget.types.GadgetType; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.lifetimes.Lifetimed; +import mineplex.core.lifetimes.ListenerComponent; +import mineplex.core.lifetimes.PhasedLifetime; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketInfo; import mineplex.core.updater.UpdateType; @@ -91,7 +94,6 @@ import nautilus.game.arcade.game.games.draw.Draw; import nautilus.game.arcade.game.games.speedbuilders.SpeedBuilders; import nautilus.game.arcade.game.modules.AntiExpOrbModule; import nautilus.game.arcade.game.modules.Module; -import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.ChampionsKit; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; @@ -112,8 +114,6 @@ import nautilus.game.arcade.stats.StatTracker; import nautilus.game.arcade.stats.WinStatTracker; import nautilus.game.arcade.wineffect.WinEffectManager; import nautilus.game.arcade.world.WorldData; -import net.minecraft.server.v1_8_R3.EntityItem; -import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; public abstract class Game extends ListenerComponent implements Lifetimed { @@ -750,6 +750,17 @@ public abstract class Game extends ListenerComponent implements Lifetimed UtilServer.getServer().getPluginManager().callEvent(stateEvent); System.out.println(GetName() + " state set to " + state.toString()); + + if (state.equals(GameState.Prepare)) + { + CoreGameStartEvent coreGameStartEvent = new CoreGameStartEvent(GetType().getDisplay()); + UtilServer.getServer().getPluginManager().callEvent(coreGameStartEvent); + } + else if (state.equals(GameState.End)) + { + CoreGameStopEvent coreGameStopEvent = new CoreGameStopEvent(GetType().getDisplay()); + UtilServer.getServer().getPluginManager().callEvent(coreGameStopEvent); + } } public void SetStateTime(long time) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/runner/Runner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/runner/Runner.java index 28f4b1bf3..53d86ee3d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/runner/Runner.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/runner/Runner.java @@ -5,6 +5,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import net.minecraft.server.v1_8_R3.EntityArrow; + import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.Block; @@ -17,9 +19,15 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ProjectileHitEvent; +import com.mineplex.anticheat.checks.move.Glide; +import com.mineplex.anticheat.checks.move.HeadRoll; +import com.mineplex.anticheat.checks.move.Speed; + +import mineplex.core.Managers; +import mineplex.core.antihack.AntiHack; import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilTime; @@ -27,17 +35,18 @@ import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.SoloGame; -import nautilus.game.arcade.game.games.runner.kits.*; +import nautilus.game.arcade.game.games.runner.kits.KitArcher; +import nautilus.game.arcade.game.games.runner.kits.KitFrosty; +import nautilus.game.arcade.game.games.runner.kits.KitLeaper; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.stats.DistanceTraveledStatTracker; -import net.minecraft.server.v1_8_R3.EntityArrow; - public class Runner extends SoloGame implements IThrown { private HashMap _blocks = new HashMap(); @@ -85,6 +94,11 @@ public class Runner extends SoloGame implements IThrown .setGiveCompassToSpecs(true) .setGiveCompassToAlive(false) .register(this); + + AntiHack antiHack = Managers.get(AntiHack.class); + antiHack.addIgnoredCheck(Speed.class); + antiHack.addIgnoredCheck(Glide.class); + antiHack.addIgnoredCheck(HeadRoll.class); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/BoosterRing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/BoosterRing.java index 0dbd22383..c73449e2e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/BoosterRing.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/BoosterRing.java @@ -16,6 +16,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import org.omg.DynamicAny._DynUnionStub; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; @@ -40,8 +41,8 @@ import nautilus.game.arcade.game.Game.GameState; */ public class BoosterRing extends Crumbleable implements Listener { - private static int MAX_RING_BOUNDS = 15; - private static int SEARCH_OUTER_RING_RANGE = 10; + private static int MAX_RING_BOUNDS = 18; + private static int SEARCH_OUTER_RING_RANGE = 12; private Game _host; @@ -63,6 +64,11 @@ public class BoosterRing extends Crumbleable implements Listener private long _disabledSince; private long _disabledFor; + private long _disableDelay; + private long _disableDelayStarted; + + private CooldownData _delayedData; + private Hologram _hologram; private boolean _timer; @@ -89,6 +95,8 @@ public class BoosterRing extends Crumbleable implements Listener _boostStrength = boostStrength; _disabledSince = System.currentTimeMillis(); + _disableDelayStarted = 0; + System.out.println("Registering Ring"); setupRing(); @@ -100,6 +108,8 @@ public class BoosterRing extends Crumbleable implements Listener _hologram = new Hologram(host.getArcadeManager().getHologramManager(), _ringMiddle, ""); _hologram.setViewDistance(300); + + init(); } @EventHandler @@ -305,7 +315,7 @@ public class BoosterRing extends Crumbleable implements Listener if (event.getType() != UpdateType.TICK) return; - for (Player player : _host.GetPlayers(true)) + for (Player player : UtilServer.getPlayers()) { if (!UtilPlayer.isGliding(player)) continue; @@ -331,7 +341,8 @@ public class BoosterRing extends Crumbleable implements Listener Vector vec = player.getEyeLocation().getDirection(); UtilAction.velocity(player, vec.multiply(event.getStrength())); - UtilFirework.playFirework(player.getEyeLocation(), Type.BALL_LARGE, Color.BLUE, true, false); + if (_host.IsAlive(player)) + UtilFirework.playFirework(player.getEyeLocation(), Type.BALL_LARGE, Color.BLUE, true, false); } @EventHandler @@ -346,6 +357,9 @@ public class BoosterRing extends Crumbleable implements Listener if (!_disabled) return; + if (isCrumbling()) + return; + double blocks = (double) _ring.size() / (double)(_disabledFor/1000); _blocksToFill += blocks; @@ -391,6 +405,42 @@ public class BoosterRing extends Crumbleable implements Listener enable(); } + @EventHandler + public void disableUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + return; + + if (_delayedData == null) + return; + + if (UtilTime.elapsed(_disableDelayStarted, _disableDelay)) + { + disable(_delayedData.getTime(), _delayedData.getMaterial(), _delayedData.getData(), _delayedData.showTimer()); + _delayedData = null; + } + } + + public void disableLater(long delay, long time, Material mat, byte data, boolean showTimer) + { + if (_delayedData != null) + return; + + _delayedData = new CooldownData(time, mat, data, showTimer); + _disableDelayStarted = System.currentTimeMillis(); + _disableDelay = delay; + } + + public void disableLater(long delay, long time, boolean showTimer) + { + disableLater(delay, time, Material.STAINED_CLAY, (byte) 14, showTimer); + } + + public void disableLater(long delay) + { + disableLater(delay, Long.MAX_VALUE, Material.STAINED_CLAY, (byte) 14, false); + } + public void disable() { disable(Long.MAX_VALUE, false); @@ -493,4 +543,40 @@ public class BoosterRing extends Crumbleable implements Listener return _ring; } + private class CooldownData + { + private long _time; + private Material _mat; + private byte _data; + private boolean _showTimer; + + public CooldownData(long time, Material mat, byte data, boolean showTimer) + { + _time = time; + _mat = mat; + _data = data; + _showTimer = showTimer; + } + + public long getTime() + { + return _time; + } + + public Material getMaterial() + { + return _mat; + } + + public byte getData() + { + return _data; + } + + public boolean showTimer() + { + return _showTimer; + } + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Crumbleable.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Crumbleable.java index 35c60e998..35d61e3d4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Crumbleable.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Crumbleable.java @@ -1,12 +1,27 @@ package nautilus.game.arcade.game.games.skyfall; import java.util.ArrayList; +import java.util.BitSet; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import net.minecraft.server.v1_8_R3.Chunk; +import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk; + +import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_8_R3.CraftChunk; +import org.bukkit.entity.Player; import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; /** * Crumbleable is a Superclass to create decayable/crumleable Objects like Sky Islands @@ -15,9 +30,81 @@ import mineplex.core.common.util.UtilMath; */ public abstract class Crumbleable { + private static final long CHUNK_CRUMBLE_DELAY = 1000; + private boolean _crumble; private ArrayList _initBlocks; + private ArrayList _realBlocks; + private Map _chunksToUpdate; + + private boolean _onlyTop; + private int _height; + + private long _lastChunk; + + public Crumbleable() + { + this(false, 0); + } + + public Crumbleable(boolean onlyTop, int height) + { + _onlyTop = onlyTop; + _height = height; + + _realBlocks = new ArrayList<>(); + _chunksToUpdate = new HashMap<>(); + + _lastChunk = System.currentTimeMillis(); + } + + /** + * Must be called when getBlocks is set + */ + public void init() + { + if (_onlyTop) + { + ArrayList flatMap = new ArrayList<>(); + ArrayList locs = getBlocks(); + int y = Integer.MIN_VALUE; + for (Location loc : locs) + { + if (loc.getBlockY() > y) + y = loc.getBlockY(); + } + + for (Location loc : locs) + { + if (loc.getBlockY() == y) + flatMap.add(loc.clone()); + } + + for (Location loc : flatMap) + { + Block block = loc.getBlock(); + + int i = 0; + + while (i <= _height) + { + if (block.getType() != Material.AIR && block.getRelative(BlockFace.UP).getType() == Material.AIR) + _realBlocks.add(block.getLocation()); + + block = block.getRelative(BlockFace.DOWN); + i++; + } + } + _initBlocks = (ArrayList) _realBlocks.clone(); + } + else + { + _realBlocks = (ArrayList) getBlocks().clone(); + _initBlocks = (ArrayList) getBlocks().clone(); + } + + } /** * @see #crumble(int, Material...) @@ -44,26 +131,50 @@ public abstract class Crumbleable crumblePercentage(); - Material material = replacements[UtilMath.r(replacements.length)]; - - if (getBlocks().isEmpty()) + if (_realBlocks.isEmpty()) { crumbledAway(); + if (!_chunksToUpdate.isEmpty()) + { + if (UtilTime.elapsed(_lastChunk, CHUNK_CRUMBLE_DELAY)) + { + Chunk chunk = _chunksToUpdate.keySet().iterator().next(); + BitSet bitSet = _chunksToUpdate.remove(chunk); + + int mask = 0; + + for (int i = 0; i < bitSet.length(); i++) + { + if (bitSet.get(i)) + { + mask |= 1 << i; + } + } + + for (Player player : UtilServer.getPlayers()) + { + UtilPlayer.sendPacket(player, new PacketPlayOutMapChunk(chunk, false, mask)); + } + + _lastChunk = System.currentTimeMillis(); + } + } return true; } for (int i = 0; i < blocks; i++) { - if (getBlocks().isEmpty()) + Material material = replacements[UtilMath.r(replacements.length)]; + if (_realBlocks.isEmpty()) { crumbledAway(); return true; } - Location toRemove = getBlocks().remove(UtilMath.r(getBlocks().size())); - if (toRemove.getBlock().getType() == Material.CHEST && getBlocks().size() > 25) + Location toRemove = _realBlocks.remove(UtilMath.r(_realBlocks.size())); + if (toRemove.getBlock().getType() == Material.CHEST && _realBlocks.size() > 25) { - getBlocks().add(toRemove); + _realBlocks.add(toRemove); continue; } @@ -74,8 +185,19 @@ public abstract class Crumbleable || toRemove.getBlock().getType() == Material.STATIONARY_LAVA) continue; - MapUtil.QuickChangeBlockAt(toRemove, material); + byte id = 0; + + if (toRemove.getBlock().getType() == Material.STAINED_GLASS || + toRemove.getBlock().getType() == Material.GLASS) + { + material = Material.STAINED_GLASS; + id = DyeColor.BLACK.getData(); + } + + MapUtil.ChunkBlockChange(toRemove, material.getId(), id, false); + _chunksToUpdate.computeIfAbsent(((CraftChunk) toRemove.getChunk()).getHandle(), key -> new BitSet()).set(((int) toRemove.getY()) >> 4); } + return false; } @@ -86,7 +208,7 @@ public abstract class Crumbleable public boolean isCrumbledAway() { - return getBlocks().isEmpty(); + return _realBlocks.isEmpty(); } /** @@ -94,19 +216,21 @@ public abstract class Crumbleable */ public double crumblePercentage() { - if (_initBlocks == null) - _initBlocks = (ArrayList) getBlocks().clone(); - try { - return (getBlocks().size()/(_initBlocks.size()/100))/100; + return (_realBlocks.size()/(_initBlocks.size())); } catch (Exception e) { - return 100; + return 1; } } + public ArrayList getRealBlocks() + { + return _realBlocks; + } + /** * Overrideable method which is called by * {@link #crumble(int, Material...)} or {@link #crumble(int)} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Island.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Island.java index 93f15841d..55d3f74ed 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Island.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Island.java @@ -8,15 +8,15 @@ import org.bukkit.block.Block; import org.bukkit.block.Chest; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.loot.ChestLoot; import mineplex.core.titles.tracks.standard.LuckyTrack; import mineplex.core.titles.tracks.standard.UnluckyTrack; -import nautilus.game.arcade.ArcadeManager; - /** * The Island Object represents a flying Island
* which has it's own chests and is able to crumble away. @@ -69,6 +69,8 @@ public class Island extends Crumbleable */ public Island(Location location, ChestLoot loot, int bounds, int height) { + super(true, height); + _location = location; _bounds = bounds; _height = height; @@ -78,24 +80,25 @@ public class Island extends Crumbleable _loot = loot; registerBlocks(); + init(); } - public void fillLoot(Block block, Player player, ArcadeManager arcadeManager) + public void fillLoot(Block block) { if (block.getType() != Material.CHEST && block.getType() != Material.TRAPPED_CHEST) return; - + if (_lootedBlocks.contains(block.getLocation())) return; - + _lootedBlocks.add(block.getLocation()); - + Chest chest = (Chest) block.getState(); Inventory inventory = chest.getBlockInventory(); inventory.clear(); - - int items = 3; + + int items = 5; if (Math.random() > 0.50) items++; if (Math.random() > 0.65) @@ -104,24 +107,78 @@ public class Island extends Crumbleable items++; if (Math.random() > 0.95) items++; - + + ArrayList exclude = new ArrayList<>(); for (int i = 0; i < items; i++) { int trys = 0; - int slot = UtilMath.r(27); + int slot = UtilMath.r(26); while (inventory.getItem(slot) != null && trys <= 5) { trys++; - slot = UtilMath.r(27); + slot = UtilMath.r(26); } - - inventory.setItem(slot, _loot.getLoot()); - } - - if (player != null && arcadeManager != null && arcadeManager.GetServerConfig().RewardStats) - { - arcadeManager.getTrackManager().getTrack(LuckyTrack.class).handleLoot(player, chest.getBlockInventory()); - arcadeManager.getTrackManager().getTrack(UnluckyTrack.class).handleLoot(player, chest.getBlockInventory()); + + ItemStack item = _loot.getLoot(exclude); + inventory.setItem(slot, item); + if (item.getType() == Material.DIAMOND) + { + inventory.setItem(slot + 1, new ItemStack(Material.STICK, 2)); + } + if (item.getType() == Material.BOW) + { + inventory.setItem(slot + 1, new ItemStack(Material.ARROW, UtilMath.r(6) + 1)); + } + + if (UtilItem.isHelmet(item)) + { + exclude.add(Material.CHAINMAIL_HELMET); + exclude.add(Material.GOLD_HELMET); + exclude.add(Material.IRON_HELMET); + exclude.add(Material.LEATHER_HELMET); + exclude.add(Material.DIAMOND_HELMET); + } + if (UtilItem.isChestplate(item)) + { + exclude.add(Material.CHAINMAIL_CHESTPLATE); + exclude.add(Material.GOLD_CHESTPLATE); + exclude.add(Material.IRON_CHESTPLATE); + exclude.add(Material.LEATHER_CHESTPLATE); + exclude.add(Material.DIAMOND_CHESTPLATE); + } + if (UtilItem.isLeggings(item)) + { + exclude.add(Material.CHAINMAIL_LEGGINGS); + exclude.add(Material.GOLD_LEGGINGS); + exclude.add(Material.IRON_LEGGINGS); + exclude.add(Material.LEATHER_LEGGINGS); + exclude.add(Material.DIAMOND_LEGGINGS); + } + if (UtilItem.isBoots(item)) + { + exclude.add(Material.CHAINMAIL_BOOTS); + exclude.add(Material.GOLD_BOOTS); + exclude.add(Material.IRON_BOOTS); + exclude.add(Material.LEATHER_BOOTS); + exclude.add(Material.DIAMOND_BOOTS); + } + if (UtilItem.isSword(item)) + { + exclude.add(Material.WOOD_SWORD); + exclude.add(Material.STONE_SWORD); + exclude.add(Material.IRON_SWORD); + exclude.add(Material.DIAMOND_SWORD); + } + if (UtilItem.isAxe(item)) + { + exclude.add(Material.WOOD_AXE); + exclude.add(Material.STONE_AXE); + exclude.add(Material.IRON_AXE); + exclude.add(Material.DIAMOND_AXE); + } + if (item.getType() == Material.BOW) + exclude.add(Material.BOW); + } } @@ -151,11 +208,11 @@ public class Island extends Crumbleable } public boolean isOnIsland(Location location) - { - if (UtilMath.offset(location, _location) > _bounds) + { + if (UtilMath.offset2d(location, _location) > _bounds + 1) return false; - - for (int y = ((int) (Math.round(_location.getY()) - _height)); y <= _location.getBlockY(); y++) + + for (int y = (_location.getBlockY() - _height); y <= _location.getBlockY(); y++) { if (location.getBlockY() == y) return true; @@ -175,7 +232,7 @@ public class Island extends Crumbleable public void registerBlocks() { - for (Block block : UtilBlock.getInBoundingBox(_location.clone().add(_bounds, 0, _bounds), _location.clone().subtract(_bounds, _height, _bounds))) + for (Block block : UtilBlock.getInBoundingBox(_location.clone().add(_bounds, 0, _bounds), _location.clone().subtract(_bounds, _height, _bounds), false)) { if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST) getChests().add(block.getLocation()); @@ -189,7 +246,7 @@ public class Island extends Crumbleable _lootedBlocks.clear(); for (Location loc : _chests) { - fillLoot(loc.getBlock(), null, null); + fillLoot(loc.getBlock()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/LootTable.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/LootTable.java index 5958180b9..ff32dcd77 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/LootTable.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/LootTable.java @@ -1,6 +1,9 @@ package nautilus.game.arcade.game.games.skyfall; +import java.util.ArrayList; + import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.F; import mineplex.core.itemstack.ItemStackFactory; @@ -14,15 +17,15 @@ import mineplex.core.loot.RandomItem; */ public class LootTable { - public final static LootTable BASIC = new LootTable( + // Survival Loot + + public final static LootTable BASIC = new LootTable(true, new RandomItem(Material.BAKED_POTATO, 30, 1, 3), new RandomItem(Material.COOKED_BEEF, 30, 1, 2), new RandomItem(Material.COOKED_CHICKEN, 30, 1, 2), new RandomItem(Material.CARROT_ITEM, 30, 1, 3), new RandomItem(Material.MUSHROOM_SOUP, 15, 1, 1), - new RandomItem(Material.WHEAT, 30, 1, 6), new RandomItem(Material.APPLE, 30, 1, 4), - new RandomItem(Material.PORK, 30, 1, 4), new RandomItem(Material.ROTTEN_FLESH, 40, 1, 6), new RandomItem(Material.WOOD_AXE, 100), @@ -57,26 +60,28 @@ public class LootTable Material.TNT, (byte) 0, 1, F.item("Throwing TNT")), 15), new RandomItem(Material.MUSHROOM_SOUP, 15), - new RandomItem(Material.BAKED_POTATO, 20, 1, 5), - new RandomItem(Material.MUSHROOM_SOUP, 20, 1, 1), - new RandomItem(Material.COOKED_BEEF, 30, 1, 3), - new RandomItem(Material.COOKED_CHICKEN, 30, 1, 3), - new RandomItem(Material.COOKED_FISH, 30, 1, 6), - new RandomItem(Material.GRILLED_PORK, 20, 1, 3), + new RandomItem(Material.BAKED_POTATO, 25, 1, 5), + new RandomItem(Material.MUSHROOM_SOUP, 25, 1, 1), + new RandomItem(Material.COOKED_BEEF, 35, 1, 3), + new RandomItem(Material.COOKED_CHICKEN, 35, 1, 3), + new RandomItem(Material.COOKED_FISH, 35, 1, 6), + new RandomItem(Material.GRILLED_PORK, 25, 1, 3), new RandomItem(Material.COOKIE, 30), new RandomItem(Material.PUMPKIN_PIE, 20, 1, 3), new RandomItem(Material.APPLE, 20, 2, 6), - new RandomItem(Material.IRON_INGOT, 30, 1, 2), new RandomItem(Material.DIAMOND, 30) ); - public final static LootTable SUPPLY_DROP = new LootTable( + public final static LootTable SUPPLY_DROP = new LootTable(true, new RandomItem(Material.DIAMOND_HELMET, 30), new RandomItem(Material.DIAMOND_LEGGINGS, 27), new RandomItem(Material.DIAMOND_BOOTS, 30), new RandomItem(Material.DIAMOND_SWORD, 16), - new RandomItem(Material.DIAMOND_AXE, 24) + new RandomItem(Material.DIAMOND_AXE, 24), + new RandomItem(Material.GOLDEN_APPLE, 4), + new RandomItem(Material.BOW, 4), + new RandomItem(Material.ARROW, 2) // new RandomItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, 1, Enchantment.DAMAGE_ALL), 8), // new RandomItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, 1, Enchantment.DAMAGE_ALL), 4), // @@ -86,10 +91,26 @@ public class LootTable // new RandomItem(new Potion(PotionType.STRENGTH, 2, false).toItemStack(1), 3) ); + public final static LootTable ALL = new LootTable(BASIC.includes(SUPPLY_DROP)); + private RandomItem[] _items; + private boolean _unbreakable; + + private LootTable(LootTable table) + { + _unbreakable = table.isUnbreakable(); + _items = table.getItems(); + } private LootTable(RandomItem... items) { + _unbreakable = false; + _items = items; + } + + private LootTable(boolean unbreakable, RandomItem... items) + { + _unbreakable = unbreakable; _items = items; } @@ -98,9 +119,14 @@ public class LootTable return _items; } + public boolean isUnbreakable() + { + return _unbreakable; + } + public ChestLoot getloot() { - ChestLoot loot = new ChestLoot(); + ChestLoot loot = new ChestLoot(_unbreakable); for (RandomItem item : _items) { loot.addLoot(item); @@ -127,6 +153,35 @@ public class LootTable i++; } - return new LootTable(items); + return new LootTable(_unbreakable, items); + } + + public LootTable excludes(ArrayList randomItems) + { + int size = _items.length - randomItems.size(); + RandomItem[] items = new RandomItem[size]; + + int i = 0; + + for (RandomItem item : _items) + { + boolean cont = false; + + for (Material other : randomItems) + { + if (item.getItemStack().getType() == other) + { + cont = true; + } + } + + if (cont) + continue; + + items[i] = item; + i++; + } + + return new LootTable(_unbreakable, items); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java index ab8ae6c56..1043881ad 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java @@ -11,10 +11,12 @@ import java.util.UUID; import net.md_5.bungee.api.ChatColor; import org.bukkit.Color; +import org.bukkit.Effect; import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect.Type; 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.block.Chest; @@ -29,9 +31,14 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.CraftItemEvent; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -58,7 +65,10 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; +import mineplex.core.loot.ChestLoot; import mineplex.core.recharge.Recharge; +import mineplex.core.titles.tracks.standard.LuckyTrack; +import mineplex.core.titles.tracks.standard.UnluckyTrack; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -89,83 +99,91 @@ import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker; */ public abstract class Skyfall extends Game { - private static final long MAP_CRUMBLE_DELAY = 1000 * 30; // 30 Seconds - private static final long CHEST_REFILL_TIME = 1000 * 60 * 3; // 3 minutes - private static final long CHEST_REFILL_ANNOUNCE_TIME = 1000 * 60 * 3; // 3 minutes - private static final int BIG_ISLAND_BOUNDS = 30; - private static final int BIG_ISLAND_HEIGHT = 40; + private static final long MAP_CRUMBLE_DELAY = 1000*20; // 2 Minutes + private static final long RING_CRUMBLE_DELAY = 1000*60*2; // 2 Minutes + private static final long CHEST_REFILL_TIME = 1000*60*3; // 3 minutes + private static final long CHEST_REFILL_ANNOUNCE_TIME = 1000*60*3; // 3 minutes private static final long ELYTRA_TAKEAWAY = 1000; - - private static final int ISLAND_CRUMBLE_RATE = 7; - private static final int BIG_ISLAND_CRUMBLE_RATE = 5; - private static final int BOOSTER_RING_CRUMBLE_RATE = 3; - private static final float RING_BOOST_STRENGTH = 2.5F; - private static final float BIG_RING_BOOST_STRENGTH = 3.5F; - - private static final long BOOSTER_COOLDOWN_TIME = 1000 * 20; // 20 Seconds - - private static final long SUPPLY_DROP_TIME = 1000 * 60 * 5; // 5 Minutes - private static final long DEATHMATCH_START_TIME = 1000 * 30; // 30 Seconds - private static final long DEATHMATCH_WAIT_TIME = 1000 * 10; // 10 Seconds - + private static final int ROT_START = 256; + private static final int ROT_Y_OFFSET = 25; + + private static final long ISLAND_ROT_TIME = 1000*60*5; // 5 Minutes + + private static final int RING_CRUMBLE_RATE = 10; + + private static final float RING_BOOST_STRENGTH = 3.25F; + private static final float BIG_RING_BOOST_STRENGTH = 4.3F; + + private static final long BOOSTER_COOLDOWN_TIME = 1000*20; // 20 Seconds + + private static final long SUPPLY_DROP_TIME = 1000*60*5; // 5 Minutes + private static final long DEATHMATCH_START_TIME = 1000*30; // 30 Seconds + private static final long DEATHMATCH_WAIT_TIME = 1000*10; // 10 Seconds + private static final int TNT_EXPLOSION_RADIUS = 14; private static final long EAT_RECHARGE = 500; // 0.5 Second - - private int _islandBounds; - private int _islandHeight; - + + private int _islandCrumbleRate; + + private int _bigIslandBounds; + private int _bigIslandHeight; + private Island _upperIsland; private Island _lowerIsland; - + private HashMap> _islands; private HashMap _tntMap; private ArrayList _boosterRings; private HashMap _disabledElytras; - + private HashSet _currentlyEating; private boolean _crumbleAnnounced; - + private long _chestsRefilled; - + private Location _supplyDrop; private Location _supplyEffect; private boolean _supplyDropActive; private boolean _supplyDropOver; - + private ArrayList _deathMatchSpawns; private boolean _deathmatch; private boolean _deathMatchStarted; private boolean _teleportedDeathmatch; private long _deathMatchStartTime; - + private boolean _refillAnnounced; - - private int _currentCrumble = 300; + private boolean _supplyOpened; - - public Skyfall(ArcadeManager manager, GameType type) + + private double _rotY; + + //private int _ringCrumbleRate; + + public Skyfall(ArcadeManager manager, GameType type) { super(manager, type, new Kit[] { - new KitSpeeder(manager), - //new KitBooster(manager), // Broken? :( - new KitJouster(manager), - new KitStunner(manager), - //new KitSurefoot(manager), - new KitAeronaught(manager), - new KitDeadeye(manager) + new KitSpeeder(manager), + //new KitBooster(manager), // Broken? :( + new KitJouster(manager), + new KitStunner(manager), + //new KitSurefoot(manager), + new KitAeronaught(manager), + new KitDeadeye(manager) }, - new String[] - { - "Fly with your Elytra", - "Try to land on Islands", - "Get your gear from chests" - }); + new String[] + { + "Fly with your Elytra", + "Try to land on Islands", + "Get your gear from chests" + }); + registerStatTrackers(new WinWithoutWearingArmorStatTracker(this), @@ -173,7 +191,7 @@ public abstract class Skyfall extends Game new FirstSupplyDropOpenStatTracker(this), new RingStatTracker(this), new AeronaughtStatTracker(this)); - + registerChatStats( Kills, Assists, @@ -182,8 +200,8 @@ public abstract class Skyfall extends Game DamageDealt, BlankLine ); - - new VersionModule(MinecraftVersion.Version1_9).register(this); + + registerModule(new VersionModule(MinecraftVersion.Version1_9)); // Disable specific GWEN checks for this game AntiHack antiHack = Managers.get(AntiHack.class); @@ -196,8 +214,8 @@ public abstract class Skyfall extends Game _tntMap = new HashMap<>(); _disabledElytras = new HashMap<>(); _currentlyEating = new HashSet<>(); - - PrepareFreeze = true; + + PrepareFreeze = true; AnnounceStay = false; DeathDropItems = true; QuitDropItems = true; @@ -214,238 +232,317 @@ public abstract class Skyfall extends Game DamageFall = false; SoupEnabled = true; StrictAntiHack = false; - + new CompassModule() - .setGiveCompassToAlive(true) - .register(this); - + .setGiveCompassToAlive(true) + .register(this); + SpeedMeasurement = true; - - _islandBounds = 25; - _islandHeight = 15; + + _bigIslandBounds = 25; + _bigIslandHeight = 15; + + _rotY = ROT_START; } - + + @EventHandler + public void testCommands(PlayerCommandPreprocessEvent event) + { + if(GetState() != GameState.Live) + return; + + if (!UtilServer.isTestServer()) + return; + + if(event.getMessage().contains("/Rate")) + { + int rate = Integer.parseInt(event.getMessage().split(" ")[1]); + _islandCrumbleRate = rate; + UtilPlayer.message(event.getPlayer(), "Crumble rate changed to " + rate); + event.setCancelled(true); + return; + } + + if(event.getMessage().contains("/Rot")) + { + UtilPlayer.message(event.getPlayer(), "Current Rot value " + _rotY); + event.setCancelled(true); + return; + } + + if(event.getMessage().contains("/Boost")) + { + float rate = Float.parseFloat(event.getMessage().split(" ")[1]); + for (BoosterRing ring : _boosterRings) + { + ring.setBoostStrength(rate); + } + UtilPlayer.message(event.getPlayer(), "Boost changed to " + rate); + event.setCancelled(true); + return; + } + + } + @EventHandler public void gameStart(GameStateChangeEvent event) { if (event.GetState() == GameState.Live) { _chestsRefilled = System.currentTimeMillis(); - + for (Location spawn : GetTeamList().get(0).GetSpawns()) { spawn.clone().subtract(0, 1, 0).getBlock().setType(Material.AIR); } - + for (Player player : GetPlayers(true)) { ItemStack stack = new ItemStack(Material.COMPASS); - + ItemMeta itemMeta = stack.getItemMeta(); itemMeta.setDisplayName(C.cGreen + C.Bold + "Tracking Compass"); stack.setItemMeta(itemMeta); - + player.getInventory().addItem(stack); } } } - + @EventHandler public void chestRefill(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; - + if (!IsLive()) return; - + if (!UtilTime.elapsed(_chestsRefilled, CHEST_REFILL_TIME)) return; - + if (_deathmatch) return; - + _chestsRefilled = System.currentTimeMillis(); _refillAnnounced = false; - - _upperIsland.refillChests(); + _lowerIsland.refillChests(); - - Announce(ChatColor.AQUA + "" + ChatColor.BOLD + "Chests on the middle Islands have been refilled!", true); + + Announce(ChatColor.AQUA + "" + ChatColor.BOLD + "Chests on the lower middle Island have been refilled!", true); } - + @EventHandler public void chestRefillAnnounce(UpdateEvent event) { if (event.getType() != UpdateType.SEC) return; - + if (!IsLive()) return; if (!UtilTime.elapsed(_chestsRefilled, CHEST_REFILL_ANNOUNCE_TIME)) return; - + if (_refillAnnounced) return; - + Announce(C.cGold + C.Bold + "The chests will be refilled in " + UtilTime.MakeStr(CHEST_REFILL_TIME - CHEST_REFILL_ANNOUNCE_TIME), false); - + _refillAnnounced = true; } - + @EventHandler public void dontRemoveElytra(InventoryClickEvent event) { if (event.getCurrentItem() == null) return; - + if (event.getCurrentItem().getType() == Material.ELYTRA) event.setCancelled(true); } - + @EventHandler public void mapCrumble(UpdateEvent event) { if (event.getType() != UpdateType.FASTEST) return; - + if (!IsLive()) return; - + if (!UtilTime.elapsed(GetStateTime(), MAP_CRUMBLE_DELAY)) return; - + if (!_crumbleAnnounced) { Announce(C.cGreenB + "As time passes, the world begins to rot...", true); _crumbleAnnounced = true; } - + for (Island island : islandCrumble()) { for (Player player : GetPlayers(true)) { if (!island.isOnIsland(player)) continue; - + if (UtilPlayer.isGliding(player)) continue; - + Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 1, false, false, true, "Island Rot", "Island Rot"); } } - + for (BoosterRing ring : _boosterRings) { for (Player player : GetPlayers(true)) { if (!ring.isCrumbledAway()) continue; - + if (UtilPlayer.isGliding(player)) continue; - - if (UtilMath.offset(player.getLocation(), ring.getMiddle()) > (ring.getSize() / 2)) + + if (UtilMath.offset(player.getLocation(), ring.getMiddle()) > (ring.getSize()/2)) continue; - + Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 1, false, false, true, "Island Rot", "Island Rot"); } } } - + + @EventHandler + public void lowerRot(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC_05) + return; + + if (!IsLive()) + return; + + if (_rotY <= (0 - ROT_Y_OFFSET)) + return; + + long startTime = GetStateTime() + MAP_CRUMBLE_DELAY; + //System.out.println("starttime " + startTime); + double current = System.currentTimeMillis() - startTime; + //System.out.println("current " + current); + + double percentage = current/((double) ISLAND_ROT_TIME); + //System.out.println("precentage " + percentage); + double value = ROT_START * percentage; + //System.out.println("value " + value); + + _rotY = (ROT_START - value); + } + public ArrayList islandCrumble() { ArrayList islands = new ArrayList<>(); + + for (Island island : _islands.get(_upperIsland).keySet()) { - if (island.crumblePercentage() <= 0.5) + if (island.isCrumbledAway()) islands.add(island); - - Material[] mats = new Material[]{Material.COAL_BLOCK, Material.ENDER_STONE}; - if (island.getLocation().getBlockY() >= GetTeamList().get(0).GetSpawns().get(0).getBlockY()) - mats = new Material[]{Material.AIR}; - - if (!island.crumble(ISLAND_CRUMBLE_RATE, mats)) - { - return islands; - } + + if (island.getLocation().getBlockY() < (_rotY + ROT_Y_OFFSET)) + continue; + + island.crumble(_islandCrumbleRate, Material.COAL_BLOCK, Material.ENDER_STONE); } - if (_upperIsland.crumblePercentage() <= 0.5) + + + if (_upperIsland.isCrumbledAway()) islands.add(_upperIsland); + - if (!_upperIsland.crumble(BIG_ISLAND_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE)) + if (_upperIsland.getLocation().getBlockY() > (_rotY + ROT_Y_OFFSET)) { - _currentCrumble = _upperIsland.getLocation().getBlockY(); - return islands; - } - else - { - while (!_upperIsland.getBoosterRing().isCrumbledAway()) + if (_upperIsland.crumble(_islandCrumbleRate, Material.COAL_BLOCK, Material.ENDER_STONE)) { - _upperIsland.getBoosterRing().crumble(BOOSTER_RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE); + while (!_upperIsland.getBoosterRing().isCrumbledAway()) + { + _upperIsland.getBoosterRing().crumble(RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE); + } } } + + for (Island island : _islands.get(_lowerIsland).keySet()) { - if (island.crumblePercentage() <= 0.5) + if (island.isCrumbledAway()) islands.add(island); - - if (!island.crumble(ISLAND_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE)) - { - return islands; - } + + if (island.getLocation().getBlockY() < (_rotY + ROT_Y_OFFSET)) + continue; + + island.crumble(_islandCrumbleRate, Material.COAL_BLOCK, Material.ENDER_STONE); } - if (_lowerIsland.crumblePercentage() <= 0.5) + + + if (_lowerIsland.isCrumbledAway()) islands.add(_lowerIsland); - - _currentCrumble = _lowerIsland.getLocation().getBlockY(); - if (_lowerIsland.crumble(BIG_ISLAND_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE)) + + if (_lowerIsland.getLocation().getBlockY() > (_rotY + ROT_Y_OFFSET)) { - while (!_lowerIsland.getBoosterRing().isCrumbledAway()) + if (_lowerIsland.crumble(_islandCrumbleRate, Material.COAL_BLOCK, Material.ENDER_STONE)) { - _lowerIsland.getBoosterRing().crumble(BOOSTER_RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE); + while (!_lowerIsland.getBoosterRing().isCrumbledAway()) + { + _lowerIsland.getBoosterRing().crumble(RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE); + } } - _currentCrumble = 0; } return islands; } - + + @EventHandler + public void disableAC(PlayerTeleportEvent event) + { + if (!IsLive()) + return; + + if (event.getCause() == TeleportCause.UNKNOWN) + event.setCancelled(true); + } + //@EventHandler public void deathMatch(UpdateEvent event) { if (event.getType() != UpdateType.SEC) return; - + if (!IsLive()) return; - + if (_deathmatch) { if (!UtilTime.elapsed(_deathMatchStartTime, DEATHMATCH_START_TIME)) return; - + if (_teleportedDeathmatch) { - + if (UtilTime.elapsed(_deathMatchStartTime, DEATHMATCH_START_TIME + DEATHMATCH_WAIT_TIME)) { if (_deathMatchStarted) return; - + _deathMatchStarted = true; Announce(C.cRed + C.Bold + "Deathmatch has begun!", false); return; - } - + } + if (!_deathMatchStarted) { long time = (_deathMatchStartTime + DEATHMATCH_START_TIME + DEATHMATCH_WAIT_TIME) - System.currentTimeMillis(); - int real = Math.round(time / 1000) + 1; - + int real = Math.round(time/1000) + 1; + Announce(C.cRed + C.Bold + "Deathmatch is starting in " + real + "...", false); } } @@ -467,7 +564,7 @@ public abstract class Skyfall extends Game } } } - + public void deathMatch() { for (Player player : GetPlayers(true)) @@ -476,55 +573,80 @@ public abstract class Skyfall extends Game player.teleport(loc); } } - + @EventHandler public void ringCrumble(UpdateEvent event) { - if (event.getType() != UpdateType.FASTER) + if (!IsLive()) return; - + + if (event.getType() != UpdateType.TICK) + return; + for (BoosterRing ring : _boosterRings) { - if (ring.getMiddle().getBlockY() < _currentCrumble) + if (ring == _upperIsland.getBoosterRing() || ring == _lowerIsland.getBoosterRing()) continue; + + if (!UtilTime.elapsed(GetStateTime(), RING_CRUMBLE_DELAY)) + return; + + if (ring.getMiddle().getBlockY() > (_upperIsland.getLocation().getBlockY() - (_upperIsland.getHeight()*2))) + { + if (!ring.crumble(RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE)) + break; + } - if (!ring.crumble(BOOSTER_RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE)) + if (!UtilTime.elapsed(GetStateTime(), (RING_CRUMBLE_DELAY*2))) + continue; + + if (ring.getMiddle().getBlockY() > (_lowerIsland.getLocation().getBlockY() - (_lowerIsland.getHeight()*2))) + { + if (!ring.crumble(RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE)) + break; + } + + if (!UtilTime.elapsed(GetStateTime(), (RING_CRUMBLE_DELAY*3))) + continue; + + if (!ring.crumble(RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE)) break; + } } - + @EventHandler public void playerHunger(UpdateEvent event) { if (event.getType() != UpdateType.SLOW) return; - + for (Player player : GetPlayers(true)) { if (!UtilPlayer.isGliding(player)) continue; - + if (player.getFoodLevel() > 0) player.setFoodLevel(player.getFoodLevel() - 1); - + } } - + @EventHandler public void supplyDrop(UpdateEvent event) { if (event.getType() != UpdateType.FASTEST) return; - + if (!IsLive()) return; - + if (!UtilTime.elapsed(GetStateTime(), SUPPLY_DROP_TIME)) return; if (_supplyDropOver) return; - + if (!_supplyDropActive) { Announce(C.cYellow + C.Bold + "Supply Drop Incoming"); @@ -536,7 +658,7 @@ public abstract class Skyfall extends Game for (int z = -1; z <= 1; z++) _supplyDrop.getBlock().getRelative(x, -3, z) .setType(Material.IRON_BLOCK); - + _supplyDropActive = true; } @@ -551,32 +673,70 @@ public abstract class Skyfall extends Game UtilFirework.playFirework(_supplyEffect, effect); _supplyDrop.getBlock().getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN).setType(Material.GLASS); - + Block block = _supplyDrop.getBlock(); block.setType(Material.CHEST); - + Chest chest = (Chest) block.getState(); - for (int i = 0; i < UtilMath.rRange(5, 8); i++) - { - chest.getInventory().setItem(UtilMath.r(27), LootTable.SUPPLY_DROP.getloot().getLoot()); + ChestLoot loot = LootTable.SUPPLY_DROP.getloot(); + ArrayList exclude = new ArrayList<>(); + for (int i = 0; i < UtilMath.rRange(3, 5); i++) + { + int slot = UtilMath.r(26); + ItemStack item = loot.getLoot(exclude); + Inventory inventory = chest.getInventory(); + inventory.setItem(slot, item); + if (item.getType() == Material.BOW) + { + inventory.setItem(slot + 1, new ItemStack(Material.ARROW, UtilMath.r(6) + 1)); + } + if (UtilItem.isHelmet(item)) + { + exclude.add(Material.DIAMOND_HELMET); + } + if (UtilItem.isChestplate(item)) + { + exclude.add(Material.DIAMOND_CHESTPLATE); + } + if (UtilItem.isLeggings(item)) + { + exclude.add(Material.DIAMOND_LEGGINGS); + } + if (UtilItem.isBoots(item)) + { + exclude.add(Material.DIAMOND_BOOTS); + } + if (UtilItem.isSword(item)) + { + exclude.add(Material.DIAMOND_SWORD); + } + if (UtilItem.isAxe(item)) + { + exclude.add(Material.DIAMOND_AXE); + } + if (item.getType() == Material.BOW) + exclude.add(Material.BOW); } _supplyDropOver = true; } } - + @EventHandler public void lootChest(PlayerInteractEvent event) { if (!IsLive()) return; - + + if (!IsAlive(event.getPlayer())) + return; + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; - + if (event.getClickedBlock().getType() != Material.CHEST && event.getClickedBlock().getType() != Material.TRAPPED_CHEST) return; - + if (event.getClickedBlock().getLocation().getBlockX() == _supplyDrop.getBlockX() && event.getClickedBlock().getLocation().getBlockY() == _supplyDrop.getBlockY() && event.getClickedBlock().getLocation().getBlockZ() == _supplyDrop.getBlockZ()) @@ -589,179 +749,247 @@ public abstract class Skyfall extends Game } return; } - + Island island = getCurrentIsland(event.getPlayer()); if (island == null) { - _upperIsland.fillLoot(event.getClickedBlock(), event.getPlayer(), getArcadeManager()); + _upperIsland.fillLoot(event.getClickedBlock()); return; } - - island.fillLoot(event.getClickedBlock(), event.getPlayer(), getArcadeManager()); + + island.fillLoot(event.getClickedBlock()); + + if (event.getPlayer() != null && Manager != null && Manager.GetServerConfig().RewardStats) + { + Manager.getTrackManager().getTrack(LuckyTrack.class).handleLoot(event.getPlayer(), ((Chest) event.getClickedBlock().getState()).getBlockInventory()); + Manager.getTrackManager().getTrack(UnluckyTrack.class).handleLoot(event.getPlayer(), ((Chest) event.getClickedBlock().getState()).getBlockInventory()); + } } - + // I have no clue why, but this is fixing all food issues @EventHandler public void foodFix(PlayerInteractEvent event) { if (!IsLive()) return; - + if (!UtilEvent.isAction(event, ActionType.R)) return; - + Player player = event.getPlayer(); - + if (player.getItemInHand() == null) return; - + ItemStack stack = player.getItemInHand(); - + if (!UtilItem.isFood(stack)) return; - + if (stack.getType() == Material.MUSHROOM_SOUP) return; - + if (player.getFoodLevel() >= 20) return; - + if (!Recharge.Instance.usable(player, "eating")) return; - + if (_currentlyEating.contains(player.getUniqueId())) return; - - _currentlyEating.add(player.getUniqueId()); + + _currentlyEating.add(player.getUniqueId()); //player.setWalkSpeed(0.1F); - + Manager.runSyncLater(new Runnable() { @Override public void run() { //player.setWalkSpeed(0.2F); - + if (stack.getAmount() <= 0) return; - + Recharge.Instance.use(player, "eating", EAT_RECHARGE, false, false); - + _currentlyEating.remove(player.getUniqueId()); //stack.setAmount(stack.getAmount() - 1); - + int heal = 4; - if (stack.getType() == Material.BAKED_POTATO + if (stack.getType() == Material.BAKED_POTATO || stack.getType() == Material.BREAD || stack.getType() == Material.COOKED_FISH) heal = 5; - + if (stack.getType() == Material.COOKED_BEEF || stack.getType() == Material.GRILLED_PORK || stack.getType() == Material.PUMPKIN_PIE) heal = 8; - + //player.setFoodLevel(player.getFoodLevel() + heal); //player.getWorld().playSound(player.getEyeLocation(), Sound.BURP, 100, 1); - } + } }, 40); } - + @Override public void ParseData() { WorldData.MaxY = 1000; - + _supplyDrop = WorldData.GetDataLocs("PINK").get(0); _deathMatchSpawns = (ArrayList) WorldData.GetDataLocs("BROWN").clone(); - - _upperIsland = new Island(WorldData.GetDataLocs("GREEN").get(0), LootTable.BASIC, BIG_ISLAND_BOUNDS, BIG_ISLAND_HEIGHT); - _lowerIsland = new Island(WorldData.GetDataLocs("YELLOW").get(0), LootTable.BASIC, BIG_ISLAND_BOUNDS, BIG_ISLAND_HEIGHT); - + for (String name : WorldData.GetAllCustomLocs().keySet()) { - if (name.split(" ")[0].equalsIgnoreCase("HEIGHT")) + if (name.split(" ")[0].equalsIgnoreCase("BIG_HEIGHT")) { - _islandHeight = Integer.parseInt(name.split(" ")[1]); + _bigIslandHeight = Integer.parseInt(name.split(" ")[1]); } - else if (name.split(" ")[0].equalsIgnoreCase("BOUNDS")) + else if (name.split(" ")[0].equalsIgnoreCase("BIG_BOUNDS")) { - _islandBounds = Integer.parseInt(name.split(" ")[1]); + _bigIslandBounds = Integer.parseInt(name.split(" ")[1]); } } - + + _upperIsland = new Island(WorldData.GetDataLocs("GREEN").get(0), LootTable.BASIC, _bigIslandBounds, _bigIslandHeight); + _lowerIsland = new Island(WorldData.GetDataLocs("YELLOW").get(0), LootTable.BASIC, _bigIslandBounds, _bigIslandHeight); + registerIslands(); registerBoosters(); - + ((CraftWorld) WorldData.World).getHandle().spigotConfig.playerTrackingRange = 250; } - + @EventHandler public void ringBoost(PlayerBoostRingEvent event) - { - event.getRing().disable(BOOSTER_COOLDOWN_TIME, Material.STAINED_CLAY, (byte) 14, true); + { + if (IsAlive(event.getPlayer())) + event.getRing().disable(BOOSTER_COOLDOWN_TIME, Material.STAINED_CLAY, (byte) 14, true); } - + public void registerBoosters() { ArrayList boosters = WorldData.GetDataLocs("ORANGE"); for (Location boosterMid : boosters) { BoosterRing ring = new BoosterRing(this, boosterMid, RING_BOOST_STRENGTH); - + if (_upperIsland.isOnIsland(boosterMid)) { _upperIsland.setBoosterRing(ring); ring.setBoostStrength(BIG_RING_BOOST_STRENGTH); } - + if (_lowerIsland.isOnIsland(boosterMid)) { _lowerIsland.setBoosterRing(ring); ring.setBoostStrength(BIG_RING_BOOST_STRENGTH); } - + _boosterRings.add(ring); } } - + public void registerIslands() { - + HashMap upperIslandMap = new HashMap<>(); HashMap lowerIslandMap = new HashMap<>(); - ArrayList islands = WorldData.GetDataLocs("RED"); - - for (Location islandMid : islands) + + for (String string : WorldData.GetAllDataLocs().keySet()) { - if (islandMid.getBlockY() >= _lowerIsland.getLocation().getBlockY()) + if (string.equalsIgnoreCase("ORANGE") || + string.equalsIgnoreCase("PINK") || + string.equalsIgnoreCase("BROWN") || + string.equalsIgnoreCase("GREEN") || + string.equalsIgnoreCase("YELLOW")) + continue; + + ArrayList islands = WorldData.GetDataLocs(string); + + int islandHeight = _bigIslandHeight; + int islandBounds = _bigIslandBounds; + String loot = "BASIC"; + + for (String name : WorldData.GetAllCustomLocs().keySet()) { - upperIslandMap.put(new Island(islandMid, LootTable.BASIC, _islandBounds, _islandHeight), islandMid.getBlockY()); + if (name.split(" ")[0].equalsIgnoreCase(string)) + { + if (name.split(" ")[1].equalsIgnoreCase("H")) + { + islandHeight = Integer.parseInt(name.split(" ")[2]); + } + if (name.split(" ")[1].equalsIgnoreCase("B")) + { + islandBounds = Integer.parseInt(name.split(" ")[2]); + } + if (name.split(" ")[1].equalsIgnoreCase("L")) + { + islandBounds = Integer.parseInt(name.split(" ")[2]); + } + } } - else + + for (Location islandMid : islands) { - lowerIslandMap.put(new Island(islandMid, LootTable.BASIC, _islandBounds, _islandHeight), islandMid.getBlockY()); + try + { + if (islandMid.getBlockY() >= _lowerIsland.getLocation().getBlockY()) + { + upperIslandMap.put(new Island(islandMid, (LootTable) LootTable.class.getField(loot).get(null), islandBounds, islandHeight), islandMid.getBlockY()); + } + else + { + lowerIslandMap.put(new Island(islandMid, (LootTable) LootTable.class.getField(loot).get(null), islandBounds, islandHeight), islandMid.getBlockY()); + } + } + catch (Exception e) + { + e.printStackTrace(); + } } } - + IslandSorter upperSorter = new IslandSorter(upperIslandMap); IslandSorter lowerSorter = new IslandSorter(lowerIslandMap); - + _islands.put(_upperIsland, new TreeMap<>(upperSorter)); _islands.get(_upperIsland).putAll(upperIslandMap); _islands.put(_lowerIsland, new TreeMap<>(lowerSorter)); _islands.get(_lowerIsland).putAll(lowerIslandMap); - } + int blocks = 0; + + for (Island island : _islands.get(_upperIsland).keySet()) + blocks += island.getRealBlocks().size(); + + for (Island island : _islands.get(_lowerIsland).keySet()) + blocks += island.getRealBlocks().size(); + + blocks += _upperIsland.getRealBlocks().size(); + blocks += _lowerIsland.getRealBlocks().size(); + + + int ticks = (int) (((ISLAND_ROT_TIME / 1000) *20) / 3); + _islandCrumbleRate = blocks / ticks; + + if (_islandCrumbleRate < 1) + _islandCrumbleRate = 1; + + _islandCrumbleRate = _islandCrumbleRate * 3; + } + public Island getCurrentIsland(Player player) { for (Island island : _islands.keySet()) { if (island.isOnIsland(player)) return island; - + for (Island subIsland : _islands.get(island).keySet()) { if (subIsland.isOnIsland(player)) @@ -770,8 +998,8 @@ public abstract class Skyfall extends Game } return null; } - - @EventHandler(priority = EventPriority.HIGHEST) + + @EventHandler(priority=EventPriority.HIGHEST) public void elytraDrop(PlayerDeathEvent event) { Iterator itemIterator = event.getDrops().iterator(); @@ -784,7 +1012,7 @@ public abstract class Skyfall extends Game } } } - + @EventHandler public void deathmatchBowShoot(EntityShootBowEvent event) { @@ -826,7 +1054,7 @@ public abstract class Skyfall extends Game event.setTo(event.getFrom()); } - + @EventHandler public void supplyGlow(UpdateEvent event) { @@ -835,7 +1063,7 @@ public abstract class Skyfall extends Game if (event.getType() != UpdateType.TICK) return; - + Block block = _supplyDrop.getBlock(); if (block.getType() != Material.CHEST) @@ -845,40 +1073,40 @@ public abstract class Skyfall extends Game if (_supplyOpened) return; - + UtilParticle.PlayParticle(ParticleType.SPELL, block.getLocation() .add(0.5, 0.5, 0.5), 0.3f, 0.3f, 0.3f, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); } - + @EventHandler public void sendWarning(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; - + for (Player player : UtilServer.getPlayers()) { if (!IsLive()) UtilPlayer.removeWorldBorder(player); - + if (!IsAlive(player)) UtilPlayer.removeWorldBorder(player); - + if (player.getInventory().getChestplate() == null) continue; - + UtilPlayer.removeWorldBorder(player); } - + if (!IsLive()) return; - + for (Player player : GetPlayers(true)) { if (player.getInventory().getChestplate() != null) continue; - + if (!UtilPlayer.hasWorldBorder(player)) UtilPlayer.sendRedScreen(player, 100000); } @@ -896,15 +1124,21 @@ public abstract class Skyfall extends Game @EventHandler public void TNTExplosion(ExplosionPrimeEvent event) - { + { if (!_tntMap.containsKey(event.getEntity())) return; Player player = _tntMap.remove(event.getEntity()); for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), TNT_EXPLOSION_RADIUS)) + { Manager.GetCondition().Factory().Explosion("Throwing TNT", other, player, 50, 0.1, false, false); - + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.ENTITY_EXPLOSION, 6, true, true, true, player.getName(), "Throwing TNT"); + } + + event.getEntity().getLocation().getWorld().playEffect(event.getEntity().getLocation(), Effect.EXPLOSION_LARGE, 100); + event.getEntity().getLocation().getWorld().playSound(event.getEntity().getLocation(), Sound.EXPLODE, 100, 1); + event.setCancelled(true); } @@ -961,49 +1195,49 @@ public abstract class Skyfall extends Game _tntMap.put(tnt, player); } - + @EventHandler public void removeElytraLava(CustomDamageEvent event) { if (!IsLive()) return; - + if (event.GetCause() != DamageCause.LAVA) return; Recharge.Instance.useForce(event.GetDamageePlayer(), "Elytra Removal", ELYTRA_TAKEAWAY, true); _disabledElytras.put(event.GetDamageePlayer().getUniqueId(), System.currentTimeMillis() + ELYTRA_TAKEAWAY); } - + @EventHandler public void removeElytraWater(UpdateEvent event) { if (!IsLive()) return; - + if (event.getType() != UpdateType.TICK) return; - + for (Player player : GetPlayers(true)) { - if (player.getLocation().getBlock().getTypeId() == 8 || player.getLocation().getBlock().getRelative(BlockFace.UP).getTypeId() == 8 || - player.getLocation().getBlock().getTypeId() == 9 || player.getLocation().getBlock().getRelative(BlockFace.UP).getTypeId() == 9) + if (player.getLocation().getBlock().getTypeId() == 8 || player.getLocation().getBlock().getRelative(BlockFace.UP).getTypeId() == 8 || + player.getLocation().getBlock().getTypeId() == 9 || player.getLocation().getBlock().getRelative(BlockFace.UP).getTypeId() == 9) { Recharge.Instance.useForce(player, "Elytra Removal", ELYTRA_TAKEAWAY, true); _disabledElytras.put(player.getUniqueId(), System.currentTimeMillis() + ELYTRA_TAKEAWAY); } } } - + @EventHandler public void updateElytras(UpdateEvent event) { if (event.getType() != UpdateType.TICK) return; - + if (Manager.GetGame() == null) return; - + for (Player player : Manager.GetGame().GetPlayers(true)) { if (_disabledElytras.containsKey(player.getUniqueId())) @@ -1011,60 +1245,84 @@ public abstract class Skyfall extends Game if (System.currentTimeMillis() > _disabledElytras.get(player.getUniqueId())) { player.getInventory().setChestplate(new ItemStack(Material.ELYTRA)); - _disabledElytras.remove(player.getUniqueId()); } else { if (player.getInventory().getChestplate() != null) { UtilPlayer.message(player, F.main("Game", C.cRed + "Your Elytra is disabled!")); - player.getInventory().setChestplate(null); } + player.getInventory().setChestplate(null); } } } } + + @EventHandler + public void updateSpecs(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (!IsLive()) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (!IsAlive(player)) + player.getInventory().setChestplate(new ItemStack(Material.ELYTRA)); + } + } + @EventHandler + public void craftedItems(CraftItemEvent event) + { + if (UtilItem.isWeapon(event.getCurrentItem()) || UtilItem.isArmor(event.getCurrentItem())) + { + UtilItem.makeUnbreakable(event.getCurrentItem()); + } + } + public boolean isDeathMatch() { return _deathmatch; } - + public boolean isDeathMatchStarted() { return _deathMatchStarted; } - + public boolean isTeleportedDeathmatch() { return _teleportedDeathmatch; } - + public long getDeathmatchStartTime() { return _deathMatchStartTime; } - + public long getChestsRefilled() { return _chestsRefilled; } - + public long getChestRefillTime() { return CHEST_REFILL_TIME; } - + public long getDeathmatchStartingTime() { return DEATHMATCH_START_TIME; } - + public long getDeathmatchWaitTime() { return DEATHMATCH_WAIT_TIME; } - + private class IslandSorter implements Comparator { private HashMap _map; @@ -1073,13 +1331,13 @@ public abstract class Skyfall extends Game { _map = map; } - + @Override public int compare(Island a, Island b) { return _map.get(a) >= _map.get(b) ? -1 : 1; } - + } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/TeamSkyfall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/TeamSkyfall.java index 05fe70127..f1c95bec8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/TeamSkyfall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/TeamSkyfall.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.skyfall; import java.util.ArrayList; import java.util.List; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -25,6 +26,7 @@ import nautilus.game.arcade.game.modules.TeamModule; */ public class TeamSkyfall extends Skyfall { + private static final long BOOSTER_COOLDOWN_TIME = 1000*20; // 20 Seconds public TeamSkyfall(ArcadeManager manager) { @@ -34,7 +36,6 @@ public class TeamSkyfall extends Skyfall FillTeamsInOrderToCount = 2; SpawnNearAllies = true; - SpawnNearEnemies = true; DamageTeamSelf = false; @@ -155,6 +156,14 @@ public class TeamSkyfall extends Skyfall SetState(GameState.End); } } + + @EventHandler + @Override + public void ringBoost(PlayerBoostRingEvent event) + { + if (IsAlive(event.getPlayer())) + event.getRing().disableLater(3000, BOOSTER_COOLDOWN_TIME, Material.STAINED_CLAY, (byte) 14, true); + } @Override public List getWinners() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/kits/perks/PerkElytraBoost.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/kits/perks/PerkElytraBoost.java index 4ad40b859..33b30aaa4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/kits/perks/PerkElytraBoost.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/kits/perks/PerkElytraBoost.java @@ -92,13 +92,12 @@ public class PerkElytraBoost extends Perk while (i < 10 && !UtilPlayer.isGliding(player)) { UtilPlayer.setGliding(player, true); - - Vector vec = player.getEyeLocation().getDirection(); - UtilAction.velocity(player, vec.multiply(2.5)); - i++; } + Vector vec = player.getEyeLocation().getDirection(); + UtilAction.velocity(player, vec.multiply(2.5)); + UtilFirework.playFirework(player.getEyeLocation(), Type.BALL_LARGE, Color.BLUE, true, false); } }, 4); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/stats/RingStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/stats/RingStatTracker.java index 8eaec3ee2..1260222a6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/stats/RingStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/stats/RingStatTracker.java @@ -29,6 +29,9 @@ public class RingStatTracker extends StatTracker if (event.isCancelled()) return; + if (!getGame().IsAlive(event.getPlayer())) + return; + addStat(event.getPlayer(), "Rings", 1, false, 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 d87447cc1..6d3c8e18b 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 @@ -9,7 +9,8 @@ import org.bukkit.Color; import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Sound; -import org.bukkit.entity.Creature; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -94,16 +95,19 @@ public class GameManager implements Listener //Display IP UtilTextTop.displayProgress(text, health, UtilServer.getPlayers()); - for (Creature pet : Manager.getCosmeticManager().getPetManager().getPets()) + for (Entity pet : Manager.getCosmeticManager().getPetManager().getPets()) { - DisguiseBase disguise = Manager.GetDisguise().getDisguise(pet); - - if (disguise instanceof DisguiseWither) + if (pet instanceof LivingEntity) { - ((DisguiseWither) disguise).setName(text); - ((DisguiseLiving) disguise).setHealth((float) Math.max(0.1, - 300 * health)); - disguise.resendMetadata(); + DisguiseBase disguise = Manager.GetDisguise().getDisguise((LivingEntity) pet); + + if (disguise instanceof DisguiseWither) + { + ((DisguiseWither) disguise).setName(text); + ((DisguiseLiving) disguise).setHealth((float) Math.max(0.1, + 300 * health)); + disguise.resendMetadata(); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java index 234e44f46..058b9e68d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java @@ -10,9 +10,11 @@ import org.bukkit.Effect; import org.bukkit.FireworkEffect; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.SkullType; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.Skull; import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers; import org.bukkit.entity.Chicken; import org.bukkit.entity.Entity; @@ -29,6 +31,7 @@ import org.bukkit.util.Vector; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; @@ -63,11 +66,27 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction; public class HolidayManager implements Listener { + private static final BlockFace[] BLOCK_FACES = { + BlockFace.NORTH, + BlockFace.EAST, + BlockFace.SOUTH, + BlockFace.WEST, + BlockFace.NORTH_EAST, + BlockFace.SOUTH_EAST, + BlockFace.SOUTH_WEST, + BlockFace.NORTH_WEST + }; + + private static final String[] EGG_SKINS = { + "KingCrazy_", + "Trajectories" + }; + public enum HolidayType { CHRISTMAS(Material.CHEST, "Present", Sound.CAT_MEOW), HALLOWEEN(Material.PUMPKIN, "Pumpkin", Sound.ZOMBIE_REMEDY), - EASTER(Material.CHEST, "Egg Basket", Sound.CAT_MEOW), + EASTER(Material.SKULL, "Easter Egg", Sound.CAT_MEOW), THANKSGIVING(null, C.cGoldB + "Thanksgiving Chicken", null); private Material _blockType; @@ -97,8 +116,8 @@ public class HolidayManager implements Listener } } - private HolidayType _type = HolidayType.THANKSGIVING; - private String _statName = "Thanksgiving Chickens 2016"; + private HolidayType _type = HolidayType.EASTER; + private String _statName = "Easter Eggs 2017"; private ArcadeManager _arcadeManager; private TitanGiveawayManager _titanManager; @@ -109,7 +128,7 @@ public class HolidayManager implements Listener private HashSet _items = new HashSet<>(); - private HashSet _coins = new HashSet<>(); + private HashSet _shards = new HashSet<>(); private HashSet _gems = new HashSet<>(); private static final double CHEST_CHANCE = 0.001; @@ -160,7 +179,8 @@ public class HolidayManager implements Listener //Break if (block.getType() != Material.PUMPKIN && block.getType() != Material.JACK_O_LANTERN && - block.getType() != Material.CHEST) + block.getType() != Material.CHEST && + block.getType() != Material.SKULL) { specialBlockBreak(null, block); blockIterator.remove(); @@ -199,10 +219,10 @@ public class HolidayManager implements Listener block.getWorld().playSound(block.getLocation(), Sound.CHICKEN_EGG_POP, 0.25f + (float) Math.random() * 0.75f, 0.75f + (float) Math.random() * 0.5f); } - if (Math.random() > 0.95) + /*if (Math.random() > 0.95) { sendChestPackets(block); - } + }*/ } else if (_type.equals(HolidayType.CHRISTMAS)) { @@ -313,6 +333,16 @@ public class HolidayManager implements Listener { sendChestPackets(block); } + + if (_type.getBlockType() == Material.SKULL) + { + block.setData((byte) 1); + Skull skull = (Skull) block.getState(); + skull.setSkullType(SkullType.PLAYER); + skull.setOwner(EGG_SKINS[UtilMath.r(EGG_SKINS.length)]); + skull.setRotation(BLOCK_FACES[UtilMath.r(BLOCK_FACES.length)]); + skull.update(); + } _active.add(block); @@ -478,25 +508,25 @@ public class HolidayManager implements Listener if (player != null && _arcadeManager.GetGame() != null) { _arcadeManager.GetGame().AddStat(player, _statName, 1, false, true); - System.out.println("Recording Pumpkin Break for " + player.getName()); + System.out.println("Recording Holiday Block Break for " + player.getName()); } - //Coins + //Shards for (int i = 0; i < 4 + Math.random() * 8; i++) { - Item coin = block.getWorld().dropItem(block.getLocation().add(0.5, 1, 0.5), - ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte) 0, 1, UtilMath.r(999999) + "Coin")); + Item shard = block.getWorld().dropItem(block.getLocation().add(0.5, 1, 0.5), + ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte) 0, 1, UtilMath.r(999999) + "Shard")); Vector vel = new Vector( (Math.random() - 0.5) * 0.5, 0.1 + Math.random() * 0.3, (Math.random() - 0.5) * 0.5); - coin.setVelocity(vel); + shard.setVelocity(vel); - coin.setPickupDelay(20); + shard.setPickupDelay(20); - _coins.add(coin); + _shards.add(shard); } //Gems @@ -530,6 +560,20 @@ public class HolidayManager implements Listener } }); }*/ + + // Eternal Giveaway + if (player != null) + { + _eternalGiveawayManager.openPumpkin(player, new Runnable() + { + @Override + public void run() + { + Location location = block.getLocation().add(0.5, 0.5, 0.5); + new EternalGiveawayAnimation(_eternalGiveawayManager, location, 3000L); + } + }); + } if (player != null) { @@ -537,15 +581,16 @@ public class HolidayManager implements Listener double rand = UtilMath.random.nextDouble(); if (rand < CHEST_CHANCE) { - if (hasItemsToGivePlayer(TreasureType.HAUNTED.getRewardPool(), player)) + if (hasItemsToGivePlayer(TreasureType.SPRING.getRewardPool(), player)) { FireworkEffect fireworkEffect = FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE) - .withColor(Color.ORANGE).withColor(Color.BLACK).withFade(Color.ORANGE) - .withFade(Color.BLACK).flicker(true).build(); - manager.addItemToInventory(player, "Haunted Chest", 1); + .withColor(Color.LIME).withColor(Color.WHITE).withFade(Color.YELLOW) + .withFade(Color.WHITE).flicker(true).build(); + manager.addItemToInventory(player, "Spring Chest", 1); HalloweenSmashedEffect halloweenSmashedEffect = new HalloweenSmashedEffect(block.getLocation() .add(.5, .5, .5), fireworkEffect, _arcadeManager.getPlugin()); halloweenSmashedEffect.start(); + UtilPlayer.message(player, F.main("Holiday Rewards", "You found a Spring Chest in a " + _type.getBlockName() + "!")); } else { @@ -556,8 +601,13 @@ public class HolidayManager implements Listener HalloweenSmashedEffect halloweenSmashedEffect = new HalloweenSmashedEffect(block.getLocation() .add(.5, .5, .5), fireworkEffect, _arcadeManager.getPlugin()); halloweenSmashedEffect.start(); + UtilPlayer.message(player, F.main("Holiday Rewards", "You found an Omega Chest in a " + _type.getBlockName() + "!")); } } + else + { + UtilPlayer.message(player, F.main("Holiday Rewards", "You found a " + _type.getBlockName())); + } } //Effect @@ -569,25 +619,25 @@ public class HolidayManager implements Listener if (player != null && _arcadeManager.GetGame() != null) { _arcadeManager.GetGame().AddStat(player, _statName, 1, false, true); - System.out.println("Recording Entity Killong for " + player.getName()); + System.out.println("Recording Entity Killing for " + player.getName()); } //Coins for (int i=0 ; i < 4 + Math.random()*8 ; i++) { - Item coin = entity.getWorld().dropItem(entity.getLocation().add(0.5, 1, 0.5), - ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte)0, 1, UtilMath.r(999999) + "Coin")); + Item shard = entity.getWorld().dropItem(entity.getLocation().add(0.5, 1, 0.5), + ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte)0, 1, UtilMath.r(999999) + "Shard")); Vector vel = new Vector( (Math.random() - 0.5) * 0.5, 0.1 + Math.random() * 0.3, (Math.random() - 0.5) * 0.5); - coin.setVelocity(vel); + shard.setVelocity(vel); - coin.setPickupDelay(20); + shard.setPickupDelay(20); - _coins.add(coin); + _shards.add(shard); } //Gems @@ -629,12 +679,12 @@ public class HolidayManager implements Listener if (UtilPlayer.isSpectator(event.getPlayer())) return; - if (_coins.contains(event.getItem())) + if (_shards.contains(event.getItem())) { event.setCancelled(true); event.getItem().remove(); - _arcadeManager.GetDonation().rewardCurrency(GlobalCurrency.TREASURE_SHARD, event.getPlayer(), _type + " Coins", 4 * event.getItem().getItemStack().getAmount()); + _arcadeManager.GetDonation().rewardCurrency(GlobalCurrency.TREASURE_SHARD, event.getPlayer(), _type + " Shards", 4 * event.getItem().getItemStack().getAmount()); event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f); } @@ -660,7 +710,7 @@ public class HolidayManager implements Listener if (event.getType() != UpdateType.FAST) return; - Iterator coinIterator = _coins.iterator(); + Iterator coinIterator = _shards.iterator(); while (coinIterator.hasNext()) { @@ -703,7 +753,7 @@ public class HolidayManager implements Listener @EventHandler public void spawnDebug(PlayerCommandPreprocessEvent event) { - if (event.getPlayer().isOp() && event.getMessage().toLowerCase().startsWith("/pumpkin")) + if (event.getPlayer().isOp() && event.getMessage().toLowerCase().startsWith("/holidayblock")) { spawnSpecialBlock(event.getPlayer().getLocation().getBlock()); event.setCancelled(true);