diff --git a/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/BungeeRotator.java b/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/BungeeRotator.java index a7d2e0462..12ff80b05 100644 --- a/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/BungeeRotator.java +++ b/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/BungeeRotator.java @@ -16,6 +16,7 @@ import java.util.logging.Logger; import mineplex.bungee.api.ApiDeleteCall; import mineplex.bungee.api.ApiGetCall; import mineplex.bungee.api.ApiPostCall; +import mineplex.bungee.api.HttpCallBase; import mineplex.bungee.api.token.ARecord; import mineplex.bungee.api.token.DnsRecord; import mineplex.bungee.api.token.DomainRecords; @@ -24,8 +25,8 @@ import mineplex.serverdata.data.BungeeServer; import mineplex.serverdata.data.DataRepository; import mineplex.serverdata.redis.RedisDataRepository; import mineplex.serverdata.servers.ConnectionData; -import mineplex.serverdata.servers.ConnectionData.ConnectionType; import mineplex.serverdata.servers.ServerManager; +import mineplex.serverdata.servers.ConnectionData.ConnectionType; public class BungeeRotator { @@ -96,8 +97,7 @@ public class BungeeRotator _repository = new RedisDataRepository(ServerManager.getConnection(true, ServerManager.SERVER_STATUS_LABEL), ServerManager.getConnection(false, ServerManager.SERVER_STATUS_LABEL), Region.ALL, BungeeServer.class, "bungeeServers"); - // Temporarily reassigning to US Redis IP for EU player redirection testing. 10.81.1.156 -> 10.33.53.16 - _secondRepository = new RedisDataRepository(new ConnectionData("10.33.53.16", 6379, ConnectionType.MASTER, "ServerStatus"), new ConnectionData("10.33.53.16", 6377, ConnectionType.SLAVE, "ServerStatus"), + _secondRepository = new RedisDataRepository(new ConnectionData("10.81.1.156", 6379, ConnectionType.MASTER, "ServerStatus"), new ConnectionData("10.81.1.156", 6377, ConnectionType.SLAVE, "ServerStatus"), Region.ALL, BungeeServer.class, "bungeeServers"); //_ipRepository = new PlayerStatsRepository(); @@ -110,7 +110,7 @@ public class BungeeRotator try { List bungeeServers = new ArrayList(_repository.getElements()); - //bungeeServers.addAll(_secondRepository.getElements()); + bungeeServers.addAll(_secondRepository.getElements()); Collections.sort(bungeeServers, bungeeSorter); diff --git a/Plugins/Mineplex.Cache/src/mineplex/cache/player/PlayerCache.java b/Plugins/Mineplex.Cache/src/mineplex/cache/player/PlayerCache.java index 2409e3be7..e269478b6 100644 --- a/Plugins/Mineplex.Cache/src/mineplex/cache/player/PlayerCache.java +++ b/Plugins/Mineplex.Cache/src/mineplex/cache/player/PlayerCache.java @@ -1,6 +1,7 @@ package mineplex.cache.player; import java.util.UUID; +import java.util.concurrent.TimeUnit; import mineplex.serverdata.Region; import mineplex.serverdata.redis.RedisDataRepository; @@ -32,7 +33,8 @@ public enum PlayerCache ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), Region.ALL, - "accountid" + "accountid", + (int) TimeUnit.HOURS.toSeconds(6) ); } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index 2f3556b26..6871107bb 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -10,58 +10,61 @@ import mineplex.core.common.util.UtilPlayer; public enum Rank { //Staff - LT("Leader", "lt", ChatColor.DARK_RED, "Leaders manage the operation of their respective team \nor projects. They usually operate on affairs within \nthe staff, development, or management team."), - OWNER("Owner", "owner", ChatColor.DARK_RED, "Owners are the founders of Mineplex. \nEach owner manages a different aspect of the \nserver and ensures its efficient operation."), - DEVELOPER("Dev", "dev", ChatColor.DARK_RED, "Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience."), - ADMIN("Admin", "adm", ChatColor.DARK_RED, "An Administrator’s role is to manage \ntheir respective Senior Moderator team \nand all moderators within it."), - JNR_DEV("Jr.Dev", "jrdev", ChatColor.GOLD, "Junior Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience."), - SUPPORT("Support", "spp", ChatColor.BLUE, "Support agents handle tickets and \nprovide customer service."), - CMOD("C.Mod", "cmod", ChatColor.GOLD, "Clans Moderators are members of the Clans Management Senior Mod team. \nTheir duties include moderation and support within the Clans servers. \n\nFor assistance, contact them using " + F.elem("/a ") + "."), - SNR_MODERATOR("Sr.Mod", "srmod", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a ") + "."), - MODERATOR("Mod", "mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + "."), - HELPER("Trainee", "train", ChatColor.GOLD, "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + "."), - MAPLEAD("MapLead", "mapl", ChatColor.BLUE, "Map Leaders are leaders of the Mineplex Build Team. \nThey oversee the creation of new maps and manage Builders."), - MAPDEV("Builder", "mapd", ChatColor.BLUE, "Builders are members of the Mineplex Build Team. \nThey create many of the maps used across Mineplex."), - MEDIA("Media", "media", ChatColor.BLUE, "The Media rank is given to talented artists who are\n endorsed to create content for Mineplex."), + LT("Leader", "lt", ChatColor.DARK_RED, "Leaders manage the operation of their respective team \nor projects. They usually operate on affairs within \nthe staff, development, or management team.", 11), + OWNER("Owner", "owner", ChatColor.DARK_RED, "Owners are the founders of Mineplex. \nEach owner manages a different aspect of the \nserver and ensures its efficient operation.", 55), + DEVELOPER("Dev", "dev", ChatColor.DARK_RED, "Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience.", 5), + ADMIN("Admin", "adm", ChatColor.DARK_RED, "An Administrator’s role is to manage \ntheir respective Senior Moderator team \nand all moderators within it.", 10), + JNR_DEV("Jr.Dev", "jrdev", ChatColor.GOLD, "Junior Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience.", -1), + SUPPORT("Support", "spp", ChatColor.BLUE, "Support agents handle tickets and \nprovide customer service.", 47), + CMOD("C.Mod", "cmod", ChatColor.GOLD, "Clans Moderators are members of the Clans Management Senior Mod team. \nTheir duties include moderation and support within the Clans servers. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32), + SNR_MODERATOR("Sr.Mod", "srmod", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 44), + MODERATOR("Mod", "mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 32), + HELPER("Trainee", "train", ChatColor.GOLD, "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a ") + ".", 24), + MAPLEAD("MapLead", "mapl", ChatColor.BLUE, "Map Leaders are leaders of the Mineplex Build Team. \nThey oversee the creation of new maps and manage Builders.", 25), + MAPDEV("Builder", "mapd", ChatColor.BLUE, "Builders are members of the Mineplex Build Team. \nThey create many of the maps used across Mineplex.", 26), + MEDIA("Media", "media", ChatColor.BLUE, "The Media rank is given to talented artists who are\n endorsed to create content for Mineplex.", -1), - EVENT("Event", "evnt", ChatColor.WHITE, "A member of the official Mineplex Events team!"), + EVENT("Event", "evnt", ChatColor.WHITE, "A member of the official Mineplex Events team!", -1), //Media - YOUTUBE("YouTube", "yt", ChatColor.RED, "A YouTuber who creates content for \nor related to Mineplex."), - YOUTUBE_SMALL("YT", "ytsm", ChatColor.DARK_PURPLE, "A YouTuber who creates content for \nor related to Mineplex. \n\nThey have fewer subscribers than full YouTubers."), - TWITCH("Twitch", "tw", ChatColor.DARK_PURPLE, "A Twitch streamer who often features \nMineplex in their streams."), + YOUTUBE("YouTube", "yt", ChatColor.RED, "A YouTuber who creates content for \nor related to Mineplex.", 22), + YOUTUBE_SMALL("YT", "ytsm", ChatColor.DARK_PURPLE, "A YouTuber who creates content for \nor related to Mineplex. \n\nThey have fewer subscribers than full YouTubers.", 20), + TWITCH("Twitch", "tw", ChatColor.DARK_PURPLE, "A Twitch streamer who often features \nMineplex in their streams.", 21), //Player - ETERNAL("Eternal", "et", ChatColor.DARK_AQUA, true, "Fantastic and magical, no one \nexcept the time lords truly understand \nthe power of this rank.\n\nThe fifth purchasable rank at Mineplex.com/shop"), - TITAN("Titan", "t", ChatColor.RED, true, "Ancient myths spoke of a gigantic being \nwith immense power... \n\nThe fourth purchasable rank at Mineplex.com/shop"), - LEGEND("Legend", "l", ChatColor.GREEN, true, "Years they have told stories of this rank, \nonly for the legends to be true. \n\nThe third purchasable rank at Mineplex.com/shop"), - HERO("Hero", "h", ChatColor.LIGHT_PURPLE, true, "There are many stories of a \nvaliant Hero who was brave enough to \ntame the most fearsome dragon in the land. \n\nThe second purchasable rank at Mineplex.com/shop"), - ULTRA("Ultra", "u", ChatColor.AQUA, true, "A first step into the stories of the mist. \nOnly those brave enough may enter. \n\nThe first purchasable rank at Mineplex.com/shop"), - ALL("", "", ChatColor.WHITE, null); + ETERNAL("Eternal", "et", ChatColor.DARK_AQUA, true, "Fantastic and magical, no one \nexcept the time lords truly understand \nthe power of this rank.\n\nThe fifth purchasable rank at Mineplex.com/shop", 18), + TITAN("Titan", "t", ChatColor.RED, true, "Ancient myths spoke of a gigantic being \nwith immense power... \n\nThe fourth purchasable rank at Mineplex.com/shop", 15), + LEGEND("Legend", "l", ChatColor.GREEN, true, "Years they have told stories of this rank, \nonly for the legends to be true. \n\nThe third purchasable rank at Mineplex.com/shop", 14), + HERO("Hero", "h", ChatColor.LIGHT_PURPLE, true, "There are many stories of a \nvaliant Hero who was brave enough to \ntame the most fearsome dragon in the land. \n\nThe second purchasable rank at Mineplex.com/shop", 13), + ULTRA("Ultra", "u", ChatColor.AQUA, true, "A first step into the stories of the mist. \nOnly those brave enough may enter. \n\nThe first purchasable rank at Mineplex.com/shop", 12), + ALL("", "", ChatColor.WHITE, null, -1); private ChatColor _color; private boolean _donor; private String _description; + private int _forumId; public String Name; public String ScoreboardTag; - Rank(String name, String scoreboardTag, ChatColor color, String description) + Rank(String name, String scoreboardTag, ChatColor color, String description, int forumId) { _color = color; Name = name; _donor = false; _description = description; ScoreboardTag = scoreboardTag; + _forumId = forumId; } - Rank(String name, String scoreboardTag, ChatColor color, boolean donor, String description) + Rank(String name, String scoreboardTag, ChatColor color, boolean donor, String description, int forumId) { _color = color; Name = name; _donor = donor; _description = description; ScoreboardTag = scoreboardTag; + _forumId = forumId; } public String getDescription() @@ -69,6 +72,11 @@ public enum Rank return _description; } + public void setName(String name) + { + Name = name; + } + public String getRawTag() { if (Name.equalsIgnoreCase("ALL")) @@ -138,4 +146,9 @@ public enum Rank { return _donor; } -} + + public int getForumId() + { + return _forumId; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java index 439bf4958..5e6621476 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java @@ -71,6 +71,23 @@ public class ShapeWings extends ShapeGrid implements CosmeticShape "00000$$0000000$$00000" }; + public static final String[] BEE_WING_PATTERN = new String[] + { + "00$$$000$$$00", + "0$###$0$###$0", + "$$$$$$$$$$$$$", + "$#####$#####$", + "$$$$$$$$$$$$$", + "0$#########$0", + "00$$$$$$$$$00", + "0$#########$0", + "$$$$$$$$$$$$$", + "$#####$#####$", + "$$$$$$$$$$$$$", + "0$###$0$###$0", + "00$$$000$$$00" + }; + public static final String[] SMALL_BUTTERFLY_WING_PATTERN = new String[] { "0$$00000000$$0", @@ -110,6 +127,30 @@ public class ShapeWings extends ShapeGrid implements CosmeticShape "00000$#$00000", "000000$000000" }; + + public static final String[] FOUR_LEAF_CLOVER = new String[] + { + "$$$$$$$$###$$$$$$$", + "$$$$$$##***#$$$$$$", + "$$$$##****%#$$$$$$", + "$$$#******%#$###$$", + "$$$#***%#%%##***#$", + "$$$$#**%#%#*****#$", + "$$$####*%%#*%%**#$", + "$##***#*%#**##**##", + "#***%%*###******%#", + "#**%##*%###%%%%%%#", + "#**#**%%#**######$", + "$#****%#*****#$$$$", + "$$#*%%%#******#$$$", + "$$#####**%#****#$$", + "$$$$$##**%#***%#$$", + "$$$$$###****%%%#$$", + "$$$$##$#%%%%%##$$$", + "$$$##$$$#####$$$$$", + "$###$$$$$$$$$$$$$$", + "$##$$$$$$$$$$$$$$$" + }; /** 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 ff803a28b..3e4c49575 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 @@ -64,6 +64,7 @@ public class SkinData public final static SkinData TURKEY = new SkinData("eyJ0aW1lc3RhbXAiOjE0NzU3NzM2MTc5MDQsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8xYzdmYjczMTRkNmY1ZTMzNmVjN2ViNTI1ZGM0ODMzOWNhMjI4ZDk3ODU1MDM3ZDZhNDIwOGZjNzYwNDc1NiJ9fX0=", "eZWi1LOD8ke7MCUAfhspBCnyfCoGM8suFLKtbW6b27CURoRBG3eKIfwLYYeMp3ObjoZ8gCB90s28Qyw5XMzwvvowy9W/b5cYC0OzQ8+GR7tDZoWc28tGqGBM8cmDJIFQgZdceBIIr2lXeAvEJfLbyrus46hPjk8YTiQW2DsBq88BhKIy6Igb1rGqJ1goVERF07b6+/yMdLKCaT8OZFzKLXfo5rY5gr6HLnvsQiNL9aTrl74agXn1GUcP+QVNe7/c9lYmv5vLCBst1YiIPq27NZASZ++Fwyv6+PRlaFZZYtMHVd4UZeYPl7ak1Cdi/1sUcRpkBbJM8AHIrqq0iuXxrLbc6ldQ2cYQKHg9ljIpW/EZanuf6Wgm/LK1JnxXne9GUb/xPzB1EnZ95i8/u9WJa+NixEcfc3pAzDPYncIR8lishFwyBRta6BCG76U3UY2lQr3YD/48AJ49r7+WVU0gOP/h2SDSdAZHEdvkpVJ0w/xA+SevJ7Y7xA5EJ655YMQ0F8f3WUFTf1pFklE5E+fwkMVCWOPw7UMy558IcRSpdWAPPyf8sc7CpDqRk37/vXWRDa+7YBfgskK6B2eXowrzThUOBx+AmDTF3Rv8ZSr1Un0FWGi+GQ5ny7W9dJBMomzyMUbzz9stsCml5XB+6xLP2MD+9lO1bHipKS6qkhtZChE="); 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="); // 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/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index 062823754..ccd084a5e 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -312,38 +312,19 @@ public class UtilEnt public static void removeGoalSelectors(Entity entity) { - try + if (((CraftEntity)entity).getHandle() instanceof EntityInsentient) { - if (_goalSelector == null) - { - _goalSelector = EntityInsentient.class.getDeclaredField("goalSelector"); - _goalSelector.setAccessible(true); - } - - if (((CraftEntity)entity).getHandle() instanceof EntityInsentient) - { - EntityInsentient creature = (EntityInsentient)((CraftEntity)entity).getHandle(); - - PathfinderGoalSelector goalSelector = new PathfinderGoalSelector(((CraftWorld)entity.getWorld()).getHandle().methodProfiler); - - _goalSelector.set(creature, goalSelector); - } - } - catch (IllegalArgumentException e) + EntityInsentient creature = (EntityInsentient)((CraftEntity)entity).getHandle(); + creature.goalSelector = new PathfinderGoalSelector(((CraftWorld)entity.getWorld()).getHandle().methodProfiler); + } + } + + public static void removeTargetSelectors(Entity entity) + { + if (((CraftEntity)entity).getHandle() instanceof EntityInsentient) { - e.printStackTrace(); - } - catch (IllegalAccessException e) - { - e.printStackTrace(); - } - catch (NoSuchFieldException e) - { - e.printStackTrace(); - } - catch (SecurityException e) - { - e.printStackTrace(); + EntityInsentient creature = (EntityInsentient)((CraftEntity)entity).getHandle(); + creature.targetSelector = new PathfinderGoalSelector(((CraftWorld)entity.getWorld()).getHandle().methodProfiler); } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java index 722b7f174..63b55feab 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilServer.java @@ -208,11 +208,6 @@ public class UtilServer } } - public static String getWebServerURL() - { - return getPlugin().getConfig().getString(Constants.WEB_CONFIG_KEY); - } - public static BukkitTask runAsync(Runnable runnable) { return getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), runnable); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 37ca50942..a8bc40c04 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -36,6 +36,7 @@ import mineplex.core.account.command.TestRank; import mineplex.core.account.command.UpdateRank; import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.account.event.ClientWebResponseEvent; +import mineplex.core.account.event.RankSaveEvent; import mineplex.core.account.repository.AccountRepository; import mineplex.core.account.repository.token.ClientToken; import mineplex.core.common.Rank; @@ -43,6 +44,7 @@ import mineplex.core.common.timing.TimingManager; import mineplex.core.common.util.Callback; import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTasks; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -552,6 +554,7 @@ public class CoreClientManager extends MiniPlugin client.SetRank(newRank, false); } + UtilServer.CallEvent(new RankSaveEvent(uuid, newRank)); } }, name, uuid, rank, perm); } @@ -571,6 +574,8 @@ public class CoreClientManager extends MiniPlugin if (callback != null) callback.run(newRank); + + UtilServer.CallEvent(new RankSaveEvent(uuid, newRank)); } }, name, uuid, rank, perm); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/RankSaveEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/RankSaveEvent.java new file mode 100644 index 000000000..8453ab6b7 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/event/RankSaveEvent.java @@ -0,0 +1,42 @@ +package mineplex.core.account.event; + +import java.util.UUID; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import mineplex.core.common.Rank; + +public class RankSaveEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private UUID _uuid; + private Rank _rank; + + public RankSaveEvent(UUID uuid, Rank rank) + { + _uuid = uuid; + _rank = rank; + } + + public UUID getUUID() + { + return _uuid; + } + + public Rank getRank() + { + return _rank; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java index 789914489..104365605 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java @@ -16,6 +16,7 @@ import com.google.gson.reflect.TypeToken; import mineplex.cache.player.PlayerCache; import mineplex.core.account.ILoginProcessor; +import mineplex.core.account.event.RankSaveEvent; import mineplex.core.account.repository.token.LoginToken; import mineplex.core.account.repository.token.RankUpdateToken; import mineplex.core.common.Rank; @@ -204,6 +205,8 @@ public class AccountRepository extends MinecraftRepository { if (callback != null) callback.run(response); + + UtilServer.CallEvent(new RankSaveEvent(uuid, rank)); }); }; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index db2e4d154..745df2fee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -449,7 +449,7 @@ public enum Achievement CHAMPIONS_SPECIAL_WIN("Champion of Champions", 3000, new String[]{"Champions CTF.SpecialWin"}, - new String[]{"Win the game with 5 more captures than the other team"}, + new String[]{"Win the game with 5 more flag captures than the other team"}, new int[]{1}, AchievementCategory.CHAMPIONS), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 511e97086..22cfcc59d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -112,7 +112,7 @@ public enum AchievementCategory DRAW_MY_THING("Draw My Thing", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED }, - Material.BOOK_AND_QUILL, 0, GameCategory.CLASSICS, "Extra Tools Kit", false, GameDisplay.Draw.getGameId()), + Material.BOOK_AND_QUILL, 0, GameCategory.CLASSICS, "None", false, GameDisplay.Draw.getGameId()), CHAMPIONS("Champions", new String[] {"Champions Domination", "Champions TDM", "Champions CTF"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED, new StatDisplay("Flags Captured", "Captures") }, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java index 6507b48d6..1eb6ee28f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsManager.java @@ -1,203 +1,254 @@ package mineplex.core.aprilfools; -import java.util.Calendar; - -import org.bukkit.Sound; -import org.bukkit.entity.Player; +import com.google.common.collect.ImmutableMap; +import mineplex.core.MiniPlugin; +import mineplex.core.aprilfools.command.PirateSongCommand; +import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.twofactor.TwoFactorAuth; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.disguise.DisguiseManager; -import mineplex.core.disguise.disguises.DisguiseCow; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +import java.util.Map; public class AprilFoolsManager extends MiniPlugin { - public static AprilFoolsManager Instance; - + + /** + * Manually can be toggled to enable or disable the April Fools activities. + */ + private static final boolean ENABLED = false; + + private static final Map CHAT_REPLACEMENTS = ImmutableMap.builder() + .put("you", "ye") + .put("yes", "aye") + .put("hello", "ahoy") + .put("hey", "ahoy") + .put("hi", "ahoy") + .put("friend", "matey") + .put("friends", "mateys") + .put("chest", "booty") + .put("chests", "booty") + .put("treasure", "booty") + .put("shards", "riches") + .put("sword", "cutlass") + .put("my", "me") + .put("gold", "dubloon") + .put("dog", "seadog") + .put("die", "walk the plank") + .put("kill", "keelhaul") + .put("boat", "ship") + .put("drink", "grog") + .put("water", "grog") + .put("dirt", "flith") + .put("flag", "jolly roger") + .put("am", "be") + .put("are", "be") + .put("your", "yer") + .put("girl", "lass") + .put("woman", "lass") + .put("hell", "davy jones' locker") + .put("nether", "davy jones' locker") + .put("of", "o'") + .put("reward", "bounty") + .put("prize", "bounty") + .put("shoot", "fire in the hole") + .put("clumsy", "landlubber") + .put("clean", "swab") + .put("look", "avast ye") + .put("omg", "shiver my timbers") + .put("wood", "timber") + .put("trash", "poop deck") + .put("noob", "shark bait") + .put("hack", "scurvy") + .put("hacks", "scurvy") + .put("hax", "scurvy") + .put("haks", "scurvy") + .put("hacker", "scurvy") + .put("owner", "captain") + .put("leader", "captain") + .put("lt", "captain") + .put("dev", "firstmate") + .put("developer", "firstmate") + .put("admin", "firstmate") + .build(); + private static final Map RANK_REPLACEMENTS = ImmutableMap.builder() + .put(Rank.ETERNAL, "Captain") + .put(Rank.TITAN, "FirstMate") + .put(Rank.LEGEND, "Boatswain") + .put(Rank.HERO, "Gunner") + .put(Rank.ULTRA, "Parrot") + .build(); + + private static AprilFoolsManager _instance; + private final AprilFoolsRepository _repository; + private final TwoFactorAuth _twoFA; + private boolean _enabled; - private DisguiseManager _disguiseManager; - private CoreClientManager _clientManager; - - protected AprilFoolsManager(JavaPlugin plugin, CoreClientManager clientManager, DisguiseManager disguiseManager) + private boolean _enabledTitle; + + public AprilFoolsManager() { - super("April Fools", plugin); - - _disguiseManager = disguiseManager; - _clientManager = clientManager; - - Calendar c = Calendar.getInstance(); - _enabled = (c.get(Calendar.MONTH) == Calendar.APRIL && c.get(Calendar.DAY_OF_MONTH) == 1); - } - - public static void Initialize(JavaPlugin plugin, CoreClientManager clientManager, DisguiseManager disguiseManager) - { - Instance = new AprilFoolsManager(plugin, clientManager, disguiseManager); + super("April Fools"); + + _instance = this; + _repository = new AprilFoolsRepository(); + _twoFA = require(TwoFactorAuth.class); + setEnabled(true); + _enabledTitle = UtilServer.isHubServer() || UtilServer.isTestServer(); + + if (_enabled) + { + for (Map.Entry entry : RANK_REPLACEMENTS.entrySet()) + { + entry.getKey().setName(entry.getValue()); + } + } } - @EventHandler - public void updateEnabled(UpdateEvent event) + @Override + public void addCommands() { - if (event.getType() != UpdateType.SLOW) - return; - - Calendar c = Calendar.getInstance(); - _enabled = (c.get(Calendar.MONTH) == Calendar.APRIL && c.get(Calendar.DAY_OF_MONTH) == 1); + addCommand(new PirateSongCommand(this)); } - - @EventHandler(priority = EventPriority.LOW) - public void chatAdd(AsyncPlayerChatEvent event) + + @EventHandler(priority = EventPriority.LOWEST) + public void chat(AsyncPlayerChatEvent event) { - if (!_enabled) - return; - - String[] words = event.getMessage().split(" "); - - String out = ""; - for (String word : words) + if (!_enabled || _twoFA.isAuthenticating(event.getPlayer())) { - //Prefix - if (Math.random() > 0.85) + return; + } + + String message = event.getMessage(); + String pirateMessage = ""; + + for (String word : message.split(" ")) + { + String wordLower = word.toLowerCase(); + wordLower = wordLower.replaceAll("[^a-zA-Z0-9]", ""); + + if (CHAT_REPLACEMENTS.containsKey(wordLower)) { - out += "moo"; - - for (int i=0 ; i 0.85) - { - out += word + " "; - - out += "moo"; - - for (int i=0 ; i 0.99) - { - out += "moo"; - - for (int i=3 ; i 0.8) + if (wordLower.length() > 1 && wordLower.charAt(wordLower.length() - 1) == 'g') { - if (_disguiseManager.getDisguise(player) instanceof DisguiseCow) - { - player.getWorld().playSound(player.getLocation(), Sound.COW_IDLE, (float)Math.random() + 0.5f, (float)Math.random() + 0.5f); - } + int g = word.lastIndexOf('g'); + char[] chars = word.toCharArray(); + + chars[g] = '\''; + + word = String.valueOf(chars); } - - continue; + + pirateMessage += word + " "; + } + } + + double random = Math.random(); + + if (random > 0.85) + { + pirateMessage += "matey!"; + } + else if (random > 0.7) + { + String ar = "ar"; + + for (int i = 0; i < 10; i++) + { + if (Math.random() > 0.75) + { + break; + } + + ar += "r"; } - //Disguise - DisguiseCow disguise = new DisguiseCow(player); - disguise.setName(getName(player), _clientManager.Get(player).GetRank()); - disguise.setCustomNameVisible(true); - _disguiseManager.disguise(disguise); + pirateMessage += "a" + ar + "gh"; } + else if (random > 0.55) + { + pirateMessage += "scallywag"; + } + + event.setMessage(pirateMessage.trim()); } - public boolean isActive() + @EventHandler + public void updateRandomMessage(UpdateEvent event) + { + if (!_enabled || !_enabledTitle || event.getType() != UpdateType.SLOW) + { + return; + } + + String message = null; + double random = Math.random(); + + if (random > 0.99) + { + message = "Aye Aye Captain!"; + } + else if (random > 0.98) + { + message = "Arggggggh"; + } + else if (random > 0.97) + { + message = "Mateyy!"; + } + else if (random > 0.96) + { + message = "Shiver me timbers!"; + } + + if (message == null) + { + return; + } + + UtilTextMiddle.display("", message, 10, 40, 10); + } + + public AprilFoolsRepository getRepository() + { + return _repository; + } + + public void setEnabled(boolean enabled) + { + _enabled = ENABLED && enabled; + } + + public boolean isEnabled() { return _enabled; } - public String getName(Player player) + public static AprilFoolsManager getInstance() { - //Name - int index = 0; - boolean hitVowel = false; - for (int i=0 ; i 16) - name = name.substring(0, 16); - - return name; - } - - public void setEnabled(boolean b) - { - Calendar c = Calendar.getInstance(); - _enabled = b && (c.get(Calendar.MONTH) == Calendar.APRIL && c.get(Calendar.DAY_OF_MONTH) == 1); + return _instance; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsRepository.java new file mode 100644 index 000000000..12c22628a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/AprilFoolsRepository.java @@ -0,0 +1,48 @@ +package mineplex.core.aprilfools; + +import mineplex.core.account.CoreClient; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +public class AprilFoolsRepository extends RepositoryBase +{ + + private static final String GET_TREASURE = "SELECT * FROM aprilFoolsTreasure WHERE accountId=?;"; + private static final String INSERT_TREASURE = "INSERT INTO aprilFoolsTreasure VALUES (?,?);"; + + public AprilFoolsRepository() + { + super(DBPool.getAccount()); + } + + public void getTreasure(Consumer> response, CoreClient client) + { + executeQuery(GET_TREASURE, resultSet -> + { + List found = new ArrayList<>(); + + while (resultSet.next()) + { + found.add(resultSet.getInt("treasureId")); + } + + response.accept(found); + }, new ColumnInt("accountId", client.getAccountId())); + } + + public void saveTreasure(CoreClient client, int treasureId) + { + int accountId = client.getAccountId(); + + executeInsert(INSERT_TREASURE, null, + new ColumnInt("accountId", accountId), + new ColumnInt("treasureId", treasureId) + ); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/command/PirateSongCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/command/PirateSongCommand.java new file mode 100644 index 000000000..405d88066 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/aprilfools/command/PirateSongCommand.java @@ -0,0 +1,48 @@ +package mineplex.core.aprilfools.command; + +import mineplex.core.aprilfools.AprilFoolsManager; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilTextMiddle; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +public class PirateSongCommand extends CommandBase +{ + + private static final String[] PIRATE_SONG = { + "Are you ready kids?", + "Aye aye captain!", + "I can't hear you!", + "AYE AYE CAPTAIN!", + "OOOOOOOOOOOOH", + "Who lives in a pineapple under the sea?", + "Spongebob Squarepants!" + }; + + public PirateSongCommand(AprilFoolsManager plugin) + { + super(plugin, Rank.ADMIN, "piratesong"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Plugin.runSyncTimer(new BukkitRunnable() + { + int index = 0; + + @Override + public void run() + { + if (index == PIRATE_SONG.length) + { + cancel(); + return; + } + + UtilTextMiddle.display("", PIRATE_SONG[index++], 10, 60, 10); + } + }, 20, 100); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index b22f39e3c..06f1d69b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -190,6 +190,7 @@ public class BonusManager extends MiniClientPlugin implements I { _youtubers.add(Pair.create("Sigils", "https://www.youtube.com/user/SigilsPlaysGames?sub_confirmation=1")); _youtubers.add(Pair.create("SallyGreenGamer", "https://www.youtube.com/channel/UCt8eypdLUND5CBvgXzEZrxw?sub_confirmation=1")); + _youtubers.add(Pair.create("RustyDawgT", "https://www.youtube.com/user/RustyDawgT?sub_confirmation=1")); } _youtubers.add(Pair.create("SamitoD", "https://www.youtube.com/user/SamitoD?sub_confirmation=1")); @@ -248,6 +249,7 @@ public class BonusManager extends MiniClientPlugin implements I { _youtubers.add(Pair.create("Sigils", "https://www.youtube.com/user/SigilsPlaysGames?sub_confirmation=1")); _youtubers.add(Pair.create("SallyGreenGamer", "https://www.youtube.com/channel/UCt8eypdLUND5CBvgXzEZrxw?sub_confirmation=1")); + _youtubers.add(Pair.create("RustyDawgT", "https://www.youtube.com/user/RustyDawgT?sub_confirmation=1")); } _youtubers.add(Pair.create("SamitoD", "https://www.youtube.com/user/SamitoD?sub_confirmation=1")); @@ -260,7 +262,7 @@ public class BonusManager extends MiniClientPlugin implements I } else { - if(carlLocation != null) + if (carlLocation != null) { _carlNpc.setLocation(carlLocation); } @@ -405,14 +407,14 @@ public class BonusManager extends MiniClientPlugin implements I if (event.getType() != UpdateType.TICK) return; + _animation.itemClean(); + if (_canVote) return; if (!_enabled) return; - _animation.itemClean(); - if (!_animationRunning) return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/animations/AnimationCarl.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/animations/AnimationCarl.java index 4ea6aa93b..eadfe6cfc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/animations/AnimationCarl.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/animations/AnimationCarl.java @@ -48,13 +48,13 @@ public class AnimationCarl extends Animation for (int i = 50; i < 60; i++) { Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i)); - Item coin = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i)); + Item shard = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte) 0, 1, " " + i)); _items.add(gem); - _items.add(coin); + _items.add(shard); Vector vel = new Vector(Math.sin(i * 9/5d), 0, Math.cos(i * 9/5d)); UtilAction.velocity(gem, vel, Math.abs(Math.sin(i * 12/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i * 12/3000d))*0.6, 1, false); - UtilAction.velocity(coin, vel, Math.abs(Math.sin(UtilMath.r(i) * 30/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 30/3000d))*0.6, 1, false); + UtilAction.velocity(shard, vel, Math.abs(Math.sin(UtilMath.r(i) * 30/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 30/3000d))*0.6, 1, false); } } @@ -62,11 +62,11 @@ public class AnimationCarl extends Animation { for (int i = 50; i < 60; i++) { - Item coin = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.DOUBLE_PLANT, (byte) 0, 1, " " + i)); - _items.add(coin); + Item shard = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte) 0, 1, " " + i)); + _items.add(shard); Vector vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d)); - UtilAction.velocity(coin, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false); + UtilAction.velocity(shard, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index 71f36d24d..63087f2f9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -205,22 +205,6 @@ public class Chat extends MiniPlugin return true; } - @EventHandler - public void removeChat(AsyncPlayerChatEvent event) - { - if (event.isCancelled()) - return; - - if (event.isAsynchronous()) - { - for (Iterator playerIterator = event.getRecipients().iterator(); playerIterator.hasNext();) - { - if (!_preferences.get(playerIterator.next()).isActive(Preference.SHOW_CHAT)) - playerIterator.remove(); - } - } - } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onSignChange(SignChangeEvent event) { @@ -369,7 +353,7 @@ public class Chat extends MiniPlugin msgContainsHack(event.getMessage())) { UtilPlayer.message(sender, F.main("Chat", - "Accusing players of cheating in-game is against the rules." + "Accusing players of cheating in-game is against the rules. " + "If you think someone is cheating, please gather evidence and report it at " + F.link("www.mineplex.com/reports"))); event.setCancelled(true); @@ -403,6 +387,11 @@ public class Chat extends MiniPlugin return; } } + + if (event.isAsynchronous()) + { + event.getRecipients().removeIf(player -> !_preferences.get(player).isActive(Preference.SHOW_CHAT)); + } } private boolean msgContainsHack(String msg) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/BroadcastCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/BroadcastCommand.java index 5f2cdd1c2..ed97355c8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/command/BroadcastCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/command/BroadcastCommand.java @@ -5,6 +5,8 @@ import org.bukkit.entity.Player; import mineplex.core.chat.Chat; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; public class BroadcastCommand extends CommandBase @@ -17,6 +19,12 @@ public class BroadcastCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { + if (args.length == 0) + { + UtilPlayer.message(caller, F.main("Broadcast", "What are you broadcasting?")); + return; + } + String announcement = ""; for (String arg : args) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java index f2cccf0a2..02709a26f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/command/CommandBase.java @@ -135,12 +135,12 @@ public abstract class CommandBase implements ICom return matches; } - protected List tabCompletePlayerNames(CommandSender sender, String commandLabel, String[] args) + protected List tabCompletePlayerNames(CommandSender sender, String[] args) { - return tabCompletePlayerNames(sender, commandLabel, args, t -> true); + return tabCompletePlayerNames(sender, args, t -> true); } - protected List tabCompletePlayerNames(CommandSender sender, String commandLabel, String[] args, Predicate filter) + protected List tabCompletePlayerNames(CommandSender sender, String[] args, Predicate filter) { if (sender instanceof Player) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java index 66cb24998..73af59a89 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/CostumePage.java @@ -1,23 +1,26 @@ package mineplex.core.cosmetic.ui.page; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + import mineplex.core.account.CoreClientManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuit; import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuit; import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuit; +import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksSuit; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.ItemGadget; import mineplex.core.gadget.types.OutfitGadget; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; /** * Created by shaun on 14-09-15. @@ -42,11 +45,13 @@ public class CostumePage extends GadgetPage OutfitGadget outfitGadget = ((OutfitGadget) gadget); - int offset = 0; + int offset; if (gadget instanceof OutfitRaveSuit) offset = 0; else if (gadget instanceof OutfitSpaceSuit) offset = 1; - else offset = 2; + else if (gadget instanceof OutfitFreezeSuit) offset = 2; + else if (gadget instanceof OutfitStPatricksSuit) offset = 3; + else offset = 4; slot = offset + 1 + 18; //1 buffer to left, 18 = 2 lines down 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 d6dd97153..713429dc6 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 @@ -175,6 +175,11 @@ public class GadgetPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Love Chests"); } + else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -18) + { + itemLore.add(C.cBlack); + itemLore.add(C.cBlue + "Found in St Patrick's Chests"); + } //Rank Unlocks else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -10) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java index 990d2905b..6e670effc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java @@ -113,6 +113,11 @@ public class MountPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Thankful Treasure"); } + else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -18) + { + itemLore.add(C.cBlack); + itemLore.add(C.cBlue + "Found in St Patrick's Chests"); + } else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -14) { itemLore.add(C.cBlack); 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 503f2897d..f7b831eca 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 @@ -22,6 +22,8 @@ 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; import mineplex.core.account.CoreClientManager; import mineplex.core.common.currency.GlobalCurrency; @@ -111,6 +113,11 @@ public class PetPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.add(C.cBlue + "Found in Haunted Chests"); } + else if (pet.getPrice() == -18) + { + itemLore.add(C.cBlack); + itemLore.add(C.cBlue + "Found in St Patrick's Chests"); + } else if (pet.getPrice() == -14) { itemLore.add(C.cBlack); @@ -165,9 +172,13 @@ public class PetPage extends ShopPageBase itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Disable"); - addButton(slot, new ShopItem(pet.getMaterial(), pet.getData(), - pet.getName() + " (" + C.cWhite + petName + C.cGreen + ")", - itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivatePetButton(this, getPlugin().getPetManager())); + ItemStack item = pet.getDisplayItem(); + ItemMeta itemMeta = item.getItemMeta(); + itemMeta.setDisplayName(C.cGreen + C.Bold + pet.getName() + C.cGreen + " (" + C.cWhite + petName + C.cGreen + ")"); + itemMeta.setLore(itemLore); + item.setItemMeta(itemMeta); + + addButton(slot, new ShopItem(item, false, false).hideInfo(), new DeactivatePetButton(this, getPlugin().getPetManager())); addGlow(slot); } @@ -175,29 +186,14 @@ public class PetPage extends ShopPageBase { itemLore.add(C.cBlack); itemLore.add(C.cGreen + "Click to Enable"); - /* - ItemStack petItem = ItemStackFactory.Instance.CreateStack(pet.getMaterial(), pet.getData(), 1, - pet.getName() + " (" + C.cWhite + petName + C.cGreen + ")", itemLore); - IButton iButton = new ActivatePetButton(pet, this); + ItemStack item = pet.getDisplayItem(); + ItemMeta itemMeta = item.getItemMeta(); + itemMeta.setDisplayName(C.cGreen + C.Bold + pet.getName() + C.cGreen + " (" + C.cWhite + petName + C.cGreen + ")"); + itemMeta.setLore(itemLore); + item.setItemMeta(itemMeta); - if (pet.equals(PetType.SHULKER)) - { - petItem = UtilItem.getVersionSpecificItem(_player, UtilPlayer.PlayerVersion._1_9, petItem); - if (petItem.getType().equals(Material.BARRIER)) - { - iButton = null; - } - else - { - // Does not set the item stack yet - //petItem.setType(Material.getMaterial(201)); - } - }*/ - - addButton(slot, new ShopItem(pet.getMaterial(), pet.getData(), - pet.getName() + " (" + C.cWhite + petName + C.cGreen + ")", - itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivatePetButton(pet, this)); + addButton(slot, new ShopItem(item, false, false).hideInfo(), new ActivatePetButton(pet, this)); //addButton(slot, new ShopItem(petItem, false, false), iButton); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/BasicMSSQLProvider.java b/Plugins/Mineplex.Core/src/mineplex/core/database/BasicMSSQLProvider.java index 45f4b7b03..f5bd25757 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/BasicMSSQLProvider.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/database/BasicMSSQLProvider.java @@ -7,6 +7,7 @@ import java.util.function.Consumer; import org.bukkit.scheduler.BukkitTask; +import mineplex.core.common.Constants; import mineplex.core.common.util.UtilServer; import mineplex.core.server.remotecall.JsonWebCall; import mineplex.core.thread.ThreadPool; @@ -17,7 +18,7 @@ import mineplex.serverdata.database.DatabaseRunnable; @Deprecated public class BasicMSSQLProvider implements MSSQLProvider { - private final String _webAddress = UtilServer.getWebServerURL(); + private final String _webAddress = Constants.WEB_ADDRESS; // Queue for failed processes private final Object QUEUE_LOCK = new Object(); 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 dfe3d6fb2..ac7443d69 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/DisguiseCommand.java @@ -19,6 +19,10 @@ public class DisguiseCommand extends CommandBase implemen { if (args == null || args.length == 0) { + Plugin.runAsync(() -> + { + new PlayerDisguiseNotification(Plugin.getRealName(caller), caller.getUniqueId(), caller.getName()).publish(); + }); Plugin.undisguise(caller); return; } @@ -28,6 +32,11 @@ public class DisguiseCommand extends CommandBase implemen return; } + Plugin.runAsync(() -> + { + new PlayerDisguiseNotification(Plugin.getRealName(caller), caller.getUniqueId(), 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 fd1b44c80..caf2b5b1d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseManager.java @@ -331,6 +331,12 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler } } + public String getRealName(Player caller) + { + CoreClient coreClient = _clients.Get(caller); + return coreClient == null ? caller.getName() : coreClient.getName(); + } + public void undisguise(Player caller) { if (!isDisguised(caller)) @@ -462,99 +468,92 @@ public class PlayerDisguiseManager extends MiniPlugin implements IPacketHandler if (!requestedUsername.equalsIgnoreCase(caller.getName())) { - Rank otherRank = Rank.ALL; - CoreClient other = new CoreClient(requestedUsername, requestedProfile.getId()); - try + getClientManager().getOrLoadClient(requestedUsername, other -> { - getClientManager().LoadClient(other, requestedProfile.getId(), caller.getAddress().getAddress().getHostAddress()); - otherRank = other.GetRank(); - } - catch (NullPointerException exception) - { - other = null; - } + Rank otherRank = other != null ? other.GetRank() : Rank.ALL; - if (otherRank.has(Rank.TWITCH)) - { - UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, YouTubers or Twitchers!")); - return; - } - - if (other != null) - { - PunishClient pclient = getPunishManager().GetClient(requestedUsername); - if (pclient != null && (pclient.IsBanned() || pclient.IsMuted())) + if (otherRank.has(Rank.TWITCH)) { - UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as players who are banned/muted!")); + UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as staff, YouTubers or Twitchers!")); return; } - } - callerClient.disguise(requestedUsername, requestedProfile.getId(), otherRank); - - _mapping.put(callerClient.getDisguisedAs().toLowerCase(), callerClient.getName()); - - System.out.println("================="); - System.out.println("Disguising " + caller.getName() + " as:"); - System.out.println(requestedProfile.getName() + " id " + requestedProfile.getId()); - System.out.println("Properties:"); - for (Map.Entry p : requestedProfile.getProperties().entries()) - { - System.out.println("\t" + p.getKey() + " " + p.getValue().getName()); - System.out.println("\t" + p.getValue().getValue()); - System.out.println("\t" + p.getValue().getSignature()); - } - System.out.println("================="); - - DisguisePlayer disguisePlayer = new DisguisePlayer(caller, requestedProfile); - disguisePlayer.showInTabList(true, 0); - allow(caller); - getDisguiseManager().disguise(disguisePlayer, () -> - { - GameProfile callerProfile = ((CraftPlayer) caller).getProfile(); - - require(ScoreboardManager.class).handlePlayerQuit(disguisePlayer.getOriginalProfile().getName()); - - try + if (other != null) { - UtilGameProfile.changeName(callerProfile, disguisePlayer.getProfile().getName()); - UtilGameProfile.changeId(callerProfile, disguisePlayer.getProfile().getId()); - - Field playersByName = PlayerList.class.getDeclaredField("playersByName"); - playersByName.setAccessible(true); - Map map = (Map) playersByName.get(MinecraftServer.getServer().getPlayerList()); - map.remove(disguisePlayer.getOriginalProfile().getName()); - map.put(disguisePlayer.getProfile().getName(), disguisePlayer.getEntity()); - } - catch (Throwable t) - { - t.printStackTrace(); + PunishClient pclient = getPunishManager().GetClient(requestedUsername); + if (pclient != null && (pclient.IsBanned() || pclient.IsMuted())) + { + UtilPlayer.message(caller, F.main("Disguise", "You can't disguise as players who are banned/muted!")); + return; + } } - require(ScoreboardManager.class).handlePlayerJoin(disguisePlayer.getName()); + callerClient.disguise(requestedUsername, requestedProfile.getId(), otherRank); - callerProfile.getProperties().clear(); - callerProfile.getProperties().putAll(disguisePlayer.getProfile().getProperties()); + _mapping.put(callerClient.getDisguisedAs().toLowerCase(), callerClient.getName()); - callerProfile.getProperties().removeAll(ORIGINAL_UUID_KEY); - callerProfile.getProperties().put(ORIGINAL_UUID_KEY, new Property(ORIGINAL_UUID_KEY, caller.getUniqueId().toString())); + System.out.println("================="); + System.out.println("Disguising " + caller.getName() + " as:"); + System.out.println(requestedProfile.getName() + " id " + requestedProfile.getId()); + System.out.println("Properties:"); + for (Map.Entry p : requestedProfile.getProperties().entries()) + { + System.out.println("\t" + p.getKey() + " " + p.getValue().getName()); + System.out.println("\t" + p.getValue().getValue()); + System.out.println("\t" + p.getValue().getSignature()); + } + System.out.println("================="); - require(FriendManager.class).updatePlayerStatus(disguisePlayer.getOriginalProfile().getId(), null); - require(FriendManager.class).updatePlayerStatus(disguisePlayer.getProfile().getId(), new PlayerStatus(disguisePlayer.getProfile().getId(), requestedUsername, _serverName)); + DisguisePlayer disguisePlayer = new DisguisePlayer(caller, requestedProfile); + disguisePlayer.showInTabList(true, 0); + allow(caller); + getDisguiseManager().disguise(disguisePlayer, () -> + { + GameProfile callerProfile = ((CraftPlayer) caller).getProfile(); - getPreferencesManager().handlePlayerJoin(caller, true); + require(ScoreboardManager.class).handlePlayerQuit(disguisePlayer.getOriginalProfile().getName()); - _disguises.put(caller.getUniqueId(), disguisePlayer); + try + { + UtilGameProfile.changeName(callerProfile, disguisePlayer.getProfile().getName()); + UtilGameProfile.changeId(callerProfile, disguisePlayer.getProfile().getId()); - UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + requestedUsername)); + Field playersByName = PlayerList.class.getDeclaredField("playersByName"); + playersByName.setAccessible(true); + Map map = (Map) playersByName.get(MinecraftServer.getServer().getPlayerList()); + map.remove(disguisePlayer.getOriginalProfile().getName()); + map.put(disguisePlayer.getProfile().getName(), disguisePlayer.getEntity()); + } + catch (Throwable t) + { + t.printStackTrace(); + } - UtilServer.CallEvent(new PlayerDisguisedEvent(caller)); + require(ScoreboardManager.class).handlePlayerJoin(disguisePlayer.getName()); - storeDisguiseData(caller, requestedUsername, requestedProfile); + callerProfile.getProperties().clear(); + callerProfile.getProperties().putAll(disguisePlayer.getProfile().getProperties()); - _pendingDisguise.remove(requestedUsername.toLowerCase()); + callerProfile.getProperties().removeAll(ORIGINAL_UUID_KEY); + callerProfile.getProperties().put(ORIGINAL_UUID_KEY, new Property(ORIGINAL_UUID_KEY, caller.getUniqueId().toString())); - _cannotJoin.remove(requestedUsername.toLowerCase()); + require(FriendManager.class).updatePlayerStatus(disguisePlayer.getOriginalProfile().getId(), null); + require(FriendManager.class).updatePlayerStatus(disguisePlayer.getProfile().getId(), new PlayerStatus(disguisePlayer.getProfile().getId(), requestedUsername, _serverName)); + + getPreferencesManager().handlePlayerJoin(caller, true); + + _disguises.put(caller.getUniqueId(), disguisePlayer); + + UtilPlayer.message(caller, F.main("Disguise", "Disguise Active: " + ChatColor.RESET + requestedUsername)); + + UtilServer.CallEvent(new PlayerDisguisedEvent(caller)); + + storeDisguiseData(caller, requestedUsername, requestedProfile); + + _pendingDisguise.remove(requestedUsername.toLowerCase()); + + _cannotJoin.remove(requestedUsername.toLowerCase()); + }); }); } else diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseNotification.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseNotification.java new file mode 100644 index 000000000..e63c0ff87 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/playerdisguise/PlayerDisguiseNotification.java @@ -0,0 +1,57 @@ +package mineplex.core.disguise.playerdisguise; + +import java.util.UUID; + +import mineplex.serverdata.commands.ServerCommand; + +public class PlayerDisguiseNotification extends ServerCommand +{ + private String _realPlayerName; + private UUID _playerUUID; + private boolean _disguising; + private String _disguisedName; + private String _disguisedSkin; + + public PlayerDisguiseNotification(String realPlayerName, UUID playerUUID, String disguisedName, String disguisedSkin) + { + _realPlayerName = realPlayerName; + _playerUUID = playerUUID; + _disguising = true; + _disguisedName = disguisedName; + _disguisedSkin = disguisedSkin; + } + + public PlayerDisguiseNotification(String realPlayerName, UUID playerUUID, String disguisedName) + { + _realPlayerName = realPlayerName; + _playerUUID = playerUUID; + _disguising = false; + _disguisedName = disguisedName; + _disguisedSkin = null; + } + + public String getRealPlayerName() + { + return _realPlayerName; + } + + public UUID getPlayerUUID() + { + return _playerUUID; + } + + public boolean isDisguising() + { + return _disguising; + } + + public String getDisguisedName() + { + return _disguisedName; + } + + public String getDisguisedSkin() + { + return _disguisedSkin; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java index 691c350f0..62546317e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/friend/command/AddFriend.java @@ -47,6 +47,6 @@ public class AddFriend extends CommandBase @Override public List onTabComplete(CommandSender sender, String commandLabel, String[] args) { - return tabCompletePlayerNames(sender, commandLabel, args); + return tabCompletePlayerNames(sender, args); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 0537100f2..afedd8807 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -2,8 +2,10 @@ package mineplex.core.gadget; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.function.Predicate; @@ -28,7 +30,6 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; @@ -153,6 +154,10 @@ import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitBoots; import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitChestplate; import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitHelmet; import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitLeggings; +import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksBoots; +import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksChestplate; +import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksHat; +import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksLeggings; import mineplex.core.gadget.gadgets.outfit.windupsuit.OutfitWindUpSuitBoosterManager; import mineplex.core.gadget.gadgets.particle.ParticleChristmasTree; import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes; @@ -160,6 +165,7 @@ 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.ParticleWingsAngel; +import mineplex.core.gadget.gadgets.particle.ParticleWingsBee; import mineplex.core.gadget.gadgets.particle.ParticleWingsDemons; import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal; import mineplex.core.gadget.gadgets.particle.ParticleWingsLove; @@ -179,6 +185,7 @@ import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; import mineplex.core.gadget.gadgets.taunts.EternalTaunt; +import mineplex.core.gadget.gadgets.taunts.RainbowTaunt; import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken; import mineplex.core.gadget.gadgets.wineffect.WinEffectFlames; import mineplex.core.gadget.gadgets.wineffect.WinEffectHalloween; @@ -206,6 +213,7 @@ import mineplex.core.gadget.set.SetWisdom; import mineplex.core.gadget.set.suits.SetFreezeSuit; import mineplex.core.gadget.set.suits.SetRaveSuit; import mineplex.core.gadget.set.suits.SetSpaceSuit; +import mineplex.core.gadget.set.suits.SetStPatricksSuit; import mineplex.core.gadget.types.ArrowEffectGadget; import mineplex.core.gadget.types.BalloonGadget; import mineplex.core.gadget.types.DeathEffectGadget; @@ -253,10 +261,10 @@ public class GadgetManager extends MiniPlugin private TreasureManager _treasureManager; private SoulManager _soulManager; - private NautHashMap> _gadgets; + private Map> _gadgets; - private final NautHashMap _lastMove = new NautHashMap<>(); - private final NautHashMap> _playerActiveGadgetMap = new NautHashMap<>(); + private final Map _lastMove = new HashMap<>(); + private final Map> _playerActiveGadgetMap = new HashMap<>(); private final HashSet _sets = new HashSet<>(); @@ -315,8 +323,11 @@ public class GadgetManager extends MiniPlugin addSet(new SetRaveSuit(this)); addSet(new SetSpaceSuit(this)); addSet(new SetFreezeSuit(this)); + addSet(new SetStPatricksSuit(this)); // Hidden in this update //addSet(new SetWindUpSuit(this)); + + // Sets addSet(new SetParty(this)); addSet(new SetCupidsLove(this)); addSet(new SetEmerald(this)); @@ -330,7 +341,7 @@ public class GadgetManager extends MiniPlugin private void createGadgets() { - _gadgets = new NautHashMap<>(); + _gadgets = new HashMap<>(); // Items addGadget(new ItemEtherealPearl(this)); @@ -350,6 +361,8 @@ public class GadgetManager extends MiniPlugin addGadget(new ItemBow(this)); addGadget(new ItemLovePotion(this)); addGadget(new ItemFlowerGift(this)); + // NEXT MONTH'S PPC + //addGadget(new ItemBubbleBlaster(this)); // Costume addGadget(new OutfitRaveSuitHelmet(this)); @@ -372,6 +385,11 @@ public class GadgetManager extends MiniPlugin addGadget(new OutfitFreezeSuitChestplate(this)); addGadget(new OutfitFreezeSuitLeggings(this)); addGadget(new OutfitFreezeSuitBoots(this)); + + addGadget(new OutfitStPatricksHat(this)); + addGadget(new OutfitStPatricksChestplate(this)); + addGadget(new OutfitStPatricksLeggings(this)); + addGadget(new OutfitStPatricksBoots(this)); addGadget(new OutfitTeam(this, "Team Helmet", -1, ArmorSlot.HELMET, Material.LEATHER_HELMET, (byte)0)); addGadget(new OutfitTeam(this, "Team Shirt", -1, ArmorSlot.CHEST, Material.LEATHER_CHESTPLATE, (byte)0)); @@ -432,6 +450,7 @@ public class GadgetManager extends MiniPlugin addGadget(new ParticleFreedom(this)); addGadget(new ParticleChristmasTree(this)); addGadget(new ParticleWingsLove(this)); + addGadget(new ParticleWingsBee(this)); // Arrow Trails addGadget(new ArrowTrailFrostLord(this)); @@ -561,6 +580,7 @@ public class GadgetManager extends MiniPlugin // TAUNTS!!! addGadget(new EternalTaunt(this)); addGadget(new BlowAKissTaunt(this)); + addGadget(new RainbowTaunt(this)); // Gem Hunters Mounts for (MountType mount : MountType.values()) @@ -1035,7 +1055,7 @@ public class GadgetManager extends MiniPlugin public void setActive(Player player, Gadget gadget) { if (!_playerActiveGadgetMap.containsKey(player)) - _playerActiveGadgetMap.put(player, new NautHashMap()); + _playerActiveGadgetMap.put(player, new HashMap<>()); _playerActiveGadgetMap.get(player).put(gadget.getGadgetType(), gadget); } @@ -1043,7 +1063,7 @@ public class GadgetManager extends MiniPlugin public Gadget getActive(Player player, GadgetType gadgetType) { if (!_playerActiveGadgetMap.containsKey(player)) - _playerActiveGadgetMap.put(player, new NautHashMap()); + _playerActiveGadgetMap.put(player, new HashMap<>()); return _playerActiveGadgetMap.get(player).get(gadgetType); } @@ -1051,7 +1071,7 @@ public class GadgetManager extends MiniPlugin public void removeActive(Player player, Gadget gadget) { if (!_playerActiveGadgetMap.containsKey(player)) - _playerActiveGadgetMap.put(player, new NautHashMap()); + _playerActiveGadgetMap.put(player, new HashMap<>()); _playerActiveGadgetMap.get(player).remove(gadget.getGadgetType()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/minestrike/GameModifierMineStrikeSkin.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/minestrike/GameModifierMineStrikeSkin.java index df1cf150f..982e97411 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/minestrike/GameModifierMineStrikeSkin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/minestrike/GameModifierMineStrikeSkin.java @@ -86,7 +86,7 @@ public class GameModifierMineStrikeSkin extends GameModifierGadget @Override public void enableCustom(Player player, boolean message) { - Manager.getGameModifiers(getGameType()).stream().filter(getWeaponFilter(_weapon)).forEach(g -> g.disable(player)); + Manager.getGameModifiers(getGameType()).stream().filter(getWeaponFilter(_weapon).and(weapon -> weapon != this)).forEach(g -> g.disable(player)); super.enableCustom(player, message); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBubbleBlaster.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBubbleBlaster.java new file mode 100644 index 000000000..525cabf58 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBubbleBlaster.java @@ -0,0 +1,121 @@ +package mineplex.core.gadget.gadgets.item; + +import java.awt.Color; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.bukkit.Material; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.Ammo; +import mineplex.core.gadget.types.ItemGadget; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class ItemBubbleBlaster extends ItemGadget +{ + + private Map _armorStands = new HashMap<>(); + + public ItemBubbleBlaster(GadgetManager manager) + { + super(manager, "Bubble Blaster", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), + -14, Material.DIAMOND_BARDING, (byte) 0, 5000, new Ammo("Bubble", "Bubble", Material.DIAMOND_BARDING, (byte) 0, new String[]{C.cGray + "Placeholder"}, -5, 1)); + } + + @Override + public void disableCustom(Player player, boolean message) + { + super.disableCustom(player, message); + } + + @Override + public void ActivateCustom(Player player) + { + + } + + @Override + @EventHandler + public void Activate(PlayerInteractEvent event) + { + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if (UtilBlock.usable(event.getClickedBlock())) + return; + + if (!UtilGear.isMat(event.getPlayer().getItemInHand(), this.getDisplayMaterial())) + return; + + Player player = event.getPlayer(); + + if (!isActive(player)) + return; + + event.setCancelled(true); + + player.getInventory().setItem(Manager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(getDisplayMaterial(), getDisplayData(), 1, F.item(Manager.getInventoryManager().Get(player).getItemCount(getName()) + " " + getName()))); + + // TODO CHANGE COLOR IF RAINBOW + // TODO COOLDOWN AFTER MAX OF 5 SECONDS HOLDING + // TODO LAUNCH MULTIPLE WHILE HOLDING + + ArmorStand armorStand = player.getWorld().spawn(player.getLocation().add(0, 1, 0), ArmorStand.class); + armorStand.setItemInHand(new ItemStack(Material.STAINED_GLASS, 1, (byte) UtilMath.random.nextInt(15))); + armorStand.setSmall(true); + armorStand.setVisible(false); + + _armorStands.put(armorStand, player); + + double x = UtilMath.random(0.5, 1) - 1.25, z = UtilMath.random(0.5, 1) - 1.25; + double sub = UtilMath.random(0.5, 1); + if (sub > 0.75) + UtilAction.velocity(armorStand, player.getLocation().getDirection().add(new Vector(x, 0, z)), 0.25, false, 0, 0.5, 1, false); + else + UtilAction.velocity(armorStand, player.getLocation().getDirection().subtract(new Vector(x, 0, z)), 0.25, false, 0, 0.5, 1, false); + } + + @EventHandler + public void updateArmorStand(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + Iterator> iterator = _armorStands.entrySet().iterator(); + while (iterator.hasNext()) + { + Map.Entry entry = iterator.next(); + ArmorStand armorStand = entry.getKey(); + Player player = entry.getValue(); + if (armorStand.getTicksLived() >= 20) + { + ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(Color.WHITE), armorStand.getLocation()); + coloredParticle.display(); + armorStand.remove(); + iterator.remove(); + } + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java index cb13b4ff5..c309fb7a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphPumpkinKing.java @@ -4,6 +4,8 @@ import java.util.List; import java.util.Map; import java.util.Random; +import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; + import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Item; @@ -32,12 +34,14 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketInfo; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.visibility.VisibilityManager; -public class MorphPumpkinKing extends MorphGadget +public class MorphPumpkinKing extends MorphGadget implements IPacketHandler { private static final int CROWN_POINTS = 12; @@ -57,6 +61,7 @@ public class MorphPumpkinKing extends MorphGadget -1, Material.PUMPKIN, (byte)0); + manager.getPacketManager().addPacketHandler(this, true, PacketPlayInUseEntity.class); } @Override @@ -123,7 +128,20 @@ public class MorphPumpkinKing extends MorphGadget _bombs.removeIf(bomb -> bomb.update()); } } - + + @Override + public void handle(PacketInfo packetInfo) + { + if (packetInfo.getPacket() instanceof PacketPlayInUseEntity) + { + PacketPlayInUseEntity packetPlayInUseEntity = (PacketPlayInUseEntity) packetInfo.getPacket(); + if (packetPlayInUseEntity.action == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) + for (JackOBomb bomb : _bombs) + if (bomb._ent.getEntityId() == packetPlayInUseEntity.a) + packetInfo.setCancelled(true); + } + } + private class JackOBomb { private Player _user; @@ -151,6 +169,12 @@ public class MorphPumpkinKing extends MorphGadget { return true; } + if (!_user.isOnline()) + { + Manager.getDisguiseManager().undisguise(_disguise); + _ent.remove(); + _done = true; + } if (System.currentTimeMillis() >= _detonation) { UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _ent.getLocation(), null, 0, 1, ViewDist.NORMAL); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSquid.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSquid.java index 096f453fd..a78f515f9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSquid.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphSquid.java @@ -63,6 +63,12 @@ public class MorphSquid extends MorphGadget implements IThrown { removeArmor(player); UtilMorph.undisguise(player, Manager.getDisguiseManager()); + + if (player.getInventory().getBoots() != null && player.getInventory().getBoots().getType() == Material.DIAMOND_BOOTS) + { + player.getInventory().setBoots(new ItemStack(Material.AIR)); + player.removePotionEffect(PotionEffectType.SPEED); + } } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/OutfitTeam.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/OutfitTeam.java index 0004420cd..bcda0800d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/OutfitTeam.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/OutfitTeam.java @@ -109,7 +109,7 @@ public class OutfitTeam extends OutfitGadget Player player = event.getPlayer(); - if (!event.getMessage().toLowerCase().startsWith("/team")) + if (!event.getMessage().toLowerCase().startsWith("/team ")) return; event.setCancelled(true); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/stpatricks/OutfitStPatricksBoots.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/stpatricks/OutfitStPatricksBoots.java new file mode 100644 index 000000000..1acc70e2e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/stpatricks/OutfitStPatricksBoots.java @@ -0,0 +1,15 @@ +package mineplex.core.gadget.gadgets.outfit.stpatricks; + +import org.bukkit.Material; + +import mineplex.core.gadget.GadgetManager; + +public class OutfitStPatricksBoots extends OutfitStPatricksSuit +{ + + public OutfitStPatricksBoots(GadgetManager manager) + { + super(manager, "Leprechaun's Boots", -18, ArmorSlot.BOOTS, Material.LEATHER_BOOTS, (byte) 0, "St Patrick's Boots"); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/stpatricks/OutfitStPatricksChestplate.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/stpatricks/OutfitStPatricksChestplate.java new file mode 100644 index 000000000..a0b264350 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/stpatricks/OutfitStPatricksChestplate.java @@ -0,0 +1,15 @@ +package mineplex.core.gadget.gadgets.outfit.stpatricks; + +import org.bukkit.Material; + +import mineplex.core.gadget.GadgetManager; + +public class OutfitStPatricksChestplate extends OutfitStPatricksSuit +{ + + public OutfitStPatricksChestplate(GadgetManager manager) + { + super(manager, "Leprechaun's Chest", -18, ArmorSlot.CHEST, Material.LEATHER_CHESTPLATE, (byte) 0, "St Patrick's Chest"); + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/stpatricks/OutfitStPatricksHat.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/stpatricks/OutfitStPatricksHat.java new file mode 100644 index 000000000..dcffccdf4 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/stpatricks/OutfitStPatricksHat.java @@ -0,0 +1,15 @@ +package mineplex.core.gadget.gadgets.outfit.stpatricks; + +import org.bukkit.Material; + +import mineplex.core.gadget.GadgetManager; + +public class OutfitStPatricksHat extends OutfitStPatricksSuit +{ + + public OutfitStPatricksHat(GadgetManager manager) + { + super(manager, "Leprechaun's Hat", -18, ArmorSlot.HELMET, Material.LEATHER_HELMET, (byte) 0, "St Patrick's Hat"); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/stpatricks/OutfitStPatricksLeggings.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/stpatricks/OutfitStPatricksLeggings.java new file mode 100644 index 000000000..18fcdf092 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/stpatricks/OutfitStPatricksLeggings.java @@ -0,0 +1,15 @@ +package mineplex.core.gadget.gadgets.outfit.stpatricks; + +import org.bukkit.Material; + +import mineplex.core.gadget.GadgetManager; + +public class OutfitStPatricksLeggings extends OutfitStPatricksSuit +{ + + public OutfitStPatricksLeggings(GadgetManager manager) + { + super(manager, "Leprechaun's Pants", -18, ArmorSlot.LEGS, Material.LEATHER_LEGGINGS, (byte) 0, "St Patrick's Pants"); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/stpatricks/OutfitStPatricksSuit.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/stpatricks/OutfitStPatricksSuit.java new file mode 100644 index 000000000..ef4f511b2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/outfit/stpatricks/OutfitStPatricksSuit.java @@ -0,0 +1,117 @@ +package mineplex.core.gadget.gadgets.outfit.stpatricks; + +import java.util.HashSet; +import java.util.Iterator; + +import org.bukkit.Color; +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.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.util.Vector; + +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.gadget.GadgetManager; +import mineplex.core.gadget.types.OutfitGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class OutfitStPatricksSuit extends OutfitGadget +{ + + private HashSet _items = new HashSet<>(); + + public OutfitStPatricksSuit(GadgetManager manager, String name, int cost, OutfitGadget.ArmorSlot slot, Material mat, byte data, String... altNames) + { + super(manager, name, UtilText.splitLinesToArray(new String[]{C.cGray + "Wherever a Leprechaun goes he leaves behind a trail of gold and a hint of spring."}, LineFormat.LORE), cost, slot, mat, data, altNames); + setColor(Color.fromRGB(0, 153, 0)); + ItemStack displayItem = new ItemStack(mat, 1, data); + if (displayItem.getItemMeta() instanceof LeatherArmorMeta) + { + LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) displayItem.getItemMeta(); + leatherArmorMeta.setColor(Color.fromRGB(0, 153, 0)); + displayItem.setItemMeta(leatherArmorMeta); + } + setDisplayItem(displayItem); + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player, message); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + // Prevents event running 4 times + if (getSlot() != ArmorSlot.HELMET) + return; + + if (event.getType() == UpdateType.TICK) + cleanItems(); + + if (event.getType() == UpdateType.FASTER) + { + for (Player player : getActive()) + { + if (setActive(player)) + { + ItemStack itemStack = new ItemStack(Material.GOLD_INGOT); + ItemMeta itemMeta = itemStack.getItemMeta(); + itemMeta.setDisplayName(player.getName() + "DROPPED" + System.currentTimeMillis() + UtilMath.random.nextInt()); + itemStack.setItemMeta(itemMeta); + Item gold = player.getWorld().dropItem(player.getLocation().add(0.5, 1.5, 0.5), itemStack); + _items.add(gold); + gold.setVelocity(new Vector((Math.random() - 0.5) * 0.3, Math.random() - 0.4, (Math.random() - 0.5) * 0.3)); + } + } + } + } + + @EventHandler + public void onItemPickup(PlayerPickupItemEvent event) + { + // Prevents event running 4 times + if (getSlot() != ArmorSlot.HELMET) + return; + + if (_items.contains(event.getItem())) + { + event.setCancelled(true); + } + } + + private boolean setActive(Player player) + { + return getSet() != null && getSet().isActive(player); + } + + public void cleanItems() + { + Iterator it = _items.iterator(); + while (it.hasNext()) + { + Item item = it.next(); + if (item.getTicksLived() >= 20) + { + item.remove(); + it.remove(); + } + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleWingsBee.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleWingsBee.java new file mode 100644 index 000000000..b413766e1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleWingsBee.java @@ -0,0 +1,55 @@ +package mineplex.core.gadget.gadgets.particle; + +import java.awt.Color; +import java.time.Month; +import java.time.YearMonth; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import mineplex.core.common.shape.ShapeWings; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class ParticleWingsBee extends ParticleGadget +{ + + private ShapeWings _wingsBlack = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1, 1, 1), 1, 0, '$', ShapeWings.DEFAULT_ROTATION, ShapeWings.BEE_WING_PATTERN); + private ShapeWings _wingsYellow = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1, 1, 1), 1, 0, '#', ShapeWings.DEFAULT_ROTATION, ShapeWings.BEE_WING_PATTERN); + + public ParticleWingsBee(GadgetManager manager) + { + super(manager, "Bumblebee's Wings", + UtilText.splitLineToArray(C.cGray + "Float like a butterfly and sting like a bee with these new spring wings!", LineFormat.LORE), + -14, Material.WOOL, (byte) 4, YearMonth.of(2017, Month.APRIL)); + } + + @Override + public void playParticle(Player player, UpdateEvent event) + { + Location loc = player.getLocation().add(0, 1, 0).add(player.getLocation().getDirection().multiply(-0.4)); + if (Manager.isMoving(player)) + { + if (event.getType() == UpdateType.TICK) + { + _wingsBlack.displayColoredParticle(loc, Color.BLACK); + _wingsYellow.displayColoredParticle(loc, Color.YELLOW); + } + return; + } + + if (event.getType() == UpdateType.FAST) + { + _wingsBlack.displayColored(loc, Color.BLACK); + _wingsYellow.displayColored(loc, Color.YELLOW); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java index aa16f3bcc..fdc5da288 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/BlowAKissTaunt.java @@ -25,7 +25,7 @@ public class BlowAKissTaunt extends TauntGadget public BlowAKissTaunt(GadgetManager manager) { super(manager, "Blow A Kiss", UtilText.splitLinesToArray(new String[]{ - C.cWhite + "Type /taunt in game to blow a kiss at your enemies.", + C.cWhite + "Use /taunt in game to blow a kiss at your enemies.", C.cRed + "Cannot be used while in PvP!"}, LineFormat.LORE), -17, Material.GLASS, (byte) 0); setDisplayItem(ItemStackFactory.Instance.createCustomPotion(PotionType.INSTANT_HEAL)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java new file mode 100644 index 000000000..de81b6a1b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/taunts/RainbowTaunt.java @@ -0,0 +1,68 @@ +package mineplex.core.gadget.gadgets.taunts; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +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.TauntGadget; +import mineplex.core.particleeffects.EffectLocation; +import mineplex.core.particleeffects.RainbowTauntEffect; +import mineplex.core.recharge.Recharge; + +public class RainbowTaunt extends TauntGadget +{ + + private static final int COOLDOWN = 30000; + private static final int PVP_COOLDOWN = 10000; + + public RainbowTaunt(GadgetManager manager) + { + super(manager, "Rainbow Taunt", UtilText.splitLinesToArray(new String[] + { + C.cGray + "At the end of every Rainbow they say there is a pot of Gold.", + "", + C.cWhite + "Use /taunt in game to use this taunt.", + C.cGreen + "Can be used while in PvP!" + }, + LineFormat.LORE), -18, Material.WOOL, (byte) 11); + setCanPlayWithPvp(false); + setPvpCooldown(PVP_COOLDOWN); + setShouldPlay(false); + } + + @Override + public void onStart(Player player) + { + if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics")) + return; + + Vector dir = player.getLocation().getDirection(); + Vector sideA = dir.clone().setX(-dir.getZ()).setZ(dir.getX()); + Vector sideB = dir.clone().setX(dir.getZ()).setZ(-dir.getX()); + + Location start = player.getLocation().clone().add(sideA.multiply(4).toLocation(player.getWorld())); + Location end = player.getLocation().clone().add(sideB.multiply(4).toLocation(player.getWorld())); + + RainbowTauntEffect rainbowTauntEffect = new RainbowTauntEffect(start, Manager.getPlugin()); + rainbowTauntEffect.setTargetLocation(new EffectLocation(end)); + rainbowTauntEffect.start(); + } + + @Override + public void onPlay(Player player) + { + + } + + @Override + public void onFinish(Player player) + { + + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/suits/SetStPatricksSuit.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/suits/SetStPatricksSuit.java new file mode 100644 index 000000000..2ae0e1ed7 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/set/suits/SetStPatricksSuit.java @@ -0,0 +1,22 @@ +package mineplex.core.gadget.set.suits; + +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksBoots; +import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksChestplate; +import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksHat; +import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksLeggings; +import mineplex.core.gadget.types.GadgetSet; + +public class SetStPatricksSuit extends GadgetSet +{ + + public SetStPatricksSuit(GadgetManager manager) + { + super(manager, "St Patrick's Suit", "You're so rich that gold falls out of your pocket with every step!", + manager.getGadget(OutfitStPatricksHat.class), + manager.getGadget(OutfitStPatricksChestplate.class), + manager.getGadget(OutfitStPatricksLeggings.class), + manager.getGadget(OutfitStPatricksBoots.class)); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java index ff08e8152..4fb2b5ed9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/MorphGadget.java @@ -26,6 +26,7 @@ public abstract class MorphGadget extends Gadget public void applyArmor(Player player, boolean message) { Manager.removeGadgetType(player, GadgetType.MORPH, this); + Manager.removeGadgetType(player, GadgetType.COSTUME); _active.add(player); 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 06af3908b..01d6e22a8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ParticleGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/ParticleGadget.java @@ -1,5 +1,7 @@ package mineplex.core.gadget.types; +import java.time.YearMonth; + import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -28,7 +30,12 @@ public abstract class ParticleGadget extends Gadget public ParticleGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data, String...altNames) { 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) + { + super(manager, GadgetType.PARTICLE, name, desc, cost, mat, data, yearMonth, 1, altNames); + } @Override public void enableCustom(Player player, boolean message) 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 9326a4cdb..0cca83b9f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/TauntGadget.java @@ -70,6 +70,7 @@ public abstract class TauntGadget extends Gadget @Override public void disableCustom(Player player, boolean message) { + super.disableCustom(player, message); finish(player); } @@ -159,4 +160,4 @@ public abstract class TauntGadget extends Gadget } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java index 403161cc9..06d6d9475 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java @@ -110,6 +110,7 @@ public abstract class WinEffectGadget extends Gadget } finally { + UtilServer.getPlayersCollection().forEach(UtilPlayer::showForAll); _player = null; _baseLocation = null; _team.clear(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java index 021c87684..3dab673b8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageAdminCommand.java @@ -35,6 +35,6 @@ public class MessageAdminCommand extends CommandBase @Override public List onTabComplete(CommandSender sender, String commandLabel, String[] args) { - return tabCompletePlayerNames(sender, commandLabel, args); + return tabCompletePlayerNames(sender, args); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java index bdc02920f..03ceaa5fd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/MessageCommand.java @@ -45,6 +45,6 @@ public class MessageCommand extends CommandBase @Override public List onTabComplete(CommandSender sender, String commandLabel, String[] args) { - return tabCompletePlayerNames(sender, commandLabel, args); + return tabCompletePlayerNames(sender, args); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java index a1d664e60..3cc8682a9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java @@ -11,6 +11,8 @@ import org.bukkit.entity.Chicken; import org.bukkit.entity.EnderDragon; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; import mineplex.core.common.util.UtilAlg; @@ -29,7 +31,7 @@ public class DragonData extends MountData public float Pitch = 0; public Vector Velocity = new Vector(0,0,0); - public Entity Chicken; + public Chicken Chicken; public DragonData(DragonMount dragonMount, Player rider) { @@ -50,6 +52,7 @@ public class DragonData extends MountData rider.getWorld().playSound(rider.getLocation(), Sound.ENDERDRAGON_GROWL, 20f, 1f); Chicken = rider.getWorld().spawn(rider.getLocation(), Chicken.class); + Chicken.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999999, 1)); Dragon.setPassenger(Chicken); Chicken.setPassenger(getOwner()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java index 869f8e261..6371980f2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java @@ -35,6 +35,7 @@ import mineplex.core.mount.types.MountMule; import mineplex.core.mount.types.MountNightmareSteed; import mineplex.core.mount.types.MountSlime; import mineplex.core.mount.types.MountSpider; +import mineplex.core.mount.types.MountStPatricksHorse; import mineplex.core.mount.types.MountTitan; import mineplex.core.mount.types.MountUndead; import mineplex.core.mount.types.MountValentinesSheep; @@ -48,7 +49,7 @@ public class MountManager extends MiniPlugin private DisguiseManager _disguiseManager; private List> _types; - private NautHashMap> _playerActiveMountMap = new NautHashMap>(); + private NautHashMap> _playerActiveMountMap = new NautHashMap<>(); public MountManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, BlockRestore blockRestore, DisguiseManager disguiseManager) { @@ -79,10 +80,10 @@ public class MountManager extends MiniPlugin _types.add(new MountValentinesSheep(this)); _types.add(new MountFreedomHorse(this)); _types.add(new MountNightmareSteed(this)); - // Hidden in this update _types.add(new MountChicken(this)); _types.add(new MountCake(this)); _types.add(new MountLoveTrain(this)); + _types.add(new MountStPatricksHorse(this)); //_types.add(new MountSheep(this)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSlime.java index 265601406..9d916335c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSlime.java @@ -50,6 +50,8 @@ public class MountSlime extends Mount> mount.getEntity().setCustomName(player.getName() + "'s " + getName()); + UtilEnt.removeTargetSelectors(mount.getEntity()); + //Inform UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(getName()) + ".")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountStPatricksHorse.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountStPatricksHorse.java new file mode 100644 index 000000000..2c20e68fe --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountStPatricksHorse.java @@ -0,0 +1,115 @@ +package mineplex.core.mount.types; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.bukkit.Material; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.HorseJumpEvent; +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.mount.HorseMount; +import mineplex.core.mount.MountManager; +import mineplex.core.mount.SingleEntityMountData; +import mineplex.core.particleeffects.RainbowTrailEffect; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +public class MountStPatricksHorse extends HorseMount +{ + + private HashSet _items = new HashSet<>(); + private Map, RainbowTrailEffect> _trailMap = new HashMap<>(); + + public MountStPatricksHorse(MountManager manager) + { + super(manager, "Rainbow Horse", + UtilText.splitLinesToArray(new String[]{C.cGray + "You know the cow that jumped over the moon? Total show off."}, LineFormat.LORE), + Material.CAULDRON_ITEM, (byte) 0, -18, Horse.Color.WHITE, Horse.Style.WHITE, Horse.Variant.HORSE, 1, null); + } + + @Override + public void enableCustom(Player player) + { + super.enableCustom(player); + SingleEntityMountData horseData = getActive().get(player); + horseData.getEntity().getInventory().setArmor(new ItemStack(Material.GOLD_BARDING)); + _trailMap.put(horseData, new RainbowTrailEffect(horseData.getEntity(), Manager.getPlugin(), _items)); + _trailMap.get(horseData).start(); + } + + @Override + public void disable(Player player) + { + super.disable(player); + List> toRemove = new ArrayList<>(); + for (SingleEntityMountData horseData : _trailMap.keySet()) + { + if (horseData.getOwner().equals(player)) + toRemove.add(horseData); + } + for (SingleEntityMountData horseData : toRemove) + { + _trailMap.get(horseData).stop(); + _trailMap.remove(horseData); + } + } + + @EventHandler + public void horseJump(HorseJumpEvent event) + { + for (SingleEntityMountData horseData : _trailMap.keySet()) + { + if (horseData.getEntity().equals(event.getEntity())) + { + if (Recharge.Instance.use(horseData.getOwner(), getName(), 2500, false, false, "Cosmetics")) + { + _trailMap.get(horseData).setJumping(true); + } + } + } + } + + @EventHandler + public void onItemPickup(PlayerPickupItemEvent event) + { + if (_items.contains(event.getItem())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK) + cleanItems(); + } + + public void cleanItems() + { + Iterator it = _items.iterator(); + while (it.hasNext()) + { + Item item = it.next(); + if (item.getTicksLived() >= 20) + { + item.remove(); + it.remove(); + } + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java index 4e76af53b..fc87a6a09 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java @@ -4,6 +4,12 @@ import java.sql.Connection; import java.sql.SQLException; import java.util.*; +import com.mojang.authlib.GameProfile; +import mineplex.core.aprilfools.AprilFoolsManager; +import mineplex.core.common.skin.SkinData; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.utils.UtilGameProfile; import org.bukkit.*; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; @@ -84,6 +90,8 @@ public class NpcManager extends MiniPlugin final Map _npcMap = new HashMap<>(); private final Set _npcDeletingPlayers = new HashSet<>(); + private final DisguiseManager _disguise; + public NpcManager(JavaPlugin plugin, Creature creature) { super("NpcManager", plugin); @@ -100,6 +108,8 @@ public class NpcManager extends MiniPlugin _plugin.getServer().getPluginManager().registerEvents(this, _plugin); + _disguise = require(DisguiseManager.class); + try { loadNpcs(); @@ -295,15 +305,17 @@ public class NpcManager extends MiniPlugin public Entity spawnNpc(Npc npc) { LivingEntity entity = (LivingEntity) _creature.SpawnEntity(npc.getLocation(), EntityType.valueOf(npc.getDatabaseRecord().getEntityType())); + String name = null; if (npc.getDatabaseRecord().getName() == null) { entity.setCustomNameVisible(false); entity.setCustomName(ChatColor.RESET.toString()); + name = entity.getCustomName(); } else { - String name = npc.getDatabaseRecord().getName(); + name = npc.getDatabaseRecord().getName(); for (ChatColor color : ChatColor.values()) name = name.replace("(" + color.name().toLowerCase() + ")", color.toString()); name = ChatColor.translateAlternateColorCodes('&', name); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/CloverEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/CloverEffect.java new file mode 100644 index 000000000..7f62e7100 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/CloverEffect.java @@ -0,0 +1,33 @@ +package mineplex.core.particleeffects; + +import java.awt.Color; + +import org.bukkit.Location; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; + +import mineplex.core.common.shape.ShapeWings; +import mineplex.core.common.util.UtilParticle; + +public class CloverEffect extends Effect +{ + + private ShapeWings _cloverBlack = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1, 1, 1), 1, 0, '#', ShapeWings.DEFAULT_ROTATION, ShapeWings.FOUR_LEAF_CLOVER); + private ShapeWings _cloverDarkGreen = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1, 1, 1), 1, 0, '%', ShapeWings.DEFAULT_ROTATION, ShapeWings.FOUR_LEAF_CLOVER); + private ShapeWings _cloverGreen = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1, 1, 1), 1, 0, '*', ShapeWings.DEFAULT_ROTATION, ShapeWings.FOUR_LEAF_CLOVER); + + public CloverEffect(JavaPlugin plugin, Location location) + { + super(-1, new EffectLocation(location), plugin, 1); + } + + @Override + public void runEffect() + { + Location location = getEffectLocation().getLocation(); + _cloverBlack.displayColored(location, Color.BLACK); + _cloverDarkGreen.displayColored(location, new Color(0, 100, 0)); + _cloverGreen.displayColored(location, Color.GREEN); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTauntEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTauntEffect.java new file mode 100644 index 000000000..a571a3f0c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTauntEffect.java @@ -0,0 +1,63 @@ +package mineplex.core.particleeffects; + +import java.awt.Color; + +import org.bukkit.Location; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; + +public class RainbowTauntEffect extends Effect +{ + + private static final int PARTICLES = 25; + private static final double HEIGHT = 4; + + private static final Color RED = new Color(255, 0, 0); + private static final Color ORANGE = new Color(255, 127, 0); + private static final Color YELLOW = new Color(255, 255, 0); + private static final Color GREEN = new Color(0, 255, 0); + private static final Color BLUE = new Color(0, 0, 255); + private static final Color INDIGO = new Color(75, 0, 130); + private static final Color VIOLET = new Color(143, 0, 255); + + public RainbowTauntEffect(Location start, JavaPlugin javaPlugin) + { + super(16, new EffectLocation(start), javaPlugin, 5); + } + + @Override + public void runEffect() + { + Location location = getEffectLocation().getFixedLocation(); + Location target = getTargetLocation().getFixedLocation(); + Color[] colors = new Color[]{VIOLET, INDIGO, BLUE, GREEN, YELLOW, ORANGE, RED}; + + for (int i = 0; i < 7; i++) + { + line(location.clone().add(0, 0.25 * i, 0), target.clone().add(0, 0.25 * i, 0), colors[i]); + } + } + + private void line(Location startLocation, Location targetLocation, Color color) + { + Vector link = targetLocation.toVector().subtract(startLocation.toVector()); + float length = (float) link.length(); + float pitch = (float) (4 * HEIGHT / Math.pow(length, 2)); + for (int i = 0; i < PARTICLES; i++) + { + Vector v = link.clone().normalize().multiply(length * i / PARTICLES); + float x = ((float) i / PARTICLES) * length - length / 2; + float y = (float) (-pitch * Math.pow(x, 2) + HEIGHT); + startLocation.add(v).add(0, y, 0); + ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, + new DustSpellColor(color), startLocation); + coloredParticle.display(); + startLocation.subtract(0, y, 0).subtract(v); + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTrailEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTrailEffect.java new file mode 100644 index 000000000..04652f71e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/RainbowTrailEffect.java @@ -0,0 +1,113 @@ +package mineplex.core.particleeffects; + +import java.awt.Color; +import java.util.HashSet; + +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; + +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 RainbowTrailEffect extends Effect +{ + + private HashSet _items; + + private long _count, _jumpingTimer = 0; + private boolean _isJumping = false; + private Entity _entity; + + private Color _red = new Color(255, 0, 0); + private Color _orange = new Color(255, 127, 0); + private Color _yellow = new Color(255, 255, 0); + private Color _green = new Color(0, 255, 0); + private Color _blue = new Color(0, 0, 255); + private Color _indigo = new Color(75, 0, 130); + private Color _violet = new Color(143, 0, 255); + + private Color _color = _red; + + public RainbowTrailEffect(Entity entity, JavaPlugin javaPlugin, HashSet items) + { + super(-1, new EffectLocation(entity), javaPlugin); + _entity = entity; + _items = items; + } + + @Override + public void runEffect() + { + if (!_entity.isValid() || _entity.isDead()) + { + stop(); + return; + } + ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, + new DustSpellColor(_color), _effectLocation.getLocation().clone().add(0, .5, 0)); + for (int i = 0; i < 7; i++) + { + coloredParticle.setLocation(_effectLocation.getLocation().clone().add(0, .5, 0)); + coloredParticle.display(); + if (_isJumping) + { + coloredParticle.setLocation(_effectLocation.getLocation().clone().add(.25, .5, 0)); + coloredParticle.display(); + coloredParticle.setLocation(_effectLocation.getLocation().clone().add(0, .5, .25)); + coloredParticle.display(); + } + } + if (_isJumping) + { + _jumpingTimer++; + if (_jumpingTimer >= 30) + { + setJumping(false); + _jumpingTimer = 0; + } + } + _count++; + if (_count % 5 == 0) + { + if (_color.equals(_red)) + _color = _orange; + else if (_color.equals(_orange)) + _color = _yellow; + else if (_color.equals(_yellow)) + _color = _green; + else if (_color.equals(_green)) + _color = _blue; + else if (_color.equals(_blue)) + _color = _indigo; + else if (_color.equals(_indigo)) + _color = _violet; + else + _color = _red; + } + if (_count == Long.MAX_VALUE - 1) + _count = 0; + } + + public void setJumping(boolean jumping) + { + _isJumping = jumping; + if (_isJumping) + { + ItemStack itemStack = new ItemStack(Material.GOLD_INGOT); + ItemMeta itemMeta = itemStack.getItemMeta(); + itemMeta.setDisplayName("DROPPED" + System.currentTimeMillis() + UtilMath.random.nextInt()); + itemStack.setItemMeta(itemMeta); + Item gold = _entity.getWorld().dropItem(_entity.getLocation().add(0.5, 1.5, 0.5), itemStack); + _items.add(gold); + gold.setVelocity(new Vector((Math.random()-0.5)*0.3, Math.random()-0.4, (Math.random()-0.5)*0.3)); + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyInviteCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyInviteCommand.java index b2435ca04..3e67e92a6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyInviteCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyInviteCommand.java @@ -1,6 +1,5 @@ package mineplex.core.party.command.cli; -import java.util.Arrays; import java.util.List; import org.bukkit.command.CommandSender; @@ -39,7 +38,7 @@ public class PartyInviteCommand extends CommandBase Player player = (Player) sender; Party party = Plugin.getPartyByPlayer(player); - return tabCompletePlayerNames(sender, commandLabel, args, other -> party == null || !party.isMember(other)); + return tabCompletePlayerNames(sender, args, other -> party == null || !party.isMember(other)); } return null; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyKickCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyKickCommand.java index 7612a7325..5613e5758 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyKickCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyKickCommand.java @@ -50,7 +50,7 @@ public class PartyKickCommand extends CommandBase if (party != null && party.isOwner(player)) { - return tabCompletePlayerNames(sender, commandLabel, args, other -> other != player && party.isMember(other)); + return tabCompletePlayerNames(sender, args, other -> other != player && party.isMember(other)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyTransferOwnerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyTransferOwnerCommand.java index 402b0be83..68dac5f57 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyTransferOwnerCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/cli/PartyTransferOwnerCommand.java @@ -77,7 +77,7 @@ public class PartyTransferOwnerCommand extends CommandBase if (party != null && party.isOwner(player)) { - return tabCompletePlayerNames(sender, commandLabel, args, other -> other != player && party.isMember(other)); + return tabCompletePlayerNames(sender, args, other -> other != player && party.isMember(other)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUIInviteCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUIInviteCommand.java index f3832cbad..2ae17a558 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUIInviteCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/command/gui/PartyGUIInviteCommand.java @@ -38,7 +38,7 @@ public class PartyGUIInviteCommand extends CommandBase Player player = (Player) sender; Party party = Plugin.getPartyByPlayer(player); - return tabCompletePlayerNames(sender, commandLabel, args, other -> party == null || !party.isMember(other)); + return tabCompletePlayerNames(sender, args, other -> party == null || !party.isMember(other)); } return null; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index 3b7a1b0e3..9eae213a0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -396,6 +396,20 @@ public class PetManager extends MiniClientPlugin UtilEnt.silence(villager, true); _trueLovePets.put(zombie, new TrueLoveData(player, zombie, villager)); } + else if (petType.equals(PetType.LEPRECHAUN)) + { + Zombie zombie = (Zombie) pet; + zombie.setBaby(true); + + UtilEnt.silence(zombie, true); + + zombie.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false, false)); + + zombie.getEquipment().setHelmet(SkinData.LEPRECHAUN.getSkull()); + zombie.getEquipment().setChestplate(ItemStackFactory.Instance.createColoredLeatherArmor(1, org.bukkit.Color.fromRGB(0, 153, 0))); + 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))); + } _activePetOwnerTypes.put(player.getName(), petType); _activePetOwners.put(player.getName(), pet); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetType.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetType.java index d3aba90ab..e5453d7fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetType.java @@ -6,7 +6,9 @@ import java.util.Optional; import org.bukkit.Material; import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; +import mineplex.core.common.skin.SkinData; import mineplex.core.pet.sales.PetSalesPackage; public enum PetType @@ -30,7 +32,8 @@ public enum PetType BLAZE("Grim Reaper", EntityType.BLAZE, -8, "Aww isn't he so cute with his little wings and little scythe?"), 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)) + 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()) // 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.") @@ -42,6 +45,7 @@ public enum PetType private final Material _material; private final byte _data; private YearMonth _yearMonth; + private ItemStack _displayItem; PetType(String name, EntityType entityType, int price) { @@ -84,6 +88,12 @@ public enum PetType _yearMonth = yearMonth; } + PetType(String name, EntityType entityType, int price, String lore, ItemStack displayItem) + { + this(name, entityType, price, lore); + _displayItem = displayItem; + } + public String getName() { return _name; @@ -114,6 +124,15 @@ public enum PetType return _data; } + public ItemStack getDisplayItem() + { + if (_displayItem == null) + { + return new ItemStack(_material, 1, _data); + } + return _displayItem; + } + public YearMonth getYearMonth() { return _yearMonth; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index 5d0d5eb88..68a0c10c1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -10,6 +10,7 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.GameMode; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -195,6 +196,11 @@ public class Portal extends MiniPlugin */ public void sendPlayer(final Player player, String serverName) { + if (player.getGameMode() == GameMode.SPECTATOR) + { + player.setSpectatorTarget(null); + } + ByteArrayOutputStream b = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(b); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/SendCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/SendCommand.java similarity index 100% rename from Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/SendCommand.java rename to Plugins/Mineplex.Core/src/mineplex/core/portal/commands/SendCommand.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/ServerCommand.java similarity index 100% rename from Plugins/Mineplex.Core/src/mineplex/core/portal/Commands/ServerCommand.java rename to Plugins/Mineplex.Core/src/mineplex/core/portal/commands/ServerCommand.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PPCDataRequestEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PPCDataRequestEvent.java new file mode 100644 index 000000000..51af9b3b9 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PPCDataRequestEvent.java @@ -0,0 +1,44 @@ +package mineplex.core.powerplayclub; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PPCDataRequestEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _player; + private PowerPlayData _data; + + public PPCDataRequestEvent(Player player) + { + _player = player; + _data = null; + } + + public Player getPlayer() + { + return _player; + } + + public PowerPlayData getData() + { + return _data; + } + + public void setData(PowerPlayData data) + { + _data = data;; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java index e28b0509f..0e007abdb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java @@ -25,6 +25,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.ILoginProcessor; +import mineplex.core.common.util.UtilServer; import mineplex.core.donation.DonationManager; import mineplex.serverdata.database.DBPool; @@ -120,9 +121,17 @@ public class PowerPlayClubRepository implements Listener { _stageOneDataClaims.remove(event.getPlayer().getUniqueId()); // Just in case. _cachedPlayerData.remove(event.getPlayer().getUniqueId()); } + + @EventHandler + public void onDataRequested(PPCDataRequestEvent event) + { + event.setData(getCachedData(event.getPlayer())); + } public CompletableFuture addSubscription(int accountId, LocalDate date, String duration) { + UtilServer.CallEvent(new SubscriptionAddEvent(accountId, duration)); + return CompletableFuture.supplyAsync(() -> { try (Connection connection = DBPool.getAccount().getConnection()) @@ -133,7 +142,8 @@ public class PowerPlayClubRepository implements Listener { statement.setString(3, duration); statement.executeUpdate(); - } catch (SQLException e) + } + catch (SQLException e) { e.printStackTrace(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index 3d5f61a42..60f365341 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -36,6 +36,7 @@ public class PowerPlayClubRewards .put(YearMonth.of(2017, Month.JANUARY), new UnknownSalesPackageItem("Over Easy Morph")) .put(YearMonth.of(2017, Month.FEBRUARY), new PetItem(PetType.TRUE_LOVE_PET)) .put(YearMonth.of(2017, Month.MARCH), new UnknownSalesPackageItem("Gold Pot Morph")) + .put(YearMonth.of(2017, Month.APRIL), new UnknownSalesPackageItem("Bumblebee's Wings")) .build(); public interface PowerPlayClubItem diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/SubscriptionAddEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/SubscriptionAddEvent.java new file mode 100644 index 000000000..50503de00 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/SubscriptionAddEvent.java @@ -0,0 +1,38 @@ +package mineplex.core.powerplayclub; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class SubscriptionAddEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private int _accountId; + private String _duration; + + public SubscriptionAddEvent(int accountId, String duration) + { + _accountId = accountId; + _duration = duration; + } + + public int getAccountId() + { + return _accountId; + } + + public String getDuration() + { + return _duration; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java index 1f9166e6e..2b5ef2dbf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Command/PunishCommand.java @@ -143,6 +143,6 @@ public class PunishCommand extends CommandBase @Override public List onTabComplete(CommandSender sender, String commandLabel, String[] args) { - return tabCompletePlayerNames(sender, commandLabel, args); + return tabCompletePlayerNames(sender, args); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index a80f5cf4b..855d747d7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -9,6 +9,7 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; import mineplex.core.common.util.banner.CountryFlag; @@ -91,6 +92,10 @@ import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitBoots; import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitChestplate; import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitHelmet; import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitLeggings; +import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksBoots; +import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksChestplate; +import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksHat; +import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksLeggings; import mineplex.core.gadget.gadgets.particle.ParticleChristmasTree; import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes; import mineplex.core.gadget.gadgets.particle.ParticleFairy; @@ -113,6 +118,7 @@ import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; +import mineplex.core.gadget.gadgets.taunts.RainbowTaunt; import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken; import mineplex.core.gadget.gadgets.wineffect.WinEffectFlames; import mineplex.core.gadget.gadgets.wineffect.WinEffectHalloween; @@ -140,6 +146,7 @@ import mineplex.core.mount.types.MountMule; import mineplex.core.mount.types.MountNightmareSteed; import mineplex.core.mount.types.MountSlime; import mineplex.core.mount.types.MountSpider; +import mineplex.core.mount.types.MountStPatricksHorse; import mineplex.core.mount.types.MountUndead; import mineplex.core.mount.types.MountValentinesSheep; import mineplex.core.mount.types.MountZombie; @@ -157,9 +164,11 @@ import mineplex.core.reward.rewards.PowerPlayReward; import mineplex.core.reward.rewards.RankReward; import mineplex.core.reward.rewards.RuneAmplifierReward; import mineplex.core.reward.rewards.SpinTicketReward; +import mineplex.core.reward.rewards.TitleReward; import mineplex.core.reward.rewards.TreasureShardReward; import mineplex.core.reward.rewards.UnknownPackageReward; import mineplex.core.stats.StatsManager; +import mineplex.core.titles.tracks.TrackManager; import mineplex.core.treasure.TreasureType; public class RewardManager @@ -167,6 +176,7 @@ public class RewardManager private EnumMap _rewardPools; private Random _random; + private final TrackManager _trackManager = Managers.require(TrackManager.class); private CoreClientManager _clientManager; private DonationManager _donationManager; private InventoryManager _inventoryManager; @@ -413,7 +423,38 @@ public class RewardManager addMineStrikeSkin(Type.MINESTRIKE, MineStrikeSkin.Desert_Eagle_Golden_Gun, rarity, 30, 2500); addMineStrikeSkin(Type.MINESTRIKE, MineStrikeSkin.P90_Asiimov, rarity, 100, 1000); addMineStrikeSkin(Type.MINESTRIKE, MineStrikeSkin.SG553_Pulse, rarity, 100, 1000); - + + // Titles + + addTitle(Type.NORMAL, "shrug", rarity, 10, 500); + addTitle(Type.NORMAL, "tableflip", rarity, 10, 500); + addTitle(Type.NORMAL, "tablerespecter", rarity, 15, 500); + addTitle(Type.NORMAL, "tableflip-disgusted", rarity, 15, 500); + addTitle(Type.NORMAL, "tableflip-enraged", rarity, 15, 500); + addTitle(Type.NORMAL, "tableflip-riot", rarity, 10, 500); + addTitle(Type.NORMAL, "teddy-bear", rarity, 10, 500); + addTitle(Type.NORMAL, "disgust", rarity, 10, 500); + addTitle(Type.NORMAL, "old-man", rarity, 5, 500); + addTitle(Type.NORMAL, "jake", rarity, 5, 500); + addTitle(Type.NORMAL, "finn", rarity, 5, 500); + addTitle(Type.NORMAL, "finn-and-jake", rarity, 5, 500); + addTitle(Type.NORMAL, "boxer", rarity, 5, 500); + addTitle(Type.NORMAL, "zoidberg", rarity, 5, 500); + + addTitle(Type.OMEGA, "shrug", rarity, 10, 500); + addTitle(Type.OMEGA, "tableflip", rarity, 10, 500); + addTitle(Type.OMEGA, "tablerespecter", rarity, 15, 500); + addTitle(Type.OMEGA, "tableflip-disgusted", rarity, 15, 500); + addTitle(Type.OMEGA, "tableflip-enraged", rarity, 15, 500); + addTitle(Type.OMEGA, "tableflip-riot", rarity, 10, 500); + addTitle(Type.OMEGA, "teddy-bear", rarity, 10, 500); + addTitle(Type.OMEGA, "disgust", rarity, 10, 500); + addTitle(Type.OMEGA, "old-man", rarity, 5, 500); + addTitle(Type.OMEGA, "jake", rarity, 5, 500); + addTitle(Type.OMEGA, "finn", rarity, 5, 500); + addTitle(Type.OMEGA, "finn-and-jake", rarity, 5, 500); + addTitle(Type.OMEGA, "boxer", rarity, 5, 500); + addTitle(Type.OMEGA, "zoidberg", rarity, 5, 500); // VALENTINES //Hats @@ -553,6 +594,11 @@ public class RewardManager addPetReward(Type.LOVECHEST, PetType.CUPID_PET, rarity, 50, 500); addGadget(Type.LOVECHEST, getGadget(WinEffectLoveIsABattlefield.class), rarity, 100, 500); + + // ST PATRICKS + addGadget(Type.STPATRICKS, getGadget(OutfitStPatricksChestplate.class), rarity, 50); + addGadget(Type.STPATRICKS, getGadget(OutfitStPatricksLeggings.class), rarity, 50); + addGadget(Type.STPATRICKS, getGadget(OutfitStPatricksBoots.class), rarity, 50); } public void addLegendary() @@ -624,6 +670,38 @@ public class RewardManager addMineStrikeSkin(Type.MINESTRIKE, MineStrikeSkin.XM1014_Pig_Gun, rarity, 10, 7500); addMineStrikeSkin(Type.MINESTRIKE, MineStrikeSkin.M4A4_Enderman, rarity, 10, 7500); + // Titles + + addTitle(Type.NORMAL, "ayyye", rarity, 25, 500); + addTitle(Type.NORMAL, "ameno", rarity, 15, 5000); + addTitle(Type.NORMAL, "magician", rarity, 25, 5000); + addTitle(Type.NORMAL, "fireball", rarity, 75, 5000); + addTitle(Type.NORMAL, "magic-missile", rarity, 75, 5000); + addTitle(Type.NORMAL, "pewpewpew", rarity, 75, 5000); + addTitle(Type.NORMAL, "stardust", rarity, 60, 5000); + addTitle(Type.NORMAL, "blow-a-kiss", rarity, 60, 5000); + addTitle(Type.NORMAL, "cool-guy", rarity, 60, 5000); + addTitle(Type.NORMAL, "deal-with-it", rarity, 60, 5000); + addTitle(Type.NORMAL, "party-time", rarity, 55, 5000); + addTitle(Type.NORMAL, "lalala", rarity, 30, 5000); + addTitle(Type.NORMAL, "gotta-go", rarity, 30, 5000); + addTitle(Type.NORMAL, "whaaat", rarity, 30, 5000); + + addTitle(Type.OMEGA, "ayyye", rarity, 25, 500); + addTitle(Type.OMEGA, "ameno", rarity, 15, 5000); + addTitle(Type.OMEGA, "magician", rarity, 25, 5000); + addTitle(Type.OMEGA, "fireball", rarity, 75, 5000); + addTitle(Type.OMEGA, "magic-missile", rarity, 75, 5000); + addTitle(Type.OMEGA, "pewpewpew", rarity, 75, 5000); + addTitle(Type.OMEGA, "stardust", rarity, 60, 5000); + addTitle(Type.OMEGA, "blow-a-kiss", rarity, 60, 5000); + addTitle(Type.OMEGA, "cool-guy", rarity, 60, 5000); + addTitle(Type.OMEGA, "deal-with-it", rarity, 60, 5000); + addTitle(Type.OMEGA, "party-time", rarity, 55, 5000); + addTitle(Type.OMEGA, "lalala", rarity, 30, 5000); + addTitle(Type.OMEGA, "gotta-go", rarity, 30, 5000); + addTitle(Type.OMEGA, "whaaat", rarity, 30, 5000); + //WINTER //Arrow Trails @@ -770,6 +848,14 @@ public class RewardManager addGadget(Type.LOVECHEST, getGadget(MorphLoveDoctor.class), rarity, 30, 5000); addGadget(Type.LOVECHEST, getGadget(BlowAKissTaunt.class), rarity, 50, 5000); addGadget(Type.LOVECHEST, getGadget(ParticleWingsLove.class), rarity, 10, 5000); + + // ST PATRICKS + addGadget(Type.STPATRICKS, getGadget(RainbowTaunt.class), rarity, 30); + addGadget(Type.STPATRICKS, getGadget(OutfitStPatricksHat.class), rarity, 15); + + addPetReward(Type.STPATRICKS, PetType.LEPRECHAUN, rarity, 30); + + addMount(Type.STPATRICKS, getMount(MountStPatricksHorse.class), rarity, 30); } public UnknownPackageReward addMount(Type type, Mount mount, RewardRarity rarity, int weight) @@ -855,6 +941,11 @@ public class RewardManager return addGadget(type, gadget, gadget.getDisplayName() + " (Minestrike Weapon Skin)", rarity, weight, shards); } + public void addTitle(Type type, String trackName, RewardRarity rarity, int weight, int shards) + { + addReward(type, new TitleReward(_trackManager.getTrackById(trackName), rarity, weight, shards)); + } + public UnknownPackageReward addHat(Type type, HatType hatType, RewardRarity rarity, int weight) { return addHat(type, hatType, rarity, weight, getShards(rarity)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java index dc9f2cd9f..623552350 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardPool.java @@ -64,6 +64,7 @@ public class RewardPool GINGERBREAD(false, 1), MINESTRIKE(true, 2), LOVECHEST(false, 1), + STPATRICKS(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 f235c8dda..33381f37e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardType.java @@ -21,6 +21,7 @@ public enum RewardType MINESTRIKE_CHEST( 0, 2, 16, 0), LOVE_CHEST( 0, 6, 18, 0), VALENTINES_GIFT( 0, 7, 20, 20), + ST_PATRICKS( 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/TitleReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/TitleReward.java new file mode 100644 index 000000000..39b04375e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/TitleReward.java @@ -0,0 +1,49 @@ +package mineplex.core.reward.rewards; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.Managers; +import mineplex.core.reward.Reward; +import mineplex.core.reward.RewardData; +import mineplex.core.reward.RewardRarity; +import mineplex.core.reward.RewardType; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackManager; + +public class TitleReward extends Reward +{ + private final ItemStack ITEM_STACK = new ItemStack(Material.BOOK); + private final TrackManager _trackManager = Managers.require(TrackManager.class); + private final Track _track; + + public TitleReward(Track track, RewardRarity rarity, int weight, int shardValue) + { + super(rarity, weight, shardValue); + if (track == null) + { + throw new IllegalStateException(); + } + _track = track; + } + + @Override + protected RewardData giveRewardCustom(Player player, RewardType rewardType) + { + _trackManager.unlockTrack(player, _track); + return getFakeRewardData(player); + } + + @Override + public RewardData getFakeRewardData(Player player) + { + return new RewardData(getRarity().getDarkColor() + "Title", getRarity().getColor() + _track.getLongName(), ITEM_STACK, getRarity()); + } + + @Override + public boolean canGiveReward(Player player) + { + return !_trackManager.hasTrack(player, _track); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageInventory.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageInventory.java index 0546c0de6..1d631af56 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageInventory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageInventory.java @@ -4,6 +4,8 @@ import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.lifetimes.Lifetime; +import mineplex.core.lifetimes.Lifetimed; import mineplex.core.shop.ShopBase; import mineplex.core.shop.item.IButton; @@ -12,7 +14,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -public abstract class ShopPageInventory> extends +public abstract class ShopPageInventory> extends ShopPageBase { private int _page; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakClientInfo.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakClientInfo.java new file mode 100644 index 000000000..95a8b483d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakClientInfo.java @@ -0,0 +1,31 @@ +package mineplex.core.teamspeak; + +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +public class TeamspeakClientInfo +{ + private Map _linkedAccounts = new HashMap<>(); + + public TeamspeakClientInfo(Map linkedAccounts) + { + _linkedAccounts = new HashMap<>(linkedAccounts); + } + + public Map getLinkedAccounts() + { + return Collections.unmodifiableMap(_linkedAccounts); + } + + public void unlink(int account) + { + _linkedAccounts.remove(account); + } + + public void link(int id, Date now) + { + _linkedAccounts.put(id, now); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakManager.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakManager.java new file mode 100644 index 000000000..68e3bccdd --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakManager.java @@ -0,0 +1,373 @@ +package mineplex.core.teamspeak; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +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.apache.commons.lang.StringUtils; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitTask; + +import mineplex.core.MiniClientPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.ILoginProcessor; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.teamspeak.commands.TeamspeakCommand; +import mineplex.core.teamspeak.redis.TeamspeakLinkRequest; +import mineplex.core.teamspeak.redis.TeamspeakLinkResponse; +import mineplex.core.teamspeak.redis.TeamspeakUnlinkRequest; +import mineplex.core.teamspeak.redis.TeamspeakUnlinkResponse; +import mineplex.serverdata.commands.ServerCommandManager; + +@ReflectivelyCreateMiniPlugin +public class TeamspeakManager extends MiniClientPlugin implements ILoginProcessor +{ + public static final String TEAMSPEAK_CHANNEL_NAME = "Teamspeak Rank Channel"; + + public static final int MAX_LINKED_ACCOUNTS = 5; + + private final CoreClientManager _clientManager = require(CoreClientManager.class); + private final TeamspeakRepository _repository = new TeamspeakRepository(); + + private final Map _requestMap = new HashMap<>(); + + private TeamspeakManager() + { + super("TeamSpeak Manager"); + + ServerCommandManager.getInstance().registerCommandType(TeamspeakLinkResponse.class, response -> + { + BukkitTask task = _requestMap.remove(response.getRequest().getCommandId()); + + if (task == null) + return; + + task.cancel(); + + Player sender = Bukkit.getPlayer(response.getRequest().getCaller()); + + if (sender == null) + return; + + switch (response.getResponse()) + { + case TOKEN_VALID: + Date now = new Date(); + Get(sender).link(response.getId(), now); + runAsync(() -> + { + _repository.save(_clientManager.getAccountId(sender), response.getId(), now); + }); + + UtilPlayer.message(sender, F.main("Teamspeak", "Congrats! You've successfully linked your Teamspeak account!")); + break; + case TOKEN_INVALID: + UtilPlayer.message(sender, F.main("Teamspeak", "Uh oh! That's not the token you were given!")); + break; + } + }); + + ServerCommandManager.getInstance().registerCommandType(TeamspeakUnlinkResponse.class, response -> + { + BukkitTask task = _requestMap.remove(response.getRequest().getCommandId()); + + if (task == null) + return; + + task.cancel(); + + Player sender = Bukkit.getPlayer(response.getRequest().getCaller()); + + if (sender == null) + return; + + switch (response.getResponse()) + { + case UNLINKED: + Get(sender).unlink(response.getRequest().getId()); + runAsync(() -> + { + _repository.delete(_clientManager.getAccountId(sender), response.getRequest().getId()); + }); + + UtilPlayer.message(sender, F.main("Teamspeak", "You've unlinked your Teamspeak account!")); + break; + } + }); + + _clientManager.addStoredProcedureLoginProcessor(this); + } + + @Override + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException + { + Map dates = new HashMap<>(); + + while (resultSet.next()) + { + int teamspeakId = resultSet.getInt("teamspeakId"); + Date linkDate = resultSet.getDate("linkDate"); + + dates.put(teamspeakId, linkDate); + } + + Set(uuid, new TeamspeakClientInfo(dates)); + } + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return String.format(TeamspeakRepository.GET_ALL_PLAYER_IDS, accountId); + } + + @Override + protected TeamspeakClientInfo addPlayer(UUID uuid) + { + return new TeamspeakClientInfo(Collections.emptyMap()); + } + + public void link(Player caller, String token) + { + if (_requestMap.containsKey(caller.getUniqueId())) + { + UtilPlayer.message(caller, F.main("Teamspeak", "Please wait until your current request has been processed")); + return; + } + + TeamspeakClientInfo info = Get(caller); + + if (info.getLinkedAccounts().size() >= MAX_LINKED_ACCOUNTS) + { + UtilPlayer.message(caller, F.main("Teamspeak", "You have too many linked accounts! Please unlink one using /teamspeak unlink")); + return; + } + + UtilPlayer.message(caller, F.main("Teamspeak", "Linking your account...")); + + TeamspeakLinkRequest linkRequest = new TeamspeakLinkRequest( + caller.getUniqueId(), + token + ); + linkRequest.publish(); + + _requestMap.put(linkRequest.getCommandId(), runSyncLater(() -> + { + if (!caller.isOnline()) + return; + + UtilPlayer.message(caller, F.main("Teamspeak", "It seems something has gone wrong - your request couldn't be processed")); + + _requestMap.remove(linkRequest.getCommandId()); + }, 20L * 5)); + } + + public void unlink(Player caller, String arg) + { + int id; + try + { + id = Integer.parseInt(arg); + } + catch (NumberFormatException ex) + { + UtilPlayer.message(caller, F.main("Teamspeak", F.elem(arg) + " is not a number")); + return; + } + + if (_requestMap.containsKey(caller.getUniqueId())) + { + UtilPlayer.message(caller, F.main("Teamspeak", "Please wait until your current request has been processed")); + return; + } + + TeamspeakClientInfo info = Get(caller); + + if (!info.getLinkedAccounts().containsKey(id)) + { + UtilPlayer.message(caller, F.main("Teamspeak", "You have not linked to that account")); + return; + } + + UtilPlayer.message(caller, F.main("Teamspeak", "Unlinking your account...")); + + TeamspeakUnlinkRequest unlinkRequest = new TeamspeakUnlinkRequest( + caller.getUniqueId(), + id + ); + unlinkRequest.publish(); + + _requestMap.put(unlinkRequest.getCommandId(), runSyncLater(() -> + { + if (!caller.isOnline()) + return; + + UtilPlayer.message(caller, F.main("Teamspeak", "It seems something has gone wrong - your request couldn't be processed")); + + _requestMap.remove(unlinkRequest.getCommandId()); + }, 20L * 5)); + } + + @Override + public void addCommands() + { + addCommand(new TeamspeakCommand(this)); + } + + public void displayUnlinkPrompt(Player caller, String strPage) + { + TeamspeakClientInfo info = Get(caller); + + List> linkedAccounts = new ArrayList<>(info.getLinkedAccounts().entrySet()); + + if (linkedAccounts.size() == 0) + { + UtilPlayer.message(caller, F.main("Teamspeak", "You have no linked Teamspeak accounts!")); + return; + } + + int totalPages = (int) Math.ceil(linkedAccounts.size() / 8.0); + int page; + + try + { + page = Integer.parseInt(strPage); + } + catch (NumberFormatException ex) + { + UtilPlayer.message(caller, F.main("Teamspeak", F.elem(strPage) + " is not a number!")); + return; + } + page = page - 1; + + if (page < 0) + { + UtilPlayer.message(caller, F.main("Teamspeak", "Page numbers must be greater than zero!")); + return; + } + else if (page >= totalPages) + { + UtilPlayer.message(caller, F.main("Teamspeak", "You only have " + F.elem(totalPages) + " pages of linked accounts, that number is too big!")); + return; + } + + String header = "[" + + ChatColor.RESET + C.cWhite + C.Bold + "Teamspeak Accounts (" + (page + 1) + "/" + totalPages + ")" + + ChatColor.RESET + C.cAqua + C.Strike + "]"; + + int headerChars = ChatColor.stripColor(header).length(); + + int numEqualsInHeader = (50 - headerChars) / 2; + header = C.cAqua + C.Strike + StringUtils.repeat("=", numEqualsInHeader) + header + StringUtils.repeat("=", numEqualsInHeader); + + caller.sendMessage(header); + + int start = page * 8; + + List> subList = start < linkedAccounts.size() ? linkedAccounts.subList(start, Math.min(linkedAccounts.size(), start + 8)) : Collections.emptyList(); + + for (Map.Entry data : subList) + { + BaseComponent[] hover = new ComponentBuilder("") + .append("ID: ") + .color(ChatColor.YELLOW) + .append(String.valueOf(data.getKey()), ComponentBuilder.FormatRetention.NONE) + .color(ChatColor.WHITE) + .create(); + + ComponentBuilder builder = new ComponentBuilder("") + .append("Unlink") + .color(ChatColor.RED) + .bold(true) + .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to unlink this account. All your ranks on Teamspeak will be removed").color(ChatColor.RED).create())) + .event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/teamspeak unlink " + data.getKey())) + .append(" - ", ComponentBuilder.FormatRetention.NONE) + .color(ChatColor.WHITE) + .append("Account linked on " + UtilTime.date(data.getValue().getTime())) + .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hover)) + .color(ChatColor.GRAY); + + caller.spigot().sendMessage(builder.create()); + } + + int chars = ChatColor.stripColor(header).length(); + + int numEquals = (chars - 3) / 2; + + ComponentBuilder pageSwitch = new ComponentBuilder("") + .append(StringUtils.repeat("=", numEquals) + "[") + .strikethrough(true) + .color(ChatColor.AQUA) + .append(" ", ComponentBuilder.FormatRetention.NONE) + .append("<", ComponentBuilder.FormatRetention.NONE) + .bold(true); + + if (page > 0) + { + BaseComponent[] prev = new ComponentBuilder("") + .append("Go to page " + page) + .color(ChatColor.GREEN) + .create(); + + pageSwitch + .color(ChatColor.GREEN) + .event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/teamspeak list " + (page))) + .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, prev)); + + } + else + { + pageSwitch + .color(ChatColor.GRAY); + } + + pageSwitch.append(" ", ComponentBuilder.FormatRetention.NONE) + .append(">", ComponentBuilder.FormatRetention.NONE) + .bold(true); + + if (page + 1 < totalPages) + { + BaseComponent[] next = new ComponentBuilder("") + .append("Go to page " + (page + 2)) + .color(ChatColor.GREEN) + .create(); + + pageSwitch + .color(ChatColor.GREEN) + .event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/teamspeak list " + (page + 2))) + .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, next)); + + } + else + { + pageSwitch + .color(ChatColor.GRAY); + } + + pageSwitch + .append(" ", ComponentBuilder.FormatRetention.NONE) + .append("]" + StringUtils.repeat("=", numEquals), ComponentBuilder.FormatRetention.NONE) + .strikethrough(true) + .color(ChatColor.AQUA); + + caller.spigot().sendMessage(pageSwitch.create()); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakRepository.java new file mode 100644 index 000000000..afe63c069 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/TeamspeakRepository.java @@ -0,0 +1,57 @@ +package mineplex.core.teamspeak; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.Date; + +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; + +@SuppressWarnings("WeakerAccess") +public class TeamspeakRepository extends RepositoryBase +{ + TeamspeakRepository() + { + super(DBPool.getAccount()); + } + + public static final String GET_ALL_PLAYER_IDS = "SELECT `teamspeakId`, `linkDate` FROM accountTeamspeak WHERE accountId = %s;"; + public static final String SAVE_PLAYER_ID = "INSERT INTO accountTeamspeak (accountId, teamspeakId, linkDate) VALUES (?, ?, ?);"; + public static final String DELETE_PLAYER_ID = "DELETE FROM accountTeamspeak WHERE accountId = ? AND teamspeakId = ?;"; + + public void save(int accountId, int id, Date now) + { + try (Connection connection = getConnection()) + { + try (PreparedStatement statement = connection.prepareStatement(SAVE_PLAYER_ID)) + { + statement.setInt(1, accountId); + statement.setInt(2, id); + statement.setDate(3, new java.sql.Date(now.getTime())); + statement.executeUpdate(); + } + } + catch (SQLException ex) + { + ex.printStackTrace(); + } + } + + public void delete(int accountId, int id) + { + try (Connection connection = getConnection()) + { + try (PreparedStatement statement = connection.prepareStatement(DELETE_PLAYER_ID)) + { + statement.setInt(1, accountId); + statement.setInt(2, id); + statement.executeUpdate(); + } + } + catch (SQLException ex) + { + ex.printStackTrace(); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/LinkCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/LinkCommand.java new file mode 100644 index 000000000..83fa22d07 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/LinkCommand.java @@ -0,0 +1,29 @@ +package mineplex.core.teamspeak.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.core.teamspeak.TeamspeakManager; + +public class LinkCommand extends CommandBase +{ + public LinkCommand(TeamspeakManager plugin) + { + super(plugin, Rank.ALL, "link"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length == 0) + { + UtilPlayer.message(caller, F.main("Teamspeak", "No token specified. Join the " + F.elem(TeamspeakManager.TEAMSPEAK_CHANNEL_NAME) + " on Teamspeak and type " + F.elem("!link") + " to link an account")); + return; + } + + Plugin.link(caller, args[0]); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/ListCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/ListCommand.java new file mode 100644 index 000000000..18b4ebf56 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/ListCommand.java @@ -0,0 +1,23 @@ +package mineplex.core.teamspeak.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.core.teamspeak.TeamspeakManager; + +public class ListCommand extends CommandBase +{ + public ListCommand(TeamspeakManager plugin) + { + super(plugin, Rank.ALL, "list"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Plugin.displayUnlinkPrompt(caller, args.length == 0 ? "1" : args[0]); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/TeamspeakCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/TeamspeakCommand.java new file mode 100644 index 000000000..c14e57d8c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/TeamspeakCommand.java @@ -0,0 +1,28 @@ +package mineplex.core.teamspeak.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.MultiCommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.teamspeak.TeamspeakManager; + +public class TeamspeakCommand extends MultiCommandBase +{ + public TeamspeakCommand(TeamspeakManager plugin) + { + super(plugin, Rank.ALL, "teamspeak", "ts"); + + AddCommand(new LinkCommand(plugin)); + AddCommand(new ListCommand(plugin)); + AddCommand(new UnlinkCommand(plugin)); + } + + @Override + protected void Help(Player caller, String[] args) + { + UtilPlayer.message(caller, F.main("Teamspeak", "To link a new Teamspeak account, run " + F.elem("/teamspeak link"))); + UtilPlayer.message(caller, F.main("Teamspeak", "To list all linked Teamspeak accounts, run " + F.elem("/teamspeak list"))); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/UnlinkCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/UnlinkCommand.java new file mode 100644 index 000000000..063b90a80 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/commands/UnlinkCommand.java @@ -0,0 +1,29 @@ +package mineplex.core.teamspeak.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.core.teamspeak.TeamspeakManager; + +public class UnlinkCommand extends CommandBase +{ + public UnlinkCommand(TeamspeakManager plugin) + { + super(plugin, Rank.ALL, "unlink"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length == 0) + { + UtilPlayer.message(caller, F.main("Teamspeak", "No account specified!")); + return; + } + + Plugin.unlink(caller, args[0]); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/redis/TeamspeakLinkRequest.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/redis/TeamspeakLinkRequest.java new file mode 100644 index 000000000..1235b54a3 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/redis/TeamspeakLinkRequest.java @@ -0,0 +1,27 @@ +package mineplex.core.teamspeak.redis; + +import java.util.UUID; + +import mineplex.serverdata.commands.ServerCommand; + +public class TeamspeakLinkRequest extends ServerCommand +{ + private final UUID _caller; + private final String _token; + + public TeamspeakLinkRequest(UUID caller, String token) + { + this._caller = caller; + this._token = token; + } + + public UUID getCaller() + { + return _caller; + } + + public String getToken() + { + return _token; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/redis/TeamspeakLinkResponse.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/redis/TeamspeakLinkResponse.java new file mode 100644 index 000000000..e9f59c0b6 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/redis/TeamspeakLinkResponse.java @@ -0,0 +1,42 @@ +package mineplex.core.teamspeak.redis; + +import com.google.gson.annotations.SerializedName; + +import mineplex.serverdata.commands.ServerCommand; + +public class TeamspeakLinkResponse extends ServerCommand +{ + private final Response _response; + private final TeamspeakLinkRequest _request; + private final int _id; + + public TeamspeakLinkResponse(Response response, TeamspeakLinkRequest request, int id) + { + _response = response; + _request = request; + _id = id; + } + + public Response getResponse() + { + return _response; + } + + public TeamspeakLinkRequest getRequest() + { + return _request; + } + + public int getId() + { + return _id; + } + + public enum Response + { + @SerializedName("token-valid") + TOKEN_VALID, + @SerializedName("token-invalid") + TOKEN_INVALID + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/redis/TeamspeakUnlinkRequest.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/redis/TeamspeakUnlinkRequest.java new file mode 100644 index 000000000..340e89cdc --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/redis/TeamspeakUnlinkRequest.java @@ -0,0 +1,27 @@ +package mineplex.core.teamspeak.redis; + +import java.util.UUID; + +import mineplex.serverdata.commands.ServerCommand; + +public class TeamspeakUnlinkRequest extends ServerCommand +{ + private final UUID _caller; + private final int _id; + + public TeamspeakUnlinkRequest(UUID caller, int id) + { + this._caller = caller; + this._id = id; + } + + public UUID getCaller() + { + return _caller; + } + + public int getId() + { + return _id; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/redis/TeamspeakUnlinkResponse.java b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/redis/TeamspeakUnlinkResponse.java new file mode 100644 index 000000000..41827f9ee --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/teamspeak/redis/TeamspeakUnlinkResponse.java @@ -0,0 +1,33 @@ +package mineplex.core.teamspeak.redis; + +import com.google.gson.annotations.SerializedName; + +import mineplex.serverdata.commands.ServerCommand; + +public class TeamspeakUnlinkResponse extends ServerCommand +{ + private final Response _response; + private final TeamspeakUnlinkRequest _request; + + public TeamspeakUnlinkResponse(Response response, TeamspeakUnlinkRequest request) + { + this._response = response; + this._request = request; + } + + public Response getResponse() + { + return _response; + } + + public TeamspeakUnlinkRequest getRequest() + { + return _request; + } + + public enum Response + { + @SerializedName(value = "unlinked") + UNLINKED + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/Titles.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/Titles.java index 4ebce3925..0f739111e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/Titles.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/Titles.java @@ -3,6 +3,7 @@ package mineplex.core.titles; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Arrays; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -37,6 +38,7 @@ import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -70,6 +72,7 @@ import mineplex.core.itemstack.ItemBuilder; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketInfo; +import mineplex.core.titles.commands.GiveTrackCommand; import mineplex.core.titles.commands.TrackCommand; import mineplex.core.titles.tracks.Track; import mineplex.core.titles.tracks.TrackFormat; @@ -301,21 +304,7 @@ public class Titles extends MiniDbClientPlugin implements IPacketHand tracks.removeIf(track -> track.getRequirements().getTier(player) == null && track.hideIfUnowned()); - tracks.sort((a, b) -> - { - if (a.hideIfUnowned() && !b.hideIfUnowned()) - { - return -1; - } - else if (!a.hideIfUnowned() && b.hideIfUnowned()) - { - return 1; - } - else - { - return a.getShortName().compareTo(b.getShortName()); - } - }); + tracks.sort(Comparator.comparing(Track::getShortName)); String bookTitle = C.cGreen + "Titles"; @@ -762,6 +751,13 @@ public class Titles extends MiniDbClientPlugin implements IPacketHand if (packetInfo.getPacket() instanceof PacketPlayOutNamedEntitySpawn) { PacketPlayOutNamedEntitySpawn packet = (PacketPlayOutNamedEntitySpawn) packetInfo.getPacket(); + Entity entity = UtilEnt.getEntityById(packet.a); + + if (!(entity instanceof Player)) + { + return; + } + Player owner = (Player) UtilEnt.getEntityById(packet.a); if (_gadgetManager.getActive(owner, GadgetType.MORPH) == null) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/GiveTrackCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/GiveTrackCommand.java new file mode 100644 index 000000000..88c8f9c8f --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/GiveTrackCommand.java @@ -0,0 +1,79 @@ +package mineplex.core.titles.commands; + +import java.util.List; +import java.util.stream.Collectors; + +import org.bukkit.command.CommandSender; +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.core.titles.tracks.ItemizedTrack; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackManager; + +public class GiveTrackCommand extends CommandBase +{ + public GiveTrackCommand(TrackManager plugin) + { + super(plugin, Rank.ADMIN, "givetrack" ); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 2) + { + UtilPlayer.message(caller, F.help("/givetrack ", "Give a player an unlockable track", GetRequiredRank())); + return; + } + + String player = args[0]; + String track = args[1]; + + Track trackObj = Plugin.getTrackById(track); + + if (trackObj == null) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "That is not a track" )); + return; + } + + if (!(trackObj instanceof ItemizedTrack)) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "That is not an unlockable track" )); + return; + } + + Plugin.unlockTrack(player, track, result -> { + switch (result) + { + case PLAYER_NOT_FOUND: + UtilPlayer.message(caller, F.main(Plugin.getName(), "That player has never joined Mineplex!")); + break; + case UNKNOWN_ERROR: + UtilPlayer.message(caller, F.main(Plugin.getName(), "Oops. Something has gone wrong while giving " + F.elem(player) + " the track " + F.elem(track) + "!")); + break; + case SUCCESS: + UtilPlayer.message(caller, F.main(Plugin.getName(), "Successfully gave " + F.elem(player) + " the track " + F.elem(track) + "!")); + break; + } + }); + } + + @Override + public List onTabComplete(CommandSender sender, String commandLabel, String[] args) + { + if (args.length == 1) + { + return tabCompletePlayerNames(sender, args); + } + if (args.length == 2) + { + return getMatches(args[1], Plugin.getAllTracks().stream().filter(track -> track instanceof ItemizedTrack).map(Track::getId).collect(Collectors.toList())); + } + return null; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/TrackCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/TrackCommand.java index 0617028ff..f17dc9574 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/TrackCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/commands/TrackCommand.java @@ -1,5 +1,8 @@ package mineplex.core.titles.commands; +import java.util.List; + +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mineplex.core.Managers; @@ -10,6 +13,7 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.titles.Titles; +import mineplex.core.titles.tracks.ItemizedTrack; import mineplex.core.titles.tracks.Track; import mineplex.core.titles.tracks.TrackManager; @@ -52,4 +56,17 @@ public class TrackCommand extends CommandBase } Plugin.setOrToggleTrackForPlayer(caller, track, args.length > 1); } + + @Override + public List onTabComplete(CommandSender sender, String commandLabel, String[] args) + { + if (args.length == 1) + { + if (sender instanceof Player) + { + return getMatches(args[0], _trackManager.getAllTracks().stream().filter(track -> track.getRequirements().getTier((Player) sender) != null).map(Track::getId)); + } + } + return null; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/ItemizedTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/ItemizedTrack.java new file mode 100644 index 000000000..87086d516 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/ItemizedTrack.java @@ -0,0 +1,35 @@ +package mineplex.core.titles.tracks; + +import net.md_5.bungee.api.ChatColor; + +import org.bukkit.entity.Player; + +import mineplex.core.Managers; +import mineplex.core.inventory.InventoryManager; + +public class ItemizedTrack extends Track +{ + private final InventoryManager _inventoryManager = Managers.require(InventoryManager.class); + + public ItemizedTrack(String trackId, String shortName, String description, boolean hideIfUnowned) + { + super(trackId, shortName, description, hideIfUnowned); + special(); + } + + public ItemizedTrack(String trackId, ChatColor color, String shortName, String longName, String description) + { + super(trackId, color, shortName, longName, description); + special(); + } + + public ItemizedTrack(String trackId, ChatColor color, String shortName, String longName, String description, boolean hideIfUnowned) + { + super(trackId, color, shortName, longName, description, hideIfUnowned); + special(); + } + + public boolean owns(Player player) { + return _inventoryManager.Get(player).getItemCount("track." + getId()) > 0; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/Track.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/Track.java index 225733a00..bb436bd21 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/Track.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/Track.java @@ -50,7 +50,7 @@ public class Track implements Listener { // Book limits Validate.isTrue(shortName.length() <= 16, "Short name cannot be longer than 16 characters"); - Validate.isTrue(trackId.length() <= 16, "ID cannot be longer than 16 characters"); + Validate.isTrue(trackId.length() <= 32, "ID cannot be longer than 32 characters"); this._id = trackId; this._shortName = shortName; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java index 1e6e3b91c..30072b414 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java @@ -5,9 +5,42 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.function.Consumer; + +import mineplex.core.titles.tracks.award.AprilFools2017Track; +import net.md_5.bungee.api.ChatColor; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import mineplex.core.MiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.Callback; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.titles.commands.GiveTrackCommand; +import mineplex.core.titles.tracks.award.Bridges2017Track; +import mineplex.core.titles.tracks.custom.DongerTrack; +import mineplex.core.titles.tracks.custom.EarlyBirdTrack; +import mineplex.core.titles.tracks.custom.HappyGaryTrack; +import mineplex.core.titles.tracks.custom.LeaderTrack; +import mineplex.core.titles.tracks.custom.SnekTrack; +import mineplex.core.titles.tracks.custom.TableFlipTrack; +import mineplex.core.titles.tracks.custom.TrackBuilder; +import mineplex.core.titles.tracks.custom.WizardTrack; +import mineplex.core.titles.tracks.standard.GemCollectorTrack; +import mineplex.core.titles.tracks.standard.HolidayCheerTrack; +import mineplex.core.titles.tracks.standard.LevelerTrack; +import mineplex.core.titles.tracks.standard.LuckyTrack; +import mineplex.core.titles.tracks.standard.MineplexMasteryTrack; +import mineplex.core.titles.tracks.standard.PartyAnimalTrack; +import mineplex.core.titles.tracks.standard.PeacefulTrack; +import mineplex.core.titles.tracks.standard.PerfectionistTrack; +import mineplex.core.titles.tracks.standard.PowerPlayTrack; +import mineplex.core.titles.tracks.standard.SweetToothTrack; +import mineplex.core.titles.tracks.standard.TreasureHunterTrack; +import mineplex.core.titles.tracks.standard.UnluckyTrack; +import mineplex.core.titles.tracks.standard.WarriorTrack; @ReflectivelyCreateMiniPlugin public class TrackManager extends MiniPlugin @@ -15,6 +48,9 @@ public class TrackManager extends MiniPlugin private final Map, Track> _registeredTracks = new LinkedHashMap<>(); private final Map _trackById = new HashMap<>(); + private final InventoryManager _inventoryManager = require(InventoryManager.class); + private final CoreClientManager _coreClientManager = require(CoreClientManager.class); + private TrackManager() { super("Track Manager"); @@ -42,10 +78,73 @@ public class TrackManager extends MiniPlugin // registerTrack(new SurvivorTrack()); registerTrack(new LevelerTrack()); registerTrack(new PerfectionistTrack()); + + // Awarded tracks + registerTrack(new Bridges2017Track()); + registerTrack(new AprilFools2017Track()); + + // Custom tracks +// registerTrack(track("lenny", "Lenny", "( ͡° ͜ʖ ͡°)")); +// registerTrack(track("lenny-disgusted", "Disgusted Lenny", "( ͡ಠ ʖ̯ ͡ಠ)")); +// registerTrack(track("lenny-winking", "Winking Lenny", "( ͡~ ͜ʖ ͡°)")); + registerTrack(track("ayyye", "Ayyye", "(づ ̄ ³ ̄)づ")); + registerTrack(track("ameno", "Ameno", "༼ つ ◕_◕ ༽つ Gib me gems")); +// registerTrack(track("unknown", "Unknown", "(☞゚ヮ゚)☞")); + registerTrack(track("shrug", "Shrug", "¯\\_(ツ)_/¯")); + registerTrack(track("tableflip", "Tableflip", "(╯°□°)╯︵ ┻━┻")); + registerTrack(track("tablerespecter", "Table Respecter", "┬─┬ノ(ಠ_ಠノ)")); + registerTrack(track("tableflip-disgusted", "Disgusted Flip", "Disgusted Tableflip", "(╯ಠ_ಠ)╯︵ ┳━┳")); +// registerTrack(track("tableflip-donger", "Donger Flip", "ヽ༼ຈل͜ຈ༽ノ︵┻━┻")); + registerTrack(track("tableflip-enraged", "Enraged Flip", "(ノಠдಠ)ノ︵┻━┻")); + registerTrack(track("tableflip-riot", "Rioting Flip", "(┛◉Д◉)┛彡┻━┻")); + registerTrack(track("magician", "Magician", "(ノ◕ヮ◕)ノ*:・゚✧")); + registerTrack(track("teddy-bear", "Teddy Bear", "ʕ•ᴥ•ʔ")); + registerTrack(track("disgust", "Disgust", "ಠ_ಠ")); + registerTrack(track("old-man", "Old Man", "໒( •̀ ╭ ͟ʖ╮ •́ )७")); + registerTrack(track("jake", "Jake", "(❍ᴥ❍ʋ)")); + registerTrack(track("finn", "Finn", "| (• ◡•)|")); + registerTrack(track("finn-and-jake", "Finn 'n Jake", "| (• ◡•)| (❍ᴥ❍ʋ)")); + registerTrack(track("boxer", "Boxer", "(ง'̀-'́)ง")); + registerTrack(track0("zoidberg", "Zoidberg", "Why not?", "(\\/) (°,,°) (\\/)")); + registerTrack(track("crying", "Crying", "(ಥ﹏ಥ)")); +// registerTrack(track("unknown", "Unknown", "(◕‿◕✿)")); + registerTrack(track("fireball", "Fireball", "༼つಠ益ಠ༽つ ─=≡ΣO))")); + registerTrack(track("stardust", "Stardust", "(つ◕౪◕)つ━☆゚.*・。゚")); + registerTrack(track("magic-missile", "Magic Missile", "( °-°)シ ミ★ ミ☆")); + registerTrack(track("blow-a-kiss", "Blowing a Kiss", "♡(´ε` )")); + registerTrack(track("pewpewpew", "PEWPEWPEW", "(☞^o^)☞")); +// registerTrack(track("pewpew", "pew pew", "(☞゚ヮ゚)☞")); + registerTrack(track("cool-guy", "Cool Guy", "(⌐■_■)")); +// registerTrack(track("unknown", "Unknown", "(ง •̀ω•́)ง✧")); +// registerTrack(track("unknown", "Unknown", "(╯⊙ ⊱ ⊙╰ )")); + registerTrack(track("party-time", "Party Time", "♪~ ᕕ(ᐛ)ᕗ")); + registerTrack(track1("whats-a-liter", "What's a Liter?", "also wats a leader")); + + registerTrack(animatedTrack("deal-with-it", "Deal With It", "(⌐■_■)", "( •_•);( •_•)>⌐■-■;(⌐■_■);( •_•)>⌐■-■", 5)); + registerTrack(animatedTrack("this-guy", "This Guy", "(☞゚ヮ゚)☞", "(☞゚ヮ゚)☞;☜(゚ヮ゚☜)", 5)); + registerTrack(animatedTrack("lalala", "La La La", "♪┏(・o・) ┛", "♪┏(・o・) ┛;♪┗ ( ・o・) ┓♪;┏ ( ・o・) ┛♪;┗ (・o・ ) ┓♪;┏(・o・)┛♪", 1)); + registerTrack(animatedTrack("gotta-go", "Gotta Go", "┬┴┬┴┤(・_├┬┴┬┴", "┬┴┬┴┤(・_├┬┴┬┴;┬┴┬┴┤ (・├┬┴┬┴;┬┴┬┴┤ (├┬┴┬┴;┬┴┬┴┤ (・├┬┴┬┴", 5)); +// registerTrack(animatedTrack("unknown", "Unknown", "(o°▽°)o", "(o°▽°)o;(o_△_)o;(o°▽°)o", 5)); + registerTrack(animatedTrack("rolling-around", "Rolling Around", "(゚‐゚)", "(.-.);(:I );(゚‐゚);( I:)", 4)); +// registerTrack(animatedTrack("unknown", "Unknown", "('ω')", "('ω');( ε: );(.ω.);( :3 );('ω');( ε: );(.ω.);( :3 )", 5)); +// registerTrack(animatedTrack("whee", "Whee", "(゚ー゚)", "(゚ー゚);( ゚ー);( ゚);(  );(゚ );(ー゚ );(゚ー゚)", 1)); +// registerTrack(animatedTrack("lets-spin", "Let's Spin", "I Say, Let's Spin", "(・ω・)", "( ・ω);( ・);( );(・ );(ω・ );(・ω・)", 1)); +// registerTrack(animatedTrack("unknown", "Unknown", "(^∀^)", "(^∀^);( ^∀);( ^);(  );(^ );(∀^ );(^∀^)", 5)); + registerTrack(animatedTrack("whaaat", "Whaaaaaat?", "(°o°)", "(°o°);(°o。);(。o。);(。o°);(°o°);(°o。);(。o。);(。o°)", 5)); +// registerTrack(animatedTrack("spinning", "Spinning", "(゚◇゚)", "(゚◇゚);( ゚◇);( ゚);(  );(゚ );(◇゚ );(゚◇", 5)); +// registerTrack(animatedTrack("unknown", "Unknown", "(・∇・)", "(・∇・);( ・∇);( ・);(  );(・ );(∇・ );(・∇・)", 5)); + } + + @Override + public void addCommands() + { + addCommand(new GiveTrackCommand(this)); } private void registerTrack(Track track) { + if (_trackById.containsKey(track.getId())) + throw new IllegalArgumentException("Duplicate id: " + track.getId()); _registeredTracks.put(track.getClass(), track); _trackById.put(track.getId(), track); } @@ -62,6 +161,144 @@ public class TrackManager extends MiniPlugin public final List getAllTracks() { - return new ArrayList<>(_registeredTracks.values()); + return new ArrayList<>(_trackById.values()); + } + + public boolean hasTrack(Player player, Track track) + { + return _inventoryManager.Get(player).getItemCount("track." + track.getId()) > 0; + } + + public void unlockTrack(Player player, Track track) + { + unlockTrack(player, track, null); + } + + public void unlockTrack(Player player, Track track, Consumer consumer) + { + unlockTrack(player.getName(), track.getId(), consumer); + } + + public void unlockTrack(String player, String track, Consumer consumer) + { + _coreClientManager.getOrLoadClient(player, client -> + { + if (client == null) + { + if (consumer != null) + consumer.accept(TrackGiveResult.PLAYER_NOT_FOUND); + return; + } + + runAsync(() -> + { + Callback successCallback = success -> + { + if (success) + { + if (consumer != null) + consumer.accept(TrackGiveResult.SUCCESS); + } + else + { + if (consumer != null) + consumer.accept(TrackGiveResult.UNKNOWN_ERROR); + } + }; + + Player playerObj = Bukkit.getPlayer(client.getUniqueId()); + + if (playerObj != null) + { + _inventoryManager.addItemToInventory(successCallback, playerObj, "track." + track, 1); + } + else + { + _inventoryManager.addItemToInventoryForOffline(successCallback, client.getAccountId(), "track." + track, 1); + } + }); + }); + } + + public enum TrackGiveResult + { + PLAYER_NOT_FOUND, + UNKNOWN_ERROR, + SUCCESS + } + + // Begin helper methods + private ItemizedTrack animatedTrack(String id, String name, String desc, String frames, int ticks) + { + return TrackBuilder.builder(id) + .withShortName(name) + .withDescription(desc) + .setFrames(frames.split(";")) + .setTicks(ticks) + .withColor(ChatColor.GOLD) + .setHideIfUnowned(true) + .build(); + } + + private ItemizedTrack animatedTrack(String id, String name, String longName, String desc, String frames, int ticks) + { + return TrackBuilder.builder(id) + .withShortName(name) + .withLongName(longName) + .withDescription(desc) + .setFrames(frames.split(";")) + .setTicks(ticks) + .withColor(ChatColor.GOLD) + .setHideIfUnowned(true) + .build(); + } + + private ItemizedTrack track(String id, String name, String tierName) + { + return TrackBuilder.builder(id) + .withShortName(name) + .withDescription(tierName) + .setTierName(tierName) + .withColor(ChatColor.GOLD) + .setTierColor(ChatColor.GOLD) + .setHideIfUnowned(true) + .build(); + } + + private ItemizedTrack track0(String id, String shortName, String desc, String tierName) + { + return TrackBuilder.builder(id) + .withShortName(shortName) + .withDescription(desc) + .setTierName(tierName) + .withColor(ChatColor.GOLD) + .setTierColor(ChatColor.GOLD) + .setHideIfUnowned(true) + .build(); + } + + private ItemizedTrack track1(String id, String name, String desc) + { + return TrackBuilder.builder(id) + .withShortName(name) + .withDescription(desc) + .setTierName(name) + .withColor(ChatColor.GOLD) + .setTierColor(ChatColor.GOLD) + .setHideIfUnowned(true) + .build(); + } + + private ItemizedTrack track(String id, String shortName, String longName, String tierName) + { + return TrackBuilder.builder(id) + .withShortName(shortName) + .withLongName(longName) + .withDescription(tierName) + .setTierName(tierName) + .withColor(ChatColor.GOLD) + .setTierColor(ChatColor.GOLD) + .setHideIfUnowned(true) + .build(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/AprilFools2017Track.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/AprilFools2017Track.java new file mode 100644 index 000000000..4df96a59b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/AprilFools2017Track.java @@ -0,0 +1,30 @@ +package mineplex.core.titles.tracks.award; + +import mineplex.core.titles.tracks.ItemizedTrack; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; +import net.md_5.bungee.api.ChatColor; + +public class AprilFools2017Track extends ItemizedTrack +{ + + public AprilFools2017Track() + { + super( + "aprilfools-2017", + ChatColor.LIGHT_PURPLE, + "Fools 2017", + "2017 April Fools Treasure Hunt", + "This track is awarded to players who found all the chests in the 2017 April Fools Event", + true); + + special(); + + getRequirements() + .addTier(new TrackTier( + "2017 April Fools", + null, + this::owns, + new TrackFormat(ChatColor.LIGHT_PURPLE, ChatColor.DARK_PURPLE) + )); } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/Bridges2017Track.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/Bridges2017Track.java new file mode 100644 index 000000000..90bb2fee3 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/Bridges2017Track.java @@ -0,0 +1,31 @@ +package mineplex.core.titles.tracks.award; + +import net.md_5.bungee.api.ChatColor; + +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; +import mineplex.core.titles.tracks.ItemizedTrack; + +public class Bridges2017Track extends ItemizedTrack +{ + public Bridges2017Track() + { + super( + "tournament-br-2017", + ChatColor.GOLD, + "BotB 2017", + "2017 Bridges Champion", + "This track is awarded to the winners of the 2017 BotB Tournament", + true); + + special(); + + getRequirements() + .addTier(new TrackTier( + "2017 Bridges Champion", + null, + this::owns, + new TrackFormat(ChatColor.GOLD, ChatColor.GOLD) + )); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/DongerTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/DongerTrack.java similarity index 75% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/DongerTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/DongerTrack.java index 9d03b4eb1..bdefb8144 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/DongerTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/DongerTrack.java @@ -1,4 +1,4 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.custom; import java.util.Set; @@ -6,6 +6,10 @@ import net.md_5.bungee.api.ChatColor; import com.google.common.collect.Sets; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; + public class DongerTrack extends Track { private static final Set OWNERS = Sets.newHashSet( @@ -13,7 +17,7 @@ public class DongerTrack extends Track "a20d59d1-cfd8-4116-ac27-45d9c7eb4a97" ); - protected DongerTrack() + public DongerTrack() { super("donger", ChatColor.AQUA, "Donger", "Donger", "ヽ༼ຈل͜ຈ༽ノ", true); special(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/EarlyBirdTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/EarlyBirdTrack.java similarity index 88% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/EarlyBirdTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/EarlyBirdTrack.java index 9e7551900..5fd11ec04 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/EarlyBirdTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/EarlyBirdTrack.java @@ -1,4 +1,4 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.custom; import java.sql.ResultSet; import java.sql.SQLException; @@ -15,12 +15,15 @@ import com.google.common.collect.Sets; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; import mineplex.core.account.ILoginProcessor; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; public class EarlyBirdTrack extends Track { private final Set _wonEternal = Sets.newConcurrentHashSet(); - protected EarlyBirdTrack() + public EarlyBirdTrack() { super("early-bird", ChatColor.AQUA, "Early Bird", "Early Bird", "This track is unlocked by receiving the Eternal rank from chickens in the 2016 Thanksgiving Event", true); special(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/HappyGaryTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/HappyGaryTrack.java similarity index 81% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/HappyGaryTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/HappyGaryTrack.java index fe75d1bf4..25b98d970 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/HappyGaryTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/HappyGaryTrack.java @@ -1,4 +1,4 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.custom; import java.util.Set; @@ -9,12 +9,15 @@ import com.google.common.collect.Sets; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; public class HappyGaryTrack extends Track { private final CoreClientManager _coreClientManager = Managers.require(CoreClientManager.class); - protected HappyGaryTrack() + public HappyGaryTrack() { super("happygary", ChatColor.GOLD, "Happy Gary", "Happy Gary", "ᐛ", true); special(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/LeaderTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/LeaderTrack.java similarity index 75% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/LeaderTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/LeaderTrack.java index 80b14ce33..e7a600b17 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/LeaderTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/LeaderTrack.java @@ -1,16 +1,19 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.custom; import net.md_5.bungee.api.ChatColor; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; public class LeaderTrack extends Track { private final CoreClientManager _coreClientManager = Managers.require(CoreClientManager.class); - protected LeaderTrack() + public LeaderTrack() { super("leader", ChatColor.DARK_RED, "Leader", "What's a Leader?", "also wat does dev mean", true); special(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/SnekTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/SnekTrack.java similarity index 74% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/SnekTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/SnekTrack.java index 7d2f1ad51..5744f36b3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/SnekTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/SnekTrack.java @@ -1,4 +1,4 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.custom; import java.util.Set; @@ -6,13 +6,17 @@ import net.md_5.bungee.api.ChatColor; import com.google.common.collect.Sets; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; + public class SnekTrack extends Track { private static final Set OWNERS = Sets.newHashSet( "b86b54da-93dd-46f9-be33-27bd92aa36d7" ); - protected SnekTrack() + public SnekTrack() { super("snek", ChatColor.DARK_GREEN, "Snek", "Snek", "oh you have do me a frighten", true); special(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TableFlipTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/TableFlipTrack.java similarity index 77% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TableFlipTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/TableFlipTrack.java index 4924fe3ef..8ea5f3590 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TableFlipTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/TableFlipTrack.java @@ -1,18 +1,21 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.custom; import net.md_5.bungee.api.ChatColor; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; public class TableFlipTrack extends Track { private final CoreClientManager _coreClientManager = Managers.require(CoreClientManager.class); - protected TableFlipTrack() + public TableFlipTrack() { - super("tableflip", ChatColor.AQUA, "Tableflip", "Tableflip", "(╯°□°)╯ ︵ ┻━┻", true); + super("tableflipanim", ChatColor.AQUA, "Tableflip", "Tableflip", "(╯°□°)╯ ︵ ┻━┻", true); special(); getRequirements() .addTier(new TrackTier( diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/TrackBuilder.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/TrackBuilder.java new file mode 100644 index 000000000..1747b2c73 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/TrackBuilder.java @@ -0,0 +1,173 @@ +package mineplex.core.titles.tracks.custom; + +import net.md_5.bungee.api.ChatColor; + +import org.apache.commons.lang3.Validate; + +import mineplex.core.titles.tracks.ItemizedTrack; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; + +public class TrackBuilder +{ + private String _id; + private String _shortName; + private String _longName; + private ChatColor _color; + private String _desc; + private boolean _hideIfUnowned; + + private String _tierName; + private String _tierDesc; + private ChatColor _tierColor; + private ChatColor _magicColor; + + private int _ticks; + private String[] _frames; + + private TrackBuilder(String id) + { + this._id = id; + } + + public TrackBuilder withShortName(String shortName) + { + Validate.notNull(shortName, "Short name cannot be null"); + this._shortName = shortName.length() > 16 ? shortName.substring(0, 16) : shortName; + return this; + } + + public TrackBuilder withLongName(String longName) + { + Validate.notNull(longName, "Long name cannot be null"); + this._longName = longName; + return this; + } + + public TrackBuilder withColor(ChatColor color) + { + Validate.notNull(color, "Color cannot be null"); + this._color = color; + return this; + } + + public TrackBuilder withDescription(String desc) + { + Validate.notNull(desc, "Description cannot be null"); + this._desc = desc; + return this; + } + + public TrackBuilder setHideIfUnowned(boolean hide) + { + this._hideIfUnowned = hide; + return this; + } + + public TrackBuilder setTierName(String tierName) + { + Validate.notNull(tierName, "Tier name cannot be null"); + this._tierName = tierName; + return this; + } + + public TrackBuilder setTierDesc(String tierDesc) + { + Validate.notNull(tierDesc, "Tier desc cannot be null"); + this._tierDesc = tierDesc; + return this; + } + + public TrackBuilder setTierColor(ChatColor tierColor) + { + Validate.notNull(tierColor, "Tier color cannot be null"); + this._tierColor = tierColor; + return this; + } + + public TrackBuilder setTierMagicColor(ChatColor magicColor) + { + Validate.notNull(magicColor, "Magic color cannot be null"); + this._magicColor = magicColor; + return this; + } + + public TrackBuilder setFrames(String... frames) + { + Validate.notNull(frames, "Frames cannot be null"); + if (frames.length == 0) + return this; + this._frames = frames; + return this; + } + + public TrackBuilder setTicks(int ticks) + { + this._ticks = ticks; + return this; + } + + public T build() + { + Validate.notNull(_id, "ID cannot be null"); + Validate.notNull(_color, "Color cannot be null"); + Validate.notNull(_shortName, "Short name cannot be null"); + + if (_desc == null) + _desc = _shortName; + if (_longName == null) + _longName = _shortName; + if (_tierColor == null) + _tierColor = _color; + if (_tierName == null) + _tierName = _shortName; + if (_tierDesc == null) + _tierDesc = _desc; + + if (_frames == null) + { + return (T) new ItemizedTrack(_id, _color, _shortName, _longName, _desc, _hideIfUnowned) + { + ItemizedTrack init() + { + getRequirements() + .addTier(new TrackTier( + _tierName, + _tierDesc, + this::owns, + new TrackFormat(_tierColor, _magicColor) + )); + return this; + } + }.init(); + } + else + { + Validate.isTrue(_ticks >= 1, "Ticks must be >= 1"); + + return (T) new ItemizedTrack(_id, _color, _shortName, _longName, _desc, _hideIfUnowned) + { + ItemizedTrack init() + { + getRequirements() + .addTier(new TrackTier( + _tierName, + _tierDesc, + this::owns, + new TrackFormat(_tierColor, _magicColor) + .animated(_ticks, _frames) + )); + return this; + } + }.init(); + } + } + + public static TrackBuilder builder(String id) + { + Validate.notNull(id, "ID cannot be null"); + Validate.isTrue(id.length() <= 32, "ID must not be longer than 32 characters"); + return new TrackBuilder(id); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/WizardTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/WizardTrack.java similarity index 81% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/WizardTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/WizardTrack.java index 768c67620..3f0e85c3e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/WizardTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/WizardTrack.java @@ -1,4 +1,4 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.custom; import java.util.Set; @@ -6,6 +6,10 @@ import net.md_5.bungee.api.ChatColor; import com.google.common.collect.Sets; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; + // hmu t3 public class WizardTrack extends Track { @@ -14,7 +18,7 @@ public class WizardTrack extends Track "2016b565-0a63-4a2d-800b-b786ac256288" ); - protected WizardTrack() + public WizardTrack() { super("wizard", ChatColor.DARK_PURPLE, "Wizard", "Wizard", "(ノ◕ヮ◕)ノ*:・゚✧", true); special(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/GemCollectorTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/GemCollectorTrack.java similarity index 89% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/GemCollectorTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/GemCollectorTrack.java index f3dfde3e5..1fa16a704 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/GemCollectorTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/GemCollectorTrack.java @@ -1,10 +1,13 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.standard; import net.md_5.bungee.api.ChatColor; import org.bukkit.entity.Player; import mineplex.core.gadget.set.SetEmerald; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; public class GemCollectorTrack extends Track { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/HolidayCheerTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/HolidayCheerTrack.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/HolidayCheerTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/HolidayCheerTrack.java index 547a84087..ecfc2ba3c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/HolidayCheerTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/HolidayCheerTrack.java @@ -1,4 +1,4 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.standard; import java.util.HashMap; import java.util.HashSet; @@ -24,6 +24,9 @@ import mineplex.core.gadget.set.SetFreedom; import mineplex.core.gadget.set.SetFrostLord; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetSet; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; import mineplex.core.treasure.TreasureType; import mineplex.core.treasure.event.TreasureStartEvent; @@ -48,6 +51,7 @@ public class HolidayCheerTrack extends Track HOLIDAY_CHESTS.add(TreasureType.TRICK_OR_TREAT); HOLIDAY_CHESTS.add(TreasureType.GINGERBREAD); HOLIDAY_CHESTS.add(TreasureType.LOVE_CHEST); + HOLIDAY_CHESTS.add(TreasureType.ST_PATRICKS); HOLIDAY_SETS.add(SetFreedom.class); HOLIDAY_SETS.add(SetCupidsLove.class); @@ -111,7 +115,7 @@ public class HolidayCheerTrack extends Track @EventHandler public void onUseCosmetic(TreasureStartEvent event) { - if (!HOLIDAY_CHESTS.contains(event.getTreasureType())) + if (!HOLIDAY_CHESTS.contains(event.getTreasure().getTreasureType())) return; int points = 100; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/KitCollectorTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/KitCollectorTrack.java similarity index 90% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/KitCollectorTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/KitCollectorTrack.java index df1366f33..66657f5a9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/KitCollectorTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/KitCollectorTrack.java @@ -1,4 +1,4 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.standard; import net.md_5.bungee.api.ChatColor; @@ -8,6 +8,9 @@ import mineplex.core.Managers; import mineplex.core.achievement.AchievementCategory; import mineplex.core.donation.DonationManager; import mineplex.core.game.GameDisplay; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; public class KitCollectorTrack extends Track { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/LevelerTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/LevelerTrack.java similarity index 90% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/LevelerTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/LevelerTrack.java index f079f9d52..5d16b8da8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/LevelerTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/LevelerTrack.java @@ -1,10 +1,13 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.standard; import net.md_5.bungee.api.ChatColor; import mineplex.core.Managers; import mineplex.core.achievement.Achievement; import mineplex.core.achievement.AchievementManager; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; public class LevelerTrack extends Track { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/LuckyTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/LuckyTrack.java similarity index 90% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/LuckyTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/LuckyTrack.java index a79ffe7ec..7bbf3bb83 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/LuckyTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/LuckyTrack.java @@ -1,4 +1,4 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.standard; import java.util.EnumMap; import java.util.HashSet; @@ -14,6 +14,9 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.reward.Reward; import mineplex.core.reward.RewardRarity; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; import mineplex.core.treasure.TreasureType; import mineplex.core.treasure.event.TreasureStartEvent; @@ -34,6 +37,8 @@ public class LuckyTrack extends Track MULTIPLIER.put(TreasureType.HAUNTED, 2); MULTIPLIER.put(TreasureType.CHRISTMAS, 2); MULTIPLIER.put(TreasureType.TRICK_OR_TREAT, 2); + MULTIPLIER.put(TreasureType.LOVE_CHEST, 2); + MULTIPLIER.put(TreasureType.ST_PATRICKS, 2); MULTIPLIER.put(TreasureType.OMEGA, 3); IRON.add(Material.IRON_SPADE); @@ -119,8 +124,8 @@ public class LuckyTrack extends Track int basePoints = POINTS.get(reward.getRarity()); - if (MULTIPLIER.get(event.getTreasureType()) != null) - basePoints *= MULTIPLIER.get(event.getTreasureType()); + if (MULTIPLIER.get(event.getTreasure().getTreasureType()) != null) + basePoints *= MULTIPLIER.get(event.getTreasure().getTreasureType()); incrementFor(event.getPlayer(), basePoints); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/MineplexMasteryTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/MineplexMasteryTrack.java similarity index 86% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/MineplexMasteryTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/MineplexMasteryTrack.java index 6135da8af..326ac6d98 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/MineplexMasteryTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/MineplexMasteryTrack.java @@ -1,4 +1,4 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.standard; import net.md_5.bungee.api.ChatColor; @@ -7,12 +7,15 @@ import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.game.GameDisplay; import mineplex.core.stats.StatsManager; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; public class MineplexMasteryTrack extends Track { private final StatsManager _statsManager; - protected MineplexMasteryTrack() + public MineplexMasteryTrack() { super("mineplex-mastery", "Mineplex Mastery", "This track is unlocked by winning different games on Mineplex"); getRequirements() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/PartyAnimalTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/PartyAnimalTrack.java similarity index 91% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/PartyAnimalTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/PartyAnimalTrack.java index 96426f84d..a626e623d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/PartyAnimalTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/PartyAnimalTrack.java @@ -1,4 +1,4 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.standard; import java.util.HashMap; import java.util.Map; @@ -13,6 +13,9 @@ import mineplex.core.gadget.gadgets.item.ItemFirework; import mineplex.core.gadget.gadgets.item.ItemPartyPopper; import mineplex.core.gadget.set.SetParty; import mineplex.core.gadget.types.Gadget; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; public class PartyAnimalTrack extends Track { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/PeacefulTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/PeacefulTrack.java similarity index 90% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/PeacefulTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/PeacefulTrack.java index 123856b8d..1afd61773 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/PeacefulTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/PeacefulTrack.java @@ -1,4 +1,4 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.standard; import java.util.HashSet; import java.util.Set; @@ -9,6 +9,9 @@ import org.bukkit.entity.Player; import mineplex.core.gadget.set.SetMusic; import mineplex.core.game.GameDisplay; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; public class PeacefulTrack extends Track { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/PerfectionistTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/PerfectionistTrack.java similarity index 86% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/PerfectionistTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/PerfectionistTrack.java index ceb768357..7bd458dd5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/PerfectionistTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/PerfectionistTrack.java @@ -1,10 +1,14 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.standard; import net.md_5.bungee.api.ChatColor; import org.bukkit.entity.Player; import mineplex.core.Managers; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackManager; +import mineplex.core.titles.tracks.TrackTier; public class PerfectionistTrack extends Track { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/PowerPlayTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/PowerPlayTrack.java similarity index 53% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/PowerPlayTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/PowerPlayTrack.java index 72730bc78..81fe01721 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/PowerPlayTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/PowerPlayTrack.java @@ -1,23 +1,25 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.standard; import net.md_5.bungee.api.ChatColor; import mineplex.core.Managers; import mineplex.core.bonuses.BonusManager; -import mineplex.core.powerplayclub.PowerPlayClubRepository; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; public class PowerPlayTrack extends Track { - private final PowerPlayClubRepository _powerPlayClubRepository = Managers.require(BonusManager.class).getPowerPlayClubRepository(); + private final BonusManager _bonusManager = Managers.require(BonusManager.class); - protected PowerPlayTrack() + public PowerPlayTrack() { super("power-play", ChatColor.AQUA, "Power Play", "Power Play VIP", "This track is unlocked by subscribing to the Power Play Club"); getRequirements() .addTier(new TrackTier( "Power Play Club", null, - player -> _powerPlayClubRepository.getCachedData(player).isSubscribed() ? 1L : 0L, + player -> _bonusManager.getPowerPlayClubRepository().getCachedData(player).isSubscribed() ? 1L : 0L, 1, new TrackFormat(ChatColor.AQUA, ChatColor.AQUA) )); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/SurvivorTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/SurvivorTrack.java similarity index 80% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/SurvivorTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/SurvivorTrack.java index 31b4dca30..6c4cd34ef 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/SurvivorTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/SurvivorTrack.java @@ -1,7 +1,11 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.standard; import net.md_5.bungee.api.ChatColor; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; + public class SurvivorTrack extends Track { public SurvivorTrack() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/SweetToothTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/SweetToothTrack.java similarity index 91% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/SweetToothTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/SweetToothTrack.java index b3bd8ca15..b1e28da36 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/SweetToothTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/SweetToothTrack.java @@ -1,4 +1,4 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.standard; import java.util.HashMap; import java.util.Map; @@ -12,6 +12,9 @@ import mineplex.core.gadget.event.PlayerConsumeMelonEvent; import mineplex.core.gadget.gadgets.item.ItemLovePotion; import mineplex.core.gadget.set.SetCandyCane; import mineplex.core.gadget.types.Gadget; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; public class SweetToothTrack extends Track { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TreasureHunterTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/TreasureHunterTrack.java similarity index 86% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TreasureHunterTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/TreasureHunterTrack.java index 24348b954..30e7d193c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TreasureHunterTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/TreasureHunterTrack.java @@ -1,4 +1,4 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.standard; import java.util.EnumMap; @@ -7,6 +7,9 @@ import net.md_5.bungee.api.ChatColor; import org.bukkit.event.EventHandler; import mineplex.core.gadget.set.SetWisdom; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; import mineplex.core.treasure.TreasureType; import mineplex.core.treasure.event.TreasureStartEvent; @@ -27,6 +30,7 @@ public class TreasureHunterTrack extends Track POINTS.put(TreasureType.THANKFUL, 25); POINTS.put(TreasureType.GINGERBREAD, 25); POINTS.put(TreasureType.LOVE_CHEST, 25); + POINTS.put(TreasureType.ST_PATRICKS, 25); POINTS.put(TreasureType.OMEGA, 50); POINTS.put(TreasureType.MINESTRIKE, 3); } @@ -79,9 +83,9 @@ public class TreasureHunterTrack extends Track @EventHandler public void onUseCosmetic(TreasureStartEvent event) { - if (POINTS.containsKey(event.getTreasureType())) + if (POINTS.containsKey(event.getTreasure().getTreasureType())) { - int basePoints = POINTS.get(event.getTreasureType()); + int basePoints = POINTS.get(event.getTreasure().getTreasureType()); if (isSetActive(event.getPlayer(), SetWisdom.class)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/UnluckyTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/UnluckyTrack.java similarity index 94% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/UnluckyTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/UnluckyTrack.java index a23a3b332..3883722bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/UnluckyTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/UnluckyTrack.java @@ -1,4 +1,4 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.standard; import java.util.EnumMap; import java.util.HashSet; @@ -14,6 +14,9 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.reward.Reward; import mineplex.core.reward.RewardRarity; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; import mineplex.core.treasure.event.TreasureStartEvent; public class UnluckyTrack extends Track diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/WarriorTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/WarriorTrack.java similarity index 89% rename from Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/WarriorTrack.java rename to Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/WarriorTrack.java index fb6c129af..dfdd2383d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/WarriorTrack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/standard/WarriorTrack.java @@ -1,10 +1,13 @@ -package mineplex.core.titles.tracks; +package mineplex.core.titles.tracks.standard; import net.md_5.bungee.api.ChatColor; import org.bukkit.entity.Player; import mineplex.core.gadget.set.SetVampire; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackFormat; +import mineplex.core.titles.tracks.TrackTier; public class WarriorTrack extends Track { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java index 71b04ad99..f1e489390 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java @@ -49,9 +49,6 @@ import mineplex.core.treasure.animation.LootRareAnimation; import mineplex.core.treasure.animation.LootUncommonAnimation; import mineplex.core.treasure.animation.TreasureRemoveAnimation; -/** - * Created by Shaun on 8/27/2014. - */ public class Treasure { private BlockRestore _blockRestore; @@ -82,15 +79,18 @@ public class Treasure private HologramManager _hologramManager; private ServerStatusManager _statusManager; - public Treasure(Player player, Reward[] rewards, RewardType rewardType, Block centerBlock, Block[] chestBlocks, TreasureType treasureType, BlockRestore blockRestore, HologramManager hologramManager, ServerStatusManager statusManager) + private TreasureManager _treasureManager; + + public Treasure(TreasureManager treasureManager, Player player, Reward[] rewards, RewardType rewardType, Block centerBlock, Block[] chestBlocks, TreasureType treasureType, BlockRestore blockRestore, HologramManager hologramManager, ServerStatusManager statusManager) { - this(player, new Random(), rewards, rewardType, centerBlock, chestBlocks, treasureType, hologramManager, statusManager); + this(treasureManager, player, new Random(), rewards, rewardType, centerBlock, chestBlocks, treasureType, hologramManager, statusManager); _blockRestore = blockRestore; } - public Treasure(Player player, Random seed, Reward[] rewards, RewardType rewardType, Block centerBlock, Block[] chestBlocks, TreasureType treasureType, HologramManager hologramManager, ServerStatusManager statusManager) + public Treasure(TreasureManager treasureManager, Player player, Random seed, Reward[] rewards, RewardType rewardType, Block centerBlock, Block[] chestBlocks, TreasureType treasureType, HologramManager hologramManager, ServerStatusManager statusManager) { + _treasureManager = treasureManager; _player = player; _random = seed; @@ -215,6 +215,15 @@ public class Treasure double rX = Math.random() * 2 - 1, rZ = Math.random() * 2 - 1; UtilParticle.PlayParticle(type, block.getLocation().add(.5 + rX, .7, .5 + rZ), .5f, .5f, .5f, .25f, 1, ViewDist.NORMAL); } + else if (_treasureType == TreasureType.ST_PATRICKS) + { + 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.GREEN : new Color(0, 100, 0)), + 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, @@ -320,7 +329,7 @@ public class Treasure if (isFinished()) { - TreasureRemoveAnimation animation = new TreasureRemoveAnimation(Treasure.this, _openedChestBlockInfo, _chestBlockInfo); + TreasureRemoveAnimation animation = new TreasureRemoveAnimation(Treasure.this, _chestBlockInfo); _animations.add(animation); _finished = true; } @@ -452,4 +461,14 @@ public class Treasure { return _treasureType; } + + public void addAnimation(Animation animation) + { + _animations.add(animation); + } + + public TreasureManager getTreasureManager() + { + return _treasureManager; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java index b729b5d15..264da1eae 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureLocation.java @@ -115,6 +115,7 @@ public class TreasureLocation implements Listener return; } + chargeAccount(player, treasureType, new Callback() { @Override @@ -172,12 +173,12 @@ public class TreasureLocation implements Listener Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening " + pron + name)); } - TreasureStartEvent startEvent = new TreasureStartEvent(player, treasureType, Arrays.asList(rewards)); - UtilServer.CallEvent(startEvent); - - Treasure treasure = new Treasure(player, rewards, treasureType.getRewardType(), _chestBlock, _chestSpawns, treasureType, _treasureManager.getBlockRestore(), _hologramManager, _statusManager); + Treasure treasure = new Treasure(_treasureManager, player, rewards, treasureType.getRewardType(), _chestBlock, _chestSpawns, treasureType, _treasureManager.getBlockRestore(), _hologramManager, _statusManager); _currentTreasure = treasure; + TreasureStartEvent startEvent = new TreasureStartEvent(player, treasure, Arrays.asList(rewards)); + UtilServer.CallEvent(startEvent); + UtilTextMiddle.display(treasureType.getName(), "Choose " + rewards.length + " " + UtilText.plural("Chest", rewards.length) + " To Open", 20, 180, 20, player); UtilPlayer.message(player, F.main("Treasure", "Choose " + rewards.length + " " + UtilText.plural("Chest", rewards.length) + " To Open")); @@ -319,7 +320,7 @@ public class TreasureLocation implements Listener Location centerLocation = treasure.getCenterBlock().getLocation().add(0.5, 0.5, 0.5); if (event.getTo().distanceSquared(centerLocation) > 9) { - Location newTo = event.getFrom(); + Location newTo = centerLocation.clone(); newTo.setPitch(event.getTo().getPitch()); newTo.setYaw(event.getTo().getYaw()); event.setTo(newTo); @@ -339,8 +340,13 @@ public class TreasureLocation implements Listener double fromDistanceFromCenter = centerLocation.distanceSquared(fromLocation); if (toDistanceFromCenter < fromDistanceFromCenter) { - Location spawnLocation = new Location(player.getWorld(), 0, 64, 0); - UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), spawnLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true); + Entity target = player; + while (target.getVehicle() != null) + { + target = target.getVehicle(); + } + Location spawnLocation = new Location(target.getWorld(), 0, 64, 0); + UtilAction.velocity(target, UtilAlg.getTrajectory(target.getLocation(), spawnLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java index 01c4b1e54..13a13af58 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java @@ -1,11 +1,17 @@ package mineplex.core.treasure; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; import org.bukkit.Location; import org.bukkit.block.Block; +import org.bukkit.entity.Item; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.plugin.java.JavaPlugin; import com.google.common.collect.Lists; @@ -25,10 +31,12 @@ import mineplex.core.reward.RewardPool; import mineplex.core.reward.RewardType; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; +import mineplex.core.treasure.animation.Animation; +import mineplex.core.treasure.event.TreasureFinishEvent; +import mineplex.core.treasure.event.TreasureStartEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; -/** - * Created by Shaun on 8/27/2014. - */ public class TreasureManager extends MiniPlugin { private CoreClientManager _clientManager; @@ -39,6 +47,9 @@ public class TreasureManager extends MiniPlugin private StatsManager _statsManager; private List _treasureLocations; private List _blockLocations; + private List _items; + + private Map _treasureAnimations = new HashMap<>(); public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, GadgetManager gadgetManager, BlockRestore blockRestore, HologramManager hologramManager, StatsManager statsManager, RewardManager rewardManager) { @@ -53,6 +64,7 @@ public class TreasureManager extends MiniPlugin _treasureLocations = Lists.newArrayList(); _blockLocations = Lists.newArrayList(); + _items = Lists.newArrayList(); for(Location location : LocationConstants.CHEST_LOCATIONS) { @@ -161,4 +173,58 @@ public class TreasureManager extends MiniPlugin { return _blockLocations; } + + @EventHandler + public void playCustomAnimation(TreasureStartEvent event) + { + TreasureType treasureType = event.getTreasure().getTreasureType(); + /*if (treasureType == TreasureType.ST_PATRICKS) + { + StPatricksChestAnimation stPatricksChestAnimation = new StPatricksChestAnimation(event.getTreasure(), event.getTreasure().getCenterBlock()); + event.getTreasure().addAnimation(stPatricksChestAnimation); + _treasureAnimations.put(event.getTreasure(), stPatricksChestAnimation); + }*/ + } + + @EventHandler + public void stopCustomAnimation(TreasureFinishEvent event) + { + if (_treasureAnimations.containsKey(event.getTreasure())) + { + Animation animation = _treasureAnimations.get(event.getTreasure()); + animation.setRunning(false); + } + } + + public void addItem(Item item) + { + _items.add(item); + } + + @EventHandler + public void pickupItem(PlayerPickupItemEvent event) + { + if (_items.contains(event.getItem())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void removeItems(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK) + { + Iterator it = _items.iterator(); + while (it.hasNext()) + { + Item item = it.next(); + if (item.getTicksLived() >= 20) + { + item.remove(); + it.remove(); + } + } + } + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java index aab8d9172..b29622c3d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureStyle.java @@ -90,6 +90,13 @@ public enum TreasureStyle ParticleType.HEART, Sound.VILLAGER_YES, Sound.VILLAGER_YES + ), + STPATRICKS( + ParticleType.HAPPY_VILLAGER, + ParticleType.HAPPY_VILLAGER, + ParticleType.HAPPY_VILLAGER, + Sound.VILLAGER_YES, + Sound.VILLAGER_YES ); 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 8766e644a..c81c578c6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureType.java @@ -32,7 +32,9 @@ public enum TreasureType MINESTRIKE(C.cGold + "Minestrike Treasure", "Minestrike Chest", "MinestrikeChest", RewardType.MINESTRIKE_CHEST, Material.CHEST, TreasureStyle.MINESTRIKE, RewardPool.Type.MINESTRIKE, true, 10000), - LOVE_CHEST(C.cRed + "Love Treasure", "Love Chest", "LoveChest", RewardType.LOVE_CHEST, Material.CHEST, TreasureStyle.LOVECHEST, RewardPool.Type.LOVECHEST, true, 20000); + 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); 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 f98716e24..f2629eb1f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/BlockChangeAnimation.java @@ -94,6 +94,11 @@ public class BlockChangeAnimation extends Animation mat = Material.WOOL; data = 6; } + else if (getTreasure().getTreasureType() == TreasureType.ST_PATRICKS) + { + mat = Material.WOOL; + data = 13; + } else continue; @@ -141,6 +146,11 @@ public class BlockChangeAnimation extends Animation mat = Material.WOOL; data = 14; } + else if (getTreasure().getTreasureType() == TreasureType.ST_PATRICKS) + { + mat = Material.GOLD_BLOCK; + data = 0; + } else continue; 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 ce268629c..80eab149e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java @@ -36,9 +36,6 @@ import mineplex.core.treasure.BlockInfo; import mineplex.core.treasure.Treasure; import mineplex.core.treasure.TreasureType; -/** - * Created by Shaun on 8/29/2014. - */ public class ChestSpawnAnimation extends Animation { private static final int ANIMATION_DURATION = 80; @@ -46,7 +43,7 @@ public class ChestSpawnAnimation extends Animation private Block _block; private byte _direction; private Location _centerLocation; - + private Location _particleLocation; private Vector _particleDirection; @@ -134,7 +131,8 @@ public class ChestSpawnAnimation extends Animation UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), newLoc, 0f, 0f, 0f, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); } - else if (getTreasure().getTreasureType() == TreasureType.MYTHICAL || getTreasure().getTreasureType() == TreasureType.MINESTRIKE) + else if (getTreasure().getTreasureType() == TreasureType.MYTHICAL || getTreasure().getTreasureType() == TreasureType.MINESTRIKE || + getTreasure().getTreasureType() == TreasureType.ST_PATRICKS) { float y = 5 * scale; double width = 0.7 * ((double) getTicks() / (double) ANIMATION_DURATION); @@ -153,7 +151,10 @@ public class ChestSpawnAnimation extends Animation } else { - ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST, new DustSpellColor(Color.YELLOW), _centerLocation.clone().add(x * width, y, z * width)); + DustSpellColor minestrikeColor = new DustSpellColor(Color.YELLOW); + DustSpellColor stpatricksColor = new DustSpellColor(Color.GREEN); + ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST, + (getTreasure().getTreasureType() == TreasureType.MINESTRIKE) ? minestrikeColor : stpatricksColor, _centerLocation.clone().add(x * width, y, z * width)); coloredParticle.display(); } } @@ -245,6 +246,11 @@ public class ChestSpawnAnimation extends Animation doBats(true, _centerLocation.clone().add(0, 6, 0), _bats); } } + else if (getTreasure().getTreasureType() == TreasureType.ST_PATRICKS) + { + Location location = _centerLocation.clone().add(0, 5, 0); + + } //Spawn Chest if (getTicks() >= ANIMATION_DURATION) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/StPatricksChestAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/StPatricksChestAnimation.java new file mode 100644 index 000000000..4b65b5787 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/StPatricksChestAnimation.java @@ -0,0 +1,46 @@ +package mineplex.core.treasure.animation; + +import java.awt.Color; + +import org.bukkit.block.Block; +import org.bukkit.util.Vector; + +import mineplex.core.common.shape.ShapeWings; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.treasure.Treasure; + +public class StPatricksChestAnimation extends Animation +{ + + private Block _center; + private int _tick = 0; + + private ShapeWings _cloverBlack = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1, 1, 1), 1, 0, '#', ShapeWings.DEFAULT_ROTATION, ShapeWings.FOUR_LEAF_CLOVER); + private ShapeWings _cloverDarkGreen = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1, 1, 1), 1, 0, '%', ShapeWings.DEFAULT_ROTATION, ShapeWings.FOUR_LEAF_CLOVER); + private ShapeWings _cloverGreen = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1, 1, 1), 1, 0, '*', ShapeWings.DEFAULT_ROTATION, ShapeWings.FOUR_LEAF_CLOVER); + + public StPatricksChestAnimation(Treasure treasure, Block center) + { + super(treasure); + _center = center; + } + + @Override + protected void tick() + { + _tick++; + if (_tick % 5 == 0) + { + _cloverBlack.displayColored(_center.getLocation().add(0, 5, 0), Color.BLACK); + _cloverDarkGreen.displayColored(_center.getLocation().add(0, 5, 0), new Color(0, 100, 0)); + _cloverGreen.displayColored(_center.getLocation().add(0, 5, 0), Color.GREEN); + } + } + + @Override + protected void onFinish() + { + + } + +} 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 a97d29f14..c0ada9705 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/TreasureRemoveAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/TreasureRemoveAnimation.java @@ -3,22 +3,27 @@ package mineplex.core.treasure.animation; import java.util.List; import java.util.Random; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Item; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.treasure.BlockInfo; import mineplex.core.treasure.Treasure; +import mineplex.core.treasure.TreasureType; -/** - * Created by shaun on 14-09-15. - */ public class TreasureRemoveAnimation extends Animation { private Random _random = new Random(); - private List _openedChests; private List _otherChests; + private int _count = 0; - public TreasureRemoveAnimation(Treasure treasure, List openedChests, List otherChests) + public TreasureRemoveAnimation(Treasure treasure, List otherChests) { super(treasure); - _openedChests = openedChests; _otherChests = otherChests; } @@ -31,14 +36,13 @@ public class TreasureRemoveAnimation extends Animation { BlockInfo info = _otherChests.remove(_random.nextInt(_otherChests.size())); getTreasure().resetBlockInfo(info); -// System.out.println("otherchests"); + if (getTreasure().getTreasureType() == TreasureType.ST_PATRICKS) + { + // Drops gold nugget + dropItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_NUGGET, (byte) 0, 1, "DroppedNugget" + _count), info); + _count++; + } } -// else if (!_openedChests.isEmpty()) -// { -// System.out.println("openchests"); -// BlockInfo info = _openedChests.remove(_random.nextInt(_openedChests.size())); -// getTreasure().resetBlockInfo(info); -// } else { finish(); @@ -46,6 +50,16 @@ public class TreasureRemoveAnimation extends Animation } } + private void dropItem(ItemStack itemStack, BlockInfo blockInfo) + { + Location location = blockInfo.getBlock().getLocation(); + Item item = location.getWorld().dropItem(location.add(0, .5, 0), itemStack); + Vector vel = new Vector(Math.sin(_count * 9/5d), 0, Math.cos(_count * 9/5d)); + UtilAction.velocity(item, vel, Math.abs(Math.sin(_count * 12/3000d)), false, 0, 0.2 + + Math.abs(Math.cos(_count * 12/3000d))*0.6, 1, false); + getTreasure().getTreasureManager().addItem(item); + } + @Override protected void onFinish() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java index 771de876a..70c891f52 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/event/TreasureStartEvent.java @@ -8,20 +8,20 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import mineplex.core.reward.Reward; -import mineplex.core.treasure.TreasureType; +import mineplex.core.treasure.Treasure; public class TreasureStartEvent extends Event { private static final HandlerList handlers = new HandlerList(); private Player _player; - private TreasureType _treasureType; + private Treasure _treasure; private List _rewards; - public TreasureStartEvent(Player player, TreasureType treasureType, List rewards) + public TreasureStartEvent(Player player, Treasure treasure, List rewards) { _player = player; - _treasureType = treasureType; + _treasure = treasure; _rewards = rewards; } @@ -30,9 +30,9 @@ public class TreasureStartEvent extends Event return _player; } - public TreasureType getTreasureType() + public Treasure getTreasure() { - return _treasureType; + return _treasure; } public List getRewards() 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 ef1e9775a..087374d5d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/BuyChestButton.java @@ -98,7 +98,8 @@ public class BuyChestButton implements IButton } if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player) && (_chestType == TreasureType.ILLUMINATED || _chestType == TreasureType.OMEGA - || _chestType == TreasureType.HAUNTED || _chestType == TreasureType.GINGERBREAD)) + || _chestType == TreasureType.HAUNTED || _chestType == TreasureType.GINGERBREAD + || _chestType == TreasureType.ST_PATRICKS)) { player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!")); return; 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 4fda07f6c..ac82b4b25 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/gui/TreasurePage.java @@ -137,6 +137,7 @@ public class TreasurePage extends ShopPageBase int gingerbreadCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.GINGERBREAD.getItemName()); 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()); boolean availableChristmas = false; boolean availableFreedom = false; @@ -144,7 +145,8 @@ public class TreasurePage extends ShopPageBase boolean availableTrick = false; boolean availableThank = false; boolean availableGingerbread = false; - boolean availableLove = new File("../../update/files/EnableLoveChest.dat").exists(); + boolean availableLove = false; + boolean availableStPatricks = new File("../../update/files/EnableStPatricksChest.dat").exists(); List shardLore = new ArrayList<>(); shardLore.add(" "); @@ -407,6 +409,30 @@ public class TreasurePage extends ShopPageBase } } + List stpatricksLore = Lists.newArrayList(); + stpatricksLore.add(" "); + stpatricksLore.add(F.value("St Patrick's Chests Owned", "" + stpatricksCount)); + stpatricksLore.add(" "); + stpatricksLore.addAll(UtilText.splitLines(new String[]{C.cGray + "Happy St. Patrick's Day! Get your Pot's of Gold and Luck of the Irish in this chest! 7 items, no duplicates."}, LineFormat.LORE)); + stpatricksLore.add(" "); + if (stpatricksCount > 0) + { + stpatricksLore.add(C.cGreen + "Click to Open!"); + } + else + { + if (!availableStPatricks) + { + stpatricksLore.add(C.cRed + "This item is no longer available"); + } + else + { + stpatricksLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + TreasureType.LOVE_CHEST.getPurchasePrice() + " Treasure Shards"); + stpatricksLore.add(" "); + stpatricksLore.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 @@ -425,6 +451,7 @@ public class TreasurePage extends ShopPageBase ItemStack thank = new ShopItem(Material.COOKED_CHICKEN, C.cGoldB + "Thankful Treasure", thankLore.toArray(new String[0]), 0, false, false); 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); // Adds shard item addItem(49, shards); @@ -447,6 +474,7 @@ public class TreasurePage extends ShopPageBase TreasurePageItem thankTreasureItem = new TreasurePageItem(thank, thankCount, TreasureType.THANKFUL); 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); _normalTreasures.add(oldTreasureItem); _normalTreasures.add(ancientTreasureItem); @@ -455,6 +483,11 @@ public class TreasurePage extends ShopPageBase _normalTreasures.add(omegaTreasureItem); _normalTreasures.add(minestrikeTreasureItem); + if (availableStPatricks) + _specialTreasures.add(stPatricksItem); + else + _seasonalTreasures.add(stPatricksItem); + if (availableLove) _specialTreasures.add(loveChestItem); else diff --git a/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java b/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java index 32107d3f6..3da03286e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/twofactor/TwoFactorAuth.java @@ -192,7 +192,7 @@ public class TwoFactorAuth extends MiniClientPlugin TwoFactorData data = Get(player); - if ((data.getLastLoginIp().isPresent() && player.getAddress().getAddress().toString().substring(1).equals(data.getLastLoginIp().get())) || _clientManager.Get(player).GetRank(true) == Rank.SUPPORT) + if (data.getLastLoginIp().isPresent() && player.getAddress().getAddress().toString().substring(1).equals(data.getLastLoginIp().get())) { player.sendMessage(F.main("2FA", "Authenticated")); return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/website/ForumUserData.java b/Plugins/Mineplex.Core/src/mineplex/core/website/ForumUserData.java new file mode 100644 index 000000000..bd663e61b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/website/ForumUserData.java @@ -0,0 +1,15 @@ +package mineplex.core.website; + +public class ForumUserData +{ + public boolean Linked; + public int LinkedForumId; + public boolean LastSyncedPowerPlayStatus; + + public ForumUserData() + { + Linked = false; + LinkedForumId = -1; + LastSyncedPowerPlayStatus = false; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/website/LinkCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/website/LinkCommand.java new file mode 100644 index 000000000..74dcbe768 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/website/LinkCommand.java @@ -0,0 +1,36 @@ +package mineplex.core.website; + +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; + +public class LinkCommand extends CommandBase +{ + public LinkCommand(WebsiteLinkManager plugin) + { + super(plugin, Rank.ALL, "link"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args.length < 1) + { + //UtilPlayer.message(caller, F.help("/" + _aliasUsed + " XXX-XXX-XXX", "Begins linking your Minecraft account with your website link code.", Rank.ALL, ChatColor.GREEN)); + } + else + { + if (Plugin.Get(caller).Linked) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Your account is already linked!")); + } + else + { + Plugin.startLink(caller, args[0]); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/website/MineplexAuthenticator.java b/Plugins/Mineplex.Core/src/mineplex/core/website/MineplexAuthenticator.java new file mode 100644 index 000000000..5cd97df4d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/website/MineplexAuthenticator.java @@ -0,0 +1,28 @@ +package mineplex.core.website; + +import java.net.Authenticator; +import java.net.PasswordAuthentication; + +public class MineplexAuthenticator extends Authenticator +{ + private String _username, _password; + + public MineplexAuthenticator(String username, String password) + { + _username = username; + _password = password; + } + + @Override + public PasswordAuthentication getPasswordAuthentication() + { + System.out.println("-==Mineplex Authentication In Progress==-"); + System.out.println("Requesting Host: " + getRequestingHost()); + System.out.println("Requesting Port: " + getRequestingPort()); + System.out.println("Requesting Prompt: " + getRequestingPrompt()); + System.out.println("Requesting Protocol: " + getRequestingProtocol()); + System.out.println("Requesting Scheme: " + getRequestingScheme()); + System.out.println("Requesting Site: " + getRequestingSite()); + return new PasswordAuthentication(_username, _password.toCharArray()); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/website/UnlinkCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/website/UnlinkCommand.java new file mode 100644 index 000000000..b6060c863 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/website/UnlinkCommand.java @@ -0,0 +1,27 @@ +package mineplex.core.website; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; + +public class UnlinkCommand extends CommandBase +{ + public UnlinkCommand(WebsiteLinkManager plugin) + { + super(plugin, Rank.ADMIN, "unlink"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args.length < 1) + { + //UtilPlayer.message(caller, F.help("/" + _aliasUsed + " ", "Removes a link to a forum and in-game account.", Rank.ADMIN, ChatColor.RED)); + } + else + { + Plugin.unlink(caller, args[0]); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java b/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java new file mode 100644 index 000000000..3ab0e1637 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/website/WebsiteLinkManager.java @@ -0,0 +1,834 @@ +package mineplex.core.website; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.Authenticator; +import java.net.MalformedURLException; +import java.net.URL; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.TimeZone; +import java.util.UUID; +import java.util.function.BiConsumer; +import java.util.function.Consumer; + +import org.apache.commons.lang.StringUtils; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; + +import mineplex.core.MiniDbClientPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.account.event.RankSaveEvent; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.powerplayclub.PPCDataRequestEvent; +import mineplex.core.powerplayclub.PowerPlayData; +import mineplex.core.powerplayclub.SubscriptionAddEvent; +import mineplex.serverdata.database.DBPool; + +public class WebsiteLinkManager extends MiniDbClientPlugin +{ + private final JsonParser PARSER = new JsonParser(); + private final String API_URL = "https://xen.mineplex.com/api.php"; + private final String API_KEY = "dd412425-edb0-477c-abee-2d0b507c59ef"; + private final int POWER_PLAY_TAG_ID = 17; + private final int LINKED_TAG_ID = 91; + + public WebsiteLinkManager(JavaPlugin plugin, CoreClientManager clientManager) + { + super("Website Link", plugin, clientManager); + + addCommand(new LinkCommand(this)); + addCommand(new UnlinkCommand(this)); + + Authenticator.setDefault(new MineplexAuthenticator("minexen", "c4cADuj&ChaQ")); + } + + public void unlink(Player sender, String target) + { + getClientManager().getOrLoadClient(target, client -> + { + if (client != null) + { + Consumer dataCallback = data -> + { + if (data == null) + { + UtilPlayer.message(sender, F.main(getName(), "Could not find " + F.name(target) + "!")); + } + else + { + if (!data.Linked) + { + UtilPlayer.message(sender, F.main(getName(), F.name(target) + " is not linked to a forum account!")); + } + else + { + runAsync(() -> + { + loadXenforoAccount(data.LinkedForumId, user -> + { + List remove = new ArrayList<>(); + remove.add(POWER_PLAY_TAG_ID); + remove.add(LINKED_TAG_ID); + for (Rank rank : Rank.values()) + { + if (rank.getForumId() != -1) + { + remove.add(rank.getForumId()); + } + } + String call = "action=editUser&user=" + user.username + "&custom_fields=mcAcctIdPC="; + doAPICall(call, err -> + { + runSync(() -> UtilPlayer.message(sender, F.main(getName(), F.name(target) + " was not able to be unlinked at this time!"))); + }, () -> + { + runSync(() -> UtilPlayer.message(sender, F.main(getName(), F.name(target) + " was not able to be unlinked at this time!"))); + }, () -> + { + refreshSiteTags(data.LinkedForumId, remove, new ArrayList<>(), false, () -> + { + try (Connection c = DBPool.getAccount().getConnection()) + { + c.prepareStatement("DELETE FROM forumLink WHERE accountId=" + client.getAccountId()).execute(); + runSync(() -> + { + UtilPlayer.message(sender, F.main(getName(), F.name(target) + " was successfully unlinked!")); + data.Linked = false; + data.LinkedForumId = -1; + data.LastSyncedPowerPlayStatus = false; + }); + } + catch (SQLException e) + { + e.printStackTrace(); + runSync(() -> UtilPlayer.message(sender, F.main(getName(), F.name(target) + " was not able to be unlinked at this time!"))); + } + }, false, () -> UtilPlayer.message(sender, F.main(getName(), F.name(target) + " was not able to be unlinked at this time!")), true); + }); + }); + }); + } + } + }; + if (Bukkit.getPlayer(client.getUniqueId()) != null) + { + dataCallback.accept(Get(client.getUniqueId())); + } + else + { + runAsync(() -> + { + try (Connection c = DBPool.getAccount().getConnection()) + { + ResultSet rs = c.prepareStatement("SELECT userId, powerPlayStatus FROM forumLink WHERE accountId=" + client.getAccountId() + ";").executeQuery(); + if (rs.next()) + { + Integer userId = rs.getInt(1); + Boolean powerPlay = rs.getBoolean(2); + final ForumUserData data = new ForumUserData(); + data.Linked = true; + data.LinkedForumId = userId; + data.LastSyncedPowerPlayStatus = powerPlay; + runSync(() -> dataCallback.accept(data)); + } + else + { + runSync(() -> dataCallback.accept(new ForumUserData())); + } + } + catch (SQLException e) + { + e.printStackTrace(); + runSync(() -> dataCallback.accept(new ForumUserData())); + } + }); + } + } + else + { + UtilPlayer.message(sender, F.main(getName(), "Could not find " + F.name(target) + "!")); + } + }); + } + + public void startLink(Player player, String code) + { + final int forumId = getForumId(code); + final int accountId = getClientManager().getAccountId(player); + final Rank rank = getClientManager().Get(player).GetRank(true); + PowerPlayData d = UtilServer.CallEvent(new PPCDataRequestEvent(player)).getData(); + final boolean powerPlay = (d != null && d.isSubscribed()); + if (forumId == -1) + { + UtilPlayer.message(player, F.main(getName(), "That link code is invalid!")); + return; + } + runAsync(() -> + { + loadXenforoAccount(forumId, data -> + { + if (data == null) + { + UtilPlayer.message(player, F.main(getName(), "That link code is invalid!")); + return; + } + if (data.custom_fields.containsKey("mcAcctIdPC") && !data.custom_fields.get("mcAcctIdPC").isEmpty()) + { + UtilPlayer.message(player, F.main(getName(), "That link code is invalid!")); + return; + } + completeLink(player, data, accountId, rank, powerPlay); + }); + }); + } + + private void completeLink(Player player, XenForoData data, int accountId, Rank rank, boolean powerPlay) + { + try (Connection c = DBPool.getAccount().getConnection()) + { + boolean success = c.prepareStatement("INSERT INTO forumLink (accountId, userId, powerPlayStatus) VALUES (" + accountId + ", " + data.user_id + ", " + powerPlay + ");").executeUpdate() > 0; + if (success) + { + String call = "action=editUser&user=" + data.username + "&custom_fields=mcAcctIdPC=" + accountId; + List adding = new ArrayList<>(); + adding.add(91); + if (rank.getForumId() != -1) + { + adding.add(rank.getForumId()); + } + if (powerPlay) + { + adding.add(POWER_PLAY_TAG_ID); + } + doAPICall(call, err -> + { + runSync(() -> UtilPlayer.message(player, F.main(getName(), "The link failed! Please try again!"))); + }, () -> + { + runSync(() -> UtilPlayer.message(player, F.main(getName(), "The link failed! Please try again!"))); + }, () -> + { + refreshSiteTags(data, new ArrayList<>(), adding, false, () -> + { + UtilPlayer.message(player, F.main(getName(), "You have successfully linked your account!")); + if (player.isOnline()) + { + Get(player).LinkedForumId = data.user_id; + Get(player).LastSyncedPowerPlayStatus = powerPlay; + Get(player).Linked = true; + } + }, true, () -> UtilPlayer.message(player, F.main(getName(), "The link failed! Please try again!")), true); + }); + } + else + { + runSync(() -> UtilPlayer.message(player, F.main(getName(), "The link failed! Please try again!"))); + } + } + catch (SQLException e) + { + runSync(() -> UtilPlayer.message(player, F.main(getName(), "The link failed! Please try again!"))); + e.printStackTrace(); + } + } + + private void refreshSiteTags(int userId, List removing, List adding, boolean runAsync, Runnable after, boolean runAfterSync, Runnable onErr, boolean runErrSync) + { + Runnable r = () -> + { + loadXenforoAccount(userId, data -> + { + refreshSiteTags(data, removing, adding, false, after, runAfterSync, onErr, runErrSync); + }); + }; + + if (runAsync) + { + runAsync(r); + } + else + { + r.run(); + } + } + + private void refreshSiteTags(XenForoData data, List removing, List adding, boolean runAsync, Runnable after, boolean runAfterSync, Runnable onErr, boolean runErrSync) + { + Runnable r = () -> + { + if (data == null) + { + return; + } + String callBase = "action=editUser&user=" + data.username; + String groups = ""; + for (int groupId : data.secondary_group_ids) + { + if (!removing.contains(groupId) && !adding.contains(groupId)) + { + groups += ("," + groupId); + } + } + for (Integer groupId : adding) + { + groups += ("," + groupId); + } + if (!groups.isEmpty()) + { + groups = groups.substring(1); + } + final String addGroups = groups; + groups = ""; + for (int groupId : data.secondary_group_ids) + { + groups += ("," + groupId); + } + if (!groups.isEmpty()) + { + groups = groups.substring(1); + } + final String remGroups = groups; + if (!remGroups.isEmpty()) + { + doAPICall(callBase + "&remove_groups=" + remGroups, err -> + { + if (runErrSync) + { + runSync(onErr); + } + else + { + onErr.run(); + } + }, () -> + { + if (runErrSync) + { + runSync(onErr); + } + else + { + onErr.run(); + } + }, () -> + { + if (!addGroups.isEmpty()) + { + doAPICall(callBase + "&add_groups=" + addGroups, err -> + { + if (runErrSync) + { + runSync(onErr); + } + else + { + onErr.run(); + } + }, () -> + { + if (runErrSync) + { + runSync(onErr); + } + else + { + onErr.run(); + } + }, () -> + { + if (runAfterSync) + { + runSync(after); + } + else + { + after.run(); + } + }); + } + else + { + if (runAfterSync) + { + runSync(after); + } + else + { + after.run(); + } + } + }); + } + else + { + if (!addGroups.isEmpty()) + { + doAPICall(callBase + "&add_groups=" + addGroups, err -> + { + if (runErrSync) + { + runSync(onErr); + } + else + { + onErr.run(); + } + }, () -> + { + if (runErrSync) + { + runSync(onErr); + } + else + { + onErr.run(); + } + }, () -> + { + if (runAfterSync) + { + runSync(after); + } + else + { + after.run(); + } + }); + } + else + { + if (runAfterSync) + { + runSync(after); + } + else + { + after.run(); + } + } + } + }; + + if (runAsync) + { + runAsync(r); + } + else + { + r.run(); + } + } + + private void loadXenforoAccount(int userId, Consumer callback) + { + try + { + StringBuilder result = new StringBuilder(); + URL call = new URL(API_URL + "?hash=" + API_KEY + "&action=getUser&value=" + userId); + BufferedReader br = new BufferedReader(new InputStreamReader(call.openStream())); + br.lines().forEach(line -> result.append(line)); + + String json = result.toString().trim(); + + JsonObject response = null; + try + { + response = PARSER.parse(json).getAsJsonObject(); + if (response.has("error")) + { + callback.accept(null); + } + else + { + XenForoData data = new XenForoData(); + data.user_id = response.get("user_id").getAsInt(); + data.username = response.get("username").getAsString(); + data.email = response.get("email").getAsString(); + data.user_group_id = response.get("user_group_id").getAsInt(); + String groups = response.get("secondary_group_ids").getAsString(); + if (groups.isEmpty()) + { + data.secondary_group_ids = new int[] {}; + } + else + { + String[] groupIds = groups.split(","); + data.secondary_group_ids = new int[groupIds.length]; + for (int index = 0; index < groupIds.length; index++) + { + data.secondary_group_ids[index] = Integer.parseInt(groupIds[index]); + } + } + Map fields = new HashMap<>(); + if (response.get("custom_fields") instanceof JsonObject) + { + JsonObject cFields = (JsonObject) response.get("custom_fields"); + for (Entry entry : cFields.entrySet()) + { + fields.put(entry.getKey(), entry.getValue().getAsString()); + } + } + data.custom_fields = fields; + callback.accept(data); + } + } + catch (JsonSyntaxException e) + { + callback.accept(null); + e.printStackTrace(); + return; + } + } + catch (MalformedURLException e) + { + callback.accept(null); + e.printStackTrace(); + } + catch (IOException e) + { + callback.accept(null); + e.printStackTrace(); + } + } + + private void doAPICall(String call, Consumer errorCallback, Runnable ioException, Runnable onComplete) + { + StringBuilder input = new StringBuilder(); + + try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(API_URL + "?hash=" + API_KEY + "&" + call).openStream()))) + { + reader.lines().forEach(l -> input.append(l)); + } + catch (IOException e) + { + System.out.println("[XENFORO API] Could not connect to web server"); + e.printStackTrace(); + ioException.run(); + return; + } + + JsonObject response = null; + try + { + response = PARSER.parse(input.toString().trim()).getAsJsonObject(); + } + catch (JsonSyntaxException e) + { + System.out.println("[XENFORO API] Could not parse JSON response data"); + e.printStackTrace(); + return; + } + + if (response.has("error")) + { + if (response.get("error").getAsString().equals("7")) + { + if (response.has("user_error_id")) + { + String errorID = response.get("user_error_id").getAsString(); + + errorCallback.accept(errorID); + System.out.println("[XENFORO API] An error was found in the JSON response (id: " + errorID + ") from REST call: " + call); + return; + } + else + { + System.out.println("[XENFORO API] An error was found in the JSON response, but no error code was found from REST call: " + call); + } + } + else + { + System.out.println("[XENFORO API] A non-user error was found in the JSON response (id: " + response.get("error").getAsString() + ") from REST call: " + call); + return; + } + } + else + { + onComplete.run(); + } + } + + private int getForumId(String linkCode) + { + String given = linkCode.replace("-", ""); + if (given.length() < 9) + { + return -1; + } + if (!StringUtils.isNumeric(given)) + { + return -1; + } + + Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); + int offset = 100000000; + StringBuilder sb = new StringBuilder(cal.get(Calendar.DAY_OF_YEAR) + ""); + while (sb.length() < 3) + { + sb.insert(0, "0"); + } + String reverse = sb.reverse().toString(); + Integer test = Integer.parseInt(reverse + reverse + reverse); + test += offset; + + Integer input = Integer.parseInt(given); + + Integer abs = Math.abs(test - input); + +// Bukkit.broadcastMessage("REVERSE: " + reverse); +// Bukkit.broadcastMessage("TEST: " + test); +// Bukkit.broadcastMessage("INPUT: " + input); +// Bukkit.broadcastMessage("ABS: " + abs); +// Bukkit.broadcastMessage("MODULUS: " + abs % 11); + + if (abs % 11 != 0) + { + return -1; + } + + return abs / 11; + } + + private void checkAccountOnline(int accountId, BiConsumer consumer) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + if (getClientManager().getAccountId(player) == accountId) + { + consumer.accept(true, player.getUniqueId()); + return; + } + } + + consumer.accept(false, null); + } + + @EventHandler + public void handleRankSave(RankSaveEvent event) + { + Consumer dataCallback = id -> + { + List remove = new ArrayList<>(); + List add = new ArrayList<>(); + for (Rank rank : Rank.values()) + { + if (rank.getForumId() != -1 && rank != event.getRank()) + { + remove.add(rank.getForumId()); + } + } + if (event.getRank().getForumId() != -1) + { + add.add(event.getRank().getForumId()); + } + refreshSiteTags(id, remove, add, false, () -> {}, false, () -> {}, false); + }; + if (Bukkit.getPlayer(event.getUUID()) != null) + { + ForumUserData fd = Get(event.getUUID()); + if (fd.Linked) + { + final int userId = fd.LinkedForumId; + runAsync(() -> + { + dataCallback.accept(userId); + }); + } + } + else + { + runAsync(() -> + { + getClientManager().getRepository().getAccountId(event.getUUID(), accountId -> + { + runAsync(() -> + { + try (Connection c = DBPool.getAccount().getConnection()) + { + ResultSet rs = c.prepareStatement("SELECT userId FROM forumLink WHERE accountId=" + accountId + ";").executeQuery(); + if (rs.next()) + { + Integer userId = rs.getInt(1); + dataCallback.accept(userId); + } + } + catch (SQLException e) + { + e.printStackTrace(); + } + }); + }); + }); + } + } + + @EventHandler + public void handleSubscriptionAdd(SubscriptionAddEvent event) + { + checkAccountOnline(event.getAccountId(), (online, uuid) -> + { + if (online) + { + ForumUserData fd = Get(uuid); + if (fd.Linked && !fd.LastSyncedPowerPlayStatus) + { + final int userId = fd.LinkedForumId; + runAsync(() -> + { + List add = new ArrayList<>(); + add.add(POWER_PLAY_TAG_ID); + refreshSiteTags(userId, new ArrayList<>(), add, false, () -> + { + runSync(() -> + { + fd.LastSyncedPowerPlayStatus = true; + }); + try (Connection c = DBPool.getAccount().getConnection()) + { + c.prepareStatement("UPDATE forumLink SET powerPlayStatus=true WHERE accountId=" + event.getAccountId() + ";").execute(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + }, false, () -> {}, false); + }); + } + } + else + { + runAsync(() -> + { + try (Connection c = DBPool.getAccount().getConnection()) + { + ResultSet rs = c.prepareStatement("SELECT userId FROM forumLink WHERE accountId=" + event.getAccountId() + ";").executeQuery(); + if (rs.next()) + { + Integer userId = rs.getInt(1); + List add = new ArrayList<>(); + add.add(17); + refreshSiteTags(userId, new ArrayList<>(), add, false, () -> + { + try + { + c.prepareStatement("UPDATE forumLink SET powerPlayStatus=true WHERE accountId=" + event.getAccountId() + ";").execute(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + }, false, () -> {}, false); + } + } + catch (SQLException e) + { + e.printStackTrace(); + } + }); + } + }); + } + + @EventHandler + public void updatePPCTag(PlayerJoinEvent event) + { + runSyncLater(() -> + { + if (event.getPlayer().isOnline()) + { + boolean ppc = false; + PowerPlayData d = UtilServer.CallEvent(new PPCDataRequestEvent(event.getPlayer())).getData(); + if (d != null) + { + ppc = d.isSubscribed(); + final boolean powerPlay = ppc; + if (Get(event.getPlayer()).Linked && Get(event.getPlayer()).LastSyncedPowerPlayStatus != powerPlay) + { + final int userId = Get(event.getPlayer()).LinkedForumId; + final int accountId = getClientManager().getAccountId(event.getPlayer()); + runAsync(() -> + { + List remove = new ArrayList<>(); + List add = new ArrayList<>(); + if (powerPlay) + { + add.add(POWER_PLAY_TAG_ID); + } + else + { + remove.add(POWER_PLAY_TAG_ID); + } + refreshSiteTags(userId, remove, add, false, () -> + { + runSync(() -> + { + if (event.getPlayer().isOnline()) + { + Get(event.getPlayer()).LastSyncedPowerPlayStatus = powerPlay; + } + }); + try (Connection c = DBPool.getAccount().getConnection()) + { + c.prepareStatement("UPDATE forumLink SET powerPlayStatus=" + powerPlay + " WHERE accountId=" + accountId + ";").execute(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + }, false, () -> {}, false); + }); + } + } + } + }, 40L); + } + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT userId, powerPlayStatus FROM forumLink WHERE accountId=" + accountId + ";"; + } + + @Override + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException + { + if (resultSet.next()) + { + ForumUserData data = new ForumUserData(); + data.Linked = true; + data.LinkedForumId = resultSet.getInt(1); + data.LastSyncedPowerPlayStatus = resultSet.getBoolean(2); + Set(uuid, data); + } + else + { + Set(uuid, new ForumUserData()); + } + } + + @Override + protected ForumUserData addPlayer(UUID uuid) + { + return new ForumUserData(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/website/XenForoData.java b/Plugins/Mineplex.Core/src/mineplex/core/website/XenForoData.java new file mode 100644 index 000000000..cb5901982 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/website/XenForoData.java @@ -0,0 +1,13 @@ +package mineplex.core.website; + +import java.util.Map; + +public class XenForoData +{ + public int user_id; + public String username; + public String email; + public int user_group_id; + public int[] secondary_group_ids; + public Map custom_fields; +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 8df0e0df1..8bddf656b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -1,5 +1,6 @@ package mineplex.game.clans; +import mineplex.core.aprilfools.AprilFoolsManager; import net.minecraft.server.v1_8_R3.MinecraftServer; import org.bukkit.Bukkit; @@ -265,6 +266,8 @@ public class Clans extends JavaPlugin require(TwoFactorAuth.class); + AprilFoolsManager.getInstance(); + // Disable spigot item merging for (World world : getServer().getWorlds()) { diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java index e44061aad..e0997337b 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/ClansHub.java @@ -60,6 +60,7 @@ import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.velocity.VelocityFix; import mineplex.core.visibility.VisibilityManager; +import mineplex.core.website.WebsiteLinkManager; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; @@ -165,7 +166,7 @@ public class ClansHub extends JavaPlugin new ResourcePackManager(this, portal); new GlobalPacketManager(this, clientManager, serverStatusManager, inventoryManager, donationManager, petManager, statsManager, hubManager.getBonusManager().getRewardManager()); - AprilFoolsManager.Initialize(this, clientManager, disguiseManager); + AprilFoolsManager.getInstance(); new EternalGiveawayManager(this, clientManager, serverStatusManager); @@ -181,6 +182,7 @@ public class ClansHub extends JavaPlugin require(TrackManager.class); require(Titles.class); require(TwoFactorAuth.class); + new WebsiteLinkManager(this, clientManager); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index c4f8cdec8..c21256ce4 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -1,5 +1,8 @@ package mineplex.hub; +import static mineplex.core.Managers.require; + +import mineplex.hub.modules.AprilFoolsTreasureHunt; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -64,6 +67,7 @@ import mineplex.core.sponsorbranding.BrandingManager; import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; +import mineplex.core.teamspeak.TeamspeakManager; import mineplex.core.teleport.Teleport; import mineplex.core.thank.ThankManager; import mineplex.core.titles.Titles; @@ -73,6 +77,7 @@ import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.velocity.VelocityFix; import mineplex.core.visibility.VisibilityManager; +import mineplex.core.website.WebsiteLinkManager; import mineplex.hub.modules.BillboardManager; import mineplex.hub.queue.QueueManager; import mineplex.hub.server.ServerManager; @@ -87,8 +92,6 @@ import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.fire.Fire; -import static mineplex.core.Managers.require; - public class Hub extends JavaPlugin implements IRelation { private NpcManager _npcManager; @@ -115,7 +118,8 @@ public class Hub extends JavaPlugin implements IRelation // new ProfileCacheManager(this); ItemStackFactory.Initialize(this, false); Recharge.Initialize(this); - VisibilityManager.Initialize(this); Give.Initialize(this); + VisibilityManager.Initialize(this); + Give.Initialize(this); Punish punish = new Punish(this, clientManager); BlockRestore blockRestore = require(BlockRestore.class); DonationManager donationManager = require(DonationManager.class); @@ -130,9 +134,9 @@ public class Hub extends JavaPlugin implements IRelation DisguiseManager disguiseManager = require(DisguiseManager.class); IncognitoManager incognito = new IncognitoManager(this, clientManager, packetHandler); PreferencesManager preferenceManager = new PreferencesManager(this, incognito, clientManager); - + incognito.setPreferencesManager(preferenceManager); - + preferenceManager.GiveItem = true; Creature creature = new Creature(this); NpcManager npcManager = new NpcManager(this, creature); @@ -143,7 +147,7 @@ public class Hub extends JavaPlugin implements IRelation //new TournamentManager(this, clientManager, donationManager); ProjectileManager throwManager = new ProjectileManager(this); - + //Main Modules new TitanGiveawayManager(this, clientManager, serverStatusManager); @@ -157,9 +161,9 @@ public class Hub extends JavaPlugin implements IRelation guardianManager.registerGuardian(new AntiHackGuardian(new Location(Bukkit.getWorld("world"), 0, 100, 0), 50, -50, 105, 95, 50, -50)); } - IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal); + IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal); - FriendManager friendManager = new FriendManager(this, clientManager, preferenceManager, portal); + FriendManager friendManager = new FriendManager(this, clientManager, preferenceManager, portal); StatsManager statsManager = new StatsManager(this, clientManager); EloManager eloManager = new EloManager(this, clientManager); @@ -197,17 +201,14 @@ public class Hub extends JavaPlugin implements IRelation new SnapshotPlugin(this, snapshotManager, clientManager); new ReportPlugin(this, reportManager); - AprilFoolsManager.Initialize(this, clientManager, disguiseManager); - new EternalGiveawayManager(this, clientManager, serverStatusManager); CombatManager combatManager = new CombatManager(this); - DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, conditionManager); conditionManager.setDamageManager(damage); - + Fire fire = new Fire(this, conditionManager, damage); Teleport teleport = new Teleport(this, clientManager); Energy energy = new Energy(this); @@ -216,14 +217,14 @@ public class Hub extends JavaPlugin implements IRelation ItemFactory itemFactory = new ItemFactory(this, blockRestore, conditionManager, damage, energy, fire, throwManager); SkillFactory skillManager = new SkillFactory(this, damage, this, combatManager, conditionManager, throwManager, disguiseManager, blockRestore, fire, new Movement(this), teleport, energy); ClassManager classManager = new ClassManager(this, clientManager, donationManager, hubManager.GetGadget(), skillManager, itemFactory); - - ClassShopManager shopManager = new ClassShopManager(this, classManager, skillManager, itemFactory, achievementManager, clientManager); - - new ClassCombatShop(shopManager, clientManager, donationManager, false, "Brute", classManager.GetClass("Brute"), true); - new ClassCombatShop(shopManager, clientManager, donationManager, false, "Mage", classManager.GetClass("Mage"), true); - new ClassCombatShop(shopManager, clientManager, donationManager, false, "Ranger", classManager.GetClass("Ranger"), true); - new ClassCombatShop(shopManager, clientManager, donationManager, false, "Knight", classManager.GetClass("Knight"), true); - new ClassCombatShop(shopManager, clientManager, donationManager, false, "Assassin", classManager.GetClass("Assassin"), true); + + ClassShopManager shopManager = new ClassShopManager(this, classManager, skillManager, itemFactory, achievementManager, clientManager); + + new ClassCombatShop(shopManager, clientManager, donationManager, false, "Brute", classManager.GetClass("Brute"), true); + new ClassCombatShop(shopManager, clientManager, donationManager, false, "Mage", classManager.GetClass("Mage"), true); + new ClassCombatShop(shopManager, clientManager, donationManager, false, "Ranger", classManager.GetClass("Ranger"), true); + new ClassCombatShop(shopManager, clientManager, donationManager, false, "Knight", classManager.GetClass("Knight"), true); + new ClassCombatShop(shopManager, clientManager, donationManager, false, "Assassin", classManager.GetClass("Assassin"), true); //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); @@ -234,6 +235,13 @@ public class Hub extends JavaPlugin implements IRelation require(TrackManager.class); require(Titles.class); require(TwoFactorAuth.class); + require(TeamspeakManager.class); + new WebsiteLinkManager(this, clientManager); + + if (AprilFoolsManager.getInstance().isEnabled()) + { + require(AprilFoolsTreasureHunt.class); + } } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 8ac9b1e7c..c01ec5d2b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -610,11 +610,6 @@ public class HubManager extends MiniClientPlugin implements IChatMess Player player = event.getPlayer(); String playerName = player.getName(); - - // April Fools - if (AprilFoolsManager.Instance.isActive()) - playerName = AprilFoolsManager.Instance.getName(player); - Rank rank = GetClients().Get(player).getRealOrDisguisedRank(); //Level Prefix diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AprilFoolsTreasureHunt.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AprilFoolsTreasureHunt.java new file mode 100644 index 000000000..0a8cc9bd2 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/AprilFoolsTreasureHunt.java @@ -0,0 +1,284 @@ +package mineplex.hub.modules; + +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.aprilfools.AprilFoolsManager; +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.donation.DonationManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.titles.tracks.Track; +import mineplex.core.titles.tracks.TrackManager; +import mineplex.core.titles.tracks.award.AprilFools2017Track; +import org.bukkit.*; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.Skull; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; + +import java.util.*; + +@ReflectivelyCreateMiniPlugin +public class AprilFoolsTreasureHunt extends MiniPlugin +{ + + private static final int SHARD_REWARD = 500; + private static final String ITEM_REWARD = "Omega Chest"; + + private static final int[][] TREASURE = { + { + 0, 72, -10 + }, + { + -56, 71, -42 + }, + { + 171, 69, -67 + }, + { + 287, 71, -197 + }, + { + 306, 123, -182 + }, + { + 99, 68, -143 + }, + { + 122, 70, -27 + }, + { + 106, 86, 54 + }, + { + 48, 71, 71 + }, + { + 54, 64, 112 + }, + { + 45, 117, 113 + }, + { + 77, 93, 210 + }, + { + -13, 65, 128 + }, + { + -22, 65, 110 + }, + { + -115, 67, 54 + }, + { + -91, 56, 46 + }, + { + -14, 29, -10 + }, + { + 13, 39, 36 + }, + { + 99, 48, 49 + }, + { + -101, 70, 196 + }, + { + 29, 111, 39 + }, + { + 36, 60, -19 + }, + { + -65, 70, -111 + }, + { + -88, 55, -77 + }, + { + -4, 73, -37 + }, + { + 120, 68, -20 + }, + { + 119, 79, 9 + }, + { + 213, 64, -111 + }, + { + 228, 63, -155 + }, + { + 34, 84, -5 + } + }; + 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 final AprilFoolsManager _aprilFools; + private final CoreClientManager _client; + private final DonationManager _donation; + private final InventoryManager _inventory; + private final TrackManager _track; + + private final Map> _foundTreasure; + private final List _treasure; + private boolean _set; + + private AprilFoolsTreasureHunt() + { + super("Treasure Hunt"); + + _aprilFools = require(AprilFoolsManager.class); + _client = require(CoreClientManager.class); + _donation = require(DonationManager.class); + _inventory = require(InventoryManager.class); + _track = require(TrackManager.class); + + _foundTreasure = new HashMap<>(); + _treasure = new ArrayList<>(TREASURE.length); + } + + @EventHandler + public void playerJoin(PlayerJoinEvent event) + { + UUID key = event.getPlayer().getUniqueId(); + + _foundTreasure.put(key, new ArrayList<>(TREASURE.length)); + + runAsync(() -> _aprilFools.getRepository().getTreasure(data -> _foundTreasure.put(key, data), _client.Get(key))); + + if (!_set) + { + _set = true; + World world = Bukkit.getWorld("world"); + + for (int[] cords : TREASURE) + { + Location location = new Location(world, cords[0], cords[1], cords[2]); + Block block = location.getBlock(); + block.setType(Material.SKULL); + block.setData((byte) 1); + Skull skull = (Skull) block.getState(); + skull.setSkullType(SkullType.PLAYER); + skull.setOwner("Topplemop"); + skull.setRotation(BLOCK_FACES[UtilMath.r(BLOCK_FACES.length)]); + skull.update(); + + _treasure.add(location); + } + + Location information = _treasure.get(0).clone(); + ArmorStand hologram = information.getWorld().spawn(information.add(.5, .5, .5), ArmorStand.class); + + hologram.setSmall(true); + hologram.setGravity(false); + hologram.setVisible(false); + hologram.setCustomNameVisible(true); + hologram.setCustomName(C.cDPurple + C.Scramble + "ABC " + C.cPurpleB + "April Fools Treasure Hunt" + C.cDPurple + C.Scramble + " ABC"); + hologram.setRemoveWhenFarAway(false); + } + } + + @EventHandler + public void interactBlock(PlayerInteractEvent event) + { + if (event.getClickedBlock() == null) + { + return; + } + + Player player = event.getPlayer(); + UUID key = event.getPlayer().getUniqueId(); + List found = _foundTreasure.get(key); + Location location = event.getClickedBlock().getLocation(); + int i = 0; + + for (Location treasure : _treasure) + { + if (location.equals(treasure)) + { + findChest(player, i); + break; + } + + i++; + } + } + + private void findChest(Player player, int treasureId) + { + List found = _foundTreasure.get(player.getUniqueId()); + + if (found.contains(treasureId)) + { + player.sendMessage(F.main(_moduleName, "You already have found this skull! You have found " + F.count(String.valueOf(found.size())) + "/" + F.count(String.valueOf(_treasure.size())) + ".")); + return; + } + + found.add(treasureId); + player.playSound(player.getLocation(), Sound.CAT_MEOW, 1, 0.7F); + player.sendMessage(F.main(_moduleName, "Found " + F.count(String.valueOf(found.size())) + "/" + F.count(String.valueOf(_treasure.size()))) + " Treasure Chests +" + F.currency(GlobalCurrency.TREASURE_SHARD, SHARD_REWARD) + "."); + _donation.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, player, "", SHARD_REWARD); + + runAsync(() -> _aprilFools.getRepository().saveTreasure(_client.Get(player.getUniqueId()), treasureId)); + + if (found.size() == 1) + { + player.sendMessage(F.main(_moduleName, "There are " + F.count("30") + " secret " + F.elem("Pirate Heads") + " to find through the lobby.")); + player.sendMessage(F.main(_moduleName, "Each one is worth " + F.currency(GlobalCurrency.TREASURE_SHARD, SHARD_REWARD) + ".")); + player.sendMessage(F.main(_moduleName, "If you find all " + F.count("30") + " you will receive an " + C.cAqua + "Omega Chest" + C.mBody + " and an exclusive " + F.elem("Title") + "!")); + } + else if (found.size() == TREASURE.length) + { + player.sendMessage(F.main(_moduleName, "Completed the " + F.name("Mineplex April Fools 2017 Treasure Hunt") + ".")); + + _inventory.addItemToInventory(data -> + { + if (data) + { + player.sendMessage(F.main(_moduleName, "+1 " + C.cAqua + ITEM_REWARD + C.mBody + "!")); + } + else + { + player.sendMessage(F.main(_moduleName, "Oops, somehow I could not give you the chest, you should inform a staff member!")); + } + }, player, ITEM_REWARD, 1); + + Track track = _track.getTrack(AprilFools2017Track.class); + + _track.unlockTrack(player, track, result -> + { + switch (result) + { + case UNKNOWN_ERROR: + player.sendMessage(F.main(_moduleName, "Oops, somehow I could not give you the title track, you should inform a staff member!")); + break; + case SUCCESS: + player.sendMessage(F.main(_moduleName, "Unlocked " + track.getColor() + track.getLongName() + C.mBody + " Title!")); + break; + } + }); + } + } +} 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 f4ccf801a..33c41236a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -115,7 +115,7 @@ public class ServerGameMenu extends ShopPageBase C.Reset + "", C.Reset + "One team must steal the other", C.Reset + "team's flag. Capture it", - C.Reset + "three times to win.", + C.Reset + "five times to win.", }, new String[] {"CTF"}, "CTF", new SelectCTFButton(this)); add(20, Material.BEACON, C.cYellowB + "Dominate " + C.cGray + "Team Game", new String[] 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 735066e80..107f9fb16 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java @@ -33,6 +33,9 @@ public class ServerNpcShop extends ShopBase case "MS": return new MinestrikeServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player, _serverGroup); + case "UHC": + return new UHCServerTypePage(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/UHCServerTypePage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/UHCServerTypePage.java new file mode 100644 index 000000000..76cc3595b --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/UHCServerTypePage.java @@ -0,0 +1,66 @@ +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 UHCServerTypePage extends ShopPageBase + +{ + public UHCServerTypePage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, + DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Ultra Hardcore", player, 27); + + buildPage(); + } + + @Override + protected void buildPage() + { + setItem(10, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.Reset + C.cYellow + "UHC Solo") + .addLore(new String[] + { + C.Reset + "", + C.Reset + C.cGreen + "Click to Play", + }).build()); + + setItem(12, new ItemBuilder(Material.SKULL_ITEM, 2, (byte) 3).setTitle(C.Reset + C.cYellow + "UHC Teams") + .addLore(new String[] + { + C.Reset + "", + C.Reset + C.cGreen + "Click to Play", + }).build()); + + setItem(14, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.Reset + C.cYellow + "UHC Speed Solo") + .addLore(new String[] + { + C.Reset + "", + C.Reset + C.cGreen + "Click to Play" + }).build()); + + setItem(16, new ItemBuilder(Material.SKULL_ITEM, 2, (byte) 3).setTitle(C.Reset + C.cYellow + "UHC Speed Teams") + .addLore(new String[] + { + C.Reset + "", + C.Reset + C.cGreen + "Click to Play" + }).build()); + + getButtonMap().put(10, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "UHC Solo", player, "UHC2"))); + getButtonMap().put(12, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "UHC", player, "UHC"))); + getButtonMap().put(14, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "UHC Speed Solo", player, "UHCS2"))); + getButtonMap().put(16, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "UHC Speed", player, "UHCS"))); + } + + public void Update() + { + getButtonMap().clear(); + buildPage(); + } +} diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java index 5bc34de18..b3b28d303 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java @@ -52,13 +52,14 @@ public enum GameType Runner("Runner"), SearchAndDestroy("Search and Destroy"), Sheep("Sheep Quest"), + Skyfall("Skyfall"), Skywars("Skywars"), Smash("Super Smash Mobs"), SmashTeams("Super Smash Mobs Teams", "Super Smash Mobs"), SmashDomination("Super Smash Mobs Domination", "Super Smash Mobs"), Snake("Snake"), SneakyAssassins("Sneaky Assassins"), - SpeedBuilders("SpeedBuilders"), + SpeedBuilders("Speed Builders"), SnowFight("Snow Fight"), Spleef("Super Spleef"), SpleefTeams("Super Spleef Teams"), diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java index bd50cddd3..c74556fae 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java @@ -56,7 +56,7 @@ public class Blink extends SkillActive "", "Using again within 5 seconds De-Blinks,", "returning you to your original location.", - "Can be used while Slowed." + "Cannot be used while Slowed." }); } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Inferno.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Inferno.java index 2c07078cb..0745f87ee 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Inferno.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/Inferno.java @@ -69,7 +69,7 @@ public class Inferno extends SkillActive } @Override - public void Skill(Player player, int level) + public void Skill(Player player, int level) { _active.add(player); } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/RopedArrow.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/RopedArrow.java index 8b6f4e2bc..a15cdc08a 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/RopedArrow.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/RopedArrow.java @@ -49,7 +49,7 @@ public class RopedArrow extends SkillActive { "Prepare a roped arrow;", "Your next arrow will pull you", - "pull you in after it hits.", + "in after it hits.", }); } diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/atomic/RedisStringRepository.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/atomic/RedisStringRepository.java index 910d61b38..b637b491d 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/atomic/RedisStringRepository.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/atomic/RedisStringRepository.java @@ -5,25 +5,36 @@ import mineplex.serverdata.redis.RedisRepository; import mineplex.serverdata.servers.ConnectionData; import redis.clients.jedis.Jedis; -import redis.clients.jedis.Response; -import redis.clients.jedis.Transaction; -import static mineplex.serverdata.Utility.currentTimeMillis; public class RedisStringRepository extends RedisRepository { private final String _dataKey; + private final int _expiration; - public RedisStringRepository(ConnectionData writeConn, ConnectionData readConn, Region region, String dataKey) + public RedisStringRepository(ConnectionData writeConn, ConnectionData readConn, Region region, String dataKey, int expiryInSeconds) { super(writeConn, readConn, region); this._dataKey = dataKey; + this._expiration = expiryInSeconds; + } + + public RedisStringRepository(ConnectionData writeConn, ConnectionData readConn, Region region, String dataKey) + { + this(writeConn, readConn, region, dataKey, -1); } public void set(String key, String value) { try (Jedis jedis = getResource(true)) { - jedis.set(generateKey(key), value); + if (_expiration == -1) + { + jedis.set(generateKey(key), value); + } + else + { + jedis.setex(generateKey(key), _expiration, value); + } } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index 41e6239be..c5b819fcf 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -166,6 +166,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable int gingerbreadChestsReceived = 0; int minestrikeChestsReceived = 0; int loveChestsReceived = 0; + int stPatricksChestReceived = 0; for (CoinTransactionToken transaction : donor.getCoinTransactions()) { @@ -319,6 +320,16 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable loveChestsReceived += 1; } } + if (transaction.SalesPackageName.startsWith("St Patricks Chest")) + { + if (transaction.Coins == 0 && transaction.Gems == 0) + { + if (transaction.SalesPackageName.split(" ").length == 4) + stPatricksChestReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[3]); + else if (transaction.SalesPackageName.split(" ").length == 3) + stPatricksChestReceived += 1; + } + } if (transaction.SalesPackageName.startsWith("Valentines Gift")) { if (transaction.Coins == 0 && transaction.Gems == 0) @@ -391,6 +402,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable caller.sendMessage(C.cBlue + "Trick or Treat Chests Received: " + C.cYellow + trickOrTreatChestsReceived + " " + C.cBlue + "Thankful Chests Received: " + C.cYellow + thankfulChestsReceived); 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 + "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 a8ac55cf0..c1809951d 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.StPatricksChest; import mineplex.staffServer.salespackage.salespackages.ThankfulChest; import mineplex.staffServer.salespackage.salespackages.TrickOrTreatChest; @@ -100,6 +101,7 @@ public class SalesPackageManager extends MiniPlugin AddSalesPackage(new HauntedChest(this)); AddSalesPackage(new MinestrikeChest(this)); AddSalesPackage(new LoveChest(this)); + AddSalesPackage(new StPatricksChest(this)); AddSalesPackage(new TrickOrTreatChest(this)); AddSalesPackage(new ThankfulChest(this)); @@ -171,7 +173,7 @@ 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 ThankfulChest || salesPackage instanceof GingerbreadChest || salesPackage instanceof MinestrikeChest || salesPackage instanceof LoveChest || salesPackage instanceof StPatricksChest) { 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/StPatricksChest.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/StPatricksChest.java new file mode 100644 index 000000000..32ae815a6 --- /dev/null +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/salespackages/StPatricksChest.java @@ -0,0 +1,20 @@ +package mineplex.staffServer.salespackage.salespackages; + +import org.bukkit.entity.Player; + +import mineplex.staffServer.salespackage.SalesPackageManager; + +public class StPatricksChest extends SalesPackageBase +{ + public StPatricksChest(SalesPackageManager manager) + { + super(manager, "1 St Patricks Chest"); + } + + public void displayToAgent(Player agent, String playerName) + { + addButton(agent, "/sales item " + playerName + " 1 Item St Patricks Chest", "Give 1 St Patricks Chest."); + agent.sendMessage(" "); + addBackButton(agent, playerName); + } +} diff --git a/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java index 2bb683ac8..68023807b 100644 --- a/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java +++ b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java @@ -118,9 +118,8 @@ public class VotifierManager extends MiniPlugin } } - String lowerPlayerName = playerName.toLowerCase(); - final PlayerStatus usStatus = _usPlayerRepo.getElement(lowerPlayerName); - final PlayerStatus euStatus = _euPlayerRepo.getElement(lowerPlayerName); + final PlayerStatus usStatus = _usPlayerRepo.getElement(uuid.toString()); + final PlayerStatus euStatus = _euPlayerRepo.getElement(uuid.toString()); System.out.println("Loaded " + playerName + " with uuid " + uuid); System.out.println("Attempting to award bonus"); 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 6478db304..82081472c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -3,6 +3,7 @@ package nautilus.game.arcade; import java.io.File; import java.util.HashMap; +import mineplex.core.aprilfools.AprilFoolsManager; import net.minecraft.server.v1_8_R3.MinecraftServer; import org.bukkit.Bukkit; @@ -73,6 +74,7 @@ import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.core.velocity.VelocityFix; import mineplex.core.visibility.VisibilityManager; +import mineplex.core.website.WebsiteLinkManager; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; @@ -199,7 +201,10 @@ public class Arcade extends JavaPlugin new FoodDupeFix(this); require(TwoFactorAuth.class); + new WebsiteLinkManager(this, _clientManager); + AprilFoolsManager.getInstance(); + //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); 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 572189cc2..c9f13d3ef 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 @@ -294,7 +294,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed public long PrepareTime = 9000; public boolean PlaySoundGameStart = true; - public double XpMult = 2; + public double XpMult = 1; public boolean SpeedMeasurement = false; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java index 794bc4cc6..d64e698de 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/Christmas.java @@ -34,7 +34,7 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketInfo; import mineplex.core.recharge.Recharge; -import mineplex.core.titles.tracks.HolidayCheerTrack; +import mineplex.core.titles.tracks.standard.HolidayCheerTrack; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index 483fdf15e..457fcb5ce 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -224,8 +224,8 @@ public class Draw extends SoloGame ); registerChatStats( - new ChatStatData("TotalGuess", "Total Guess'", true), - new ChatStatData("PureLuck", "Lucky Guess'", true) + new ChatStatData("TotalGuess", "Total Guesses", true), + new ChatStatData("PureLuck", "Lucky Guesses", true) ); new CompassModule() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java index 88b9411c9..364028b29 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/hotbar/HotbarEditor.java @@ -14,6 +14,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.Inventory; @@ -127,11 +128,24 @@ public class HotbarEditor extends MiniPlugin if (UtilItem.isSimilar(item, _item, UtilItem.ItemAttribute.NAME)) { + event.setCancelled(true); HotbarInventory.open(event.getPlayer(), this); } } } + @EventHandler + public void onInteract(PlayerInteractEntityEvent event) + { + ItemStack item = event.getPlayer().getItemInHand(); + + if (UtilItem.isSimilar(item, _item, UtilItem.ItemAttribute.NAME)) + { + event.setCancelled(true); + HotbarInventory.open(event.getPlayer(), this); + } + } + public Gladiators getHost() { return _host; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/modes/ChampionsGladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/modes/ChampionsGladiators.java index dd740ef73..d7af66dea 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/modes/ChampionsGladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/modes/ChampionsGladiators.java @@ -5,6 +5,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityRegainHealthEvent; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -17,6 +19,7 @@ import nautilus.game.arcade.game.games.champions.kits.KitRanger; import nautilus.game.arcade.game.games.gladiators.Arena; import nautilus.game.arcade.game.games.gladiators.ArenaType; import nautilus.game.arcade.game.games.gladiators.Gladiators; +import nautilus.game.arcade.game.games.gladiators.RoundState; import nautilus.game.arcade.kit.Kit; /** @@ -88,5 +91,11 @@ public class ChampionsGladiators extends Gladiators { return "Champions Gladiators"; } - + + @EventHandler + public void skill(SkillTriggerEvent event) + { + if (getRoundState() != RoundState.FIGHTING) + event.SetCancelled(true); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/micro/Micro.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/micro/Micro.java index 09941ea19..6e70e0851 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/micro/Micro.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/micro/Micro.java @@ -9,6 +9,8 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.BlockGrowEvent; import org.bukkit.event.block.BlockPlaceEvent; import mineplex.core.common.util.MapUtil; @@ -107,12 +109,24 @@ public class Micro extends TeamGame { Block block = WorldData.World.getBlockAt(x, y, z); - if (block.getType() == Material.AIR || block.isLiquid()) + if (block.getType() == Material.AIR) continue; _blocks.add(block); } } + + @EventHandler + public void preventGrow(BlockGrowEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void preventFlow(BlockFromToEvent event) + { + event.setCancelled(true); + } @EventHandler public void BlockPlace(BlockPlaceEvent event) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/micro/modes/OverpoweredMicroBattles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/micro/modes/OverpoweredMicroBattles.java index b1f19b179..7adb3c904 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/micro/modes/OverpoweredMicroBattles.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/micro/modes/OverpoweredMicroBattles.java @@ -5,6 +5,7 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.games.AbsorptionFix; import nautilus.game.arcade.game.games.micro.Micro; import nautilus.game.arcade.game.games.micro.modes.kits.KitOverlord; +import nautilus.game.arcade.game.modules.TeamArmorModule; import nautilus.game.arcade.kit.Kit; /** @@ -23,7 +24,10 @@ public class OverpoweredMicroBattles extends Micro new KitOverlord(manager) }, GameType.Brawl); - + + getModule(TeamArmorModule.class) + .dontGiveTeamArmor(); + new AbsorptionFix(this); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/micro/modes/TinyWinners.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/micro/modes/TinyWinners.java index 2eab38c90..9e66f6631 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/micro/modes/TinyWinners.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/micro/modes/TinyWinners.java @@ -14,6 +14,7 @@ import nautilus.game.arcade.game.games.champions.kits.KitKnight; import nautilus.game.arcade.game.games.champions.kits.KitMage; import nautilus.game.arcade.game.games.champions.kits.KitRanger; import nautilus.game.arcade.game.games.micro.Micro; +import nautilus.game.arcade.game.modules.TeamArmorModule; import nautilus.game.arcade.kit.Kit; /** @@ -41,6 +42,8 @@ public class TinyWinners extends Micro Manager.getClassManager().GetItemFactory().getProximityManager().setProxyLimit(6); StrictAntiHack = true; + getModule(TeamArmorModule.class) + .dontGiveTeamArmor(); manager.enableChampionsModules(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java index cc694d4f9..34de2ce93 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java @@ -559,7 +559,7 @@ public class Gun extends StrikeItem C.cYellow + C.Bold + "Damage per Bullet: " + ChatColor.RESET + UtilMath.trim(1, getDamage()), C.cYellow + C.Bold + "Armor Penetration: " + ChatColor.RESET + (int)(_gunStats.getArmorPen()*100) + "%", C.cYellow + C.Bold + "Damage Dropoff: " + ChatColor.RESET + (int)(_gunStats.getDropoff()*1000d) + "% per 10 Blocks", - C.cYellow + C.Bold + "Recoil per Shot: " + ChatColor.RESET + _gunStats.getConeIncreaseRate(), + C.cYellow + C.Bold + "Recoil per Shot: " + ChatColor.RESET + UtilMath.trim(2, _gunStats.getConeIncreaseRate()), C.cYellow + C.Bold + "Recoil Recovery: " + ChatColor.RESET + _gunStats.getConeReduceRate() + " per Second", }; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/modes/EweHeroes.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/modes/EweHeroes.java index a55694553..b66971a8c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/modes/EweHeroes.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/modes/EweHeroes.java @@ -18,6 +18,7 @@ import nautilus.game.arcade.game.games.champions.kits.KitKnight; import nautilus.game.arcade.game.games.champions.kits.KitMage; import nautilus.game.arcade.game.games.champions.kits.KitRanger; import nautilus.game.arcade.game.games.sheep.SheepGame; +import nautilus.game.arcade.game.modules.TeamArmorModule; import nautilus.game.arcade.kit.Kit; /** @@ -47,6 +48,8 @@ public class EweHeroes extends SheepGame Manager.getClassManager().GetItemFactory().getProximityManager().setProxyLimit(6); StrictAntiHack = true; + getModule(TeamArmorModule.class) + .dontGiveTeamArmor(); new ChampionsFixes(this); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/modes/OverpoweredSheepQuest.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/modes/OverpoweredSheepQuest.java index 8b44da93c..64a4c46ae 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/modes/OverpoweredSheepQuest.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sheep/modes/OverpoweredSheepQuest.java @@ -5,6 +5,7 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.games.AbsorptionFix; import nautilus.game.arcade.game.games.sheep.SheepGame; import nautilus.game.arcade.game.games.sheep.modes.kits.KitShepherd; +import nautilus.game.arcade.game.modules.TeamArmorModule; import nautilus.game.arcade.kit.Kit; /** @@ -21,7 +22,10 @@ public class OverpoweredSheepQuest extends SheepGame { new KitShepherd(manager) }, GameType.Brawl); - + + getModule(TeamArmorModule.class) + .dontGiveTeamArmor(); + new AbsorptionFix(this); } 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 fbad85f14..a1901ee2c 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 @@ -14,6 +14,13 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.loot.ChestLoot; +<<<<<<< .mine + + +======= +import mineplex.core.titles.tracks.standard.LuckyTrack; +import mineplex.core.titles.tracks.standard.UnluckyTrack; +>>>>>>> .theirs /** * The Island Object represents a flying Island
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 a948f40d9..f92eeffe2 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 @@ -152,7 +152,6 @@ public abstract class Skyfall extends Game private boolean _refillAnnounced; - private int _currentCrumble = 300; private boolean _supplyOpened; //private int _ringCrumbleRate; @@ -414,7 +413,6 @@ public abstract class Skyfall extends Game if (!_upperIsland.crumble(_islandCrumbleRate, Material.COAL_BLOCK, Material.ENDER_STONE)) { - _currentCrumble = (_upperIsland.getLocation().getBlockY() - _upperIsland.getHeight()); return islands; } else @@ -437,14 +435,12 @@ public abstract class Skyfall extends Game if (_lowerIsland.isCrumbledAway()) islands.add(_lowerIsland); - _currentCrumble = (_lowerIsland.getLocation().getBlockY() - _lowerIsland.getHeight()); if (_lowerIsland.crumble(_islandCrumbleRate, 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; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java index a437aa169..a82efebfc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java @@ -68,8 +68,8 @@ import mineplex.core.explosion.ExplosionEvent; import mineplex.core.loot.ChestLoot; import mineplex.core.loot.RandomItem; import mineplex.core.recharge.Recharge; -import mineplex.core.titles.tracks.LuckyTrack; -import mineplex.core.titles.tracks.UnluckyTrack; +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.combat.CombatComponent; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java index 1cb424597..e542c7549 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java @@ -65,7 +65,7 @@ public class SoloSuperSmash extends SuperSmash { super(manager, kits, type, new String[] { - "Each player has 3 respawns", + "Each player has 4 respawns", "Attack to restore hunger!", "Last player alive wins!" }); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java index 56ceef7ed..4dc2f850f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java @@ -101,8 +101,8 @@ import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.loot.ChestLoot; import mineplex.core.loot.RandomItem; import mineplex.core.recharge.Recharge; -import mineplex.core.titles.tracks.LuckyTrack; -import mineplex.core.titles.tracks.UnluckyTrack; +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.core.visibility.VisibilityManager; @@ -1986,7 +1986,7 @@ public abstract class SurvivalGames extends Game @EventHandler public void craftedItems(CraftItemEvent event) { - if (UtilItem.isWeapon(event.getCurrentItem()) || UtilItem.isArmor(event.getCurrentItem())) + if (UtilItem.isWeapon(event.getCurrentItem()) || UtilItem.isArmor(event.getCurrentItem()) || event.getCurrentItem().getType() == Material.FISHING_ROD) { UtilItem.makeUnbreakable(event.getCurrentItem()); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java index e9b881916..93c2fb37c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/turfforts/TurfForts.java @@ -380,7 +380,7 @@ public class TurfForts extends TeamGame while (block.getTypeId() == 0 && block.getY() > 0) block = block.getRelative(BlockFace.DOWN); - if (block.getData() != team.GetColorData()) + if ((block.getType() != Material.STAINED_CLAY && block.getType() != Material.WOOL) || block.getData() != team.GetColorData()) { UtilPlayer.message(event.getPlayer(), F.main("Game", "You can only build above " + F.elem(team.GetColor() + team.GetName()) + ".")); event.setCancelled(true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TeamArmorModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TeamArmorModule.java index 1d75f12ac..e158fd9d9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TeamArmorModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TeamArmorModule.java @@ -37,13 +37,25 @@ public class TeamArmorModule extends Module public TeamArmorModule giveTeamArmor() { - this._giveTeamArmor = true; + _giveTeamArmor = true; return this; } public TeamArmorModule giveHotbarItem() { - this._giveHotbarItem = true; + _giveHotbarItem = true; + return this; + } + + public TeamArmorModule dontGiveTeamArmor() + { + _giveTeamArmor = false; + return this; + } + + public TeamArmorModule dontGiveHotbarItem() + { + _giveHotbarItem = false; return this; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/compass/menu/CompassMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/compass/menu/CompassMenu.java index 81114a0b8..2c11196c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/compass/menu/CompassMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/compass/menu/CompassMenu.java @@ -6,28 +6,29 @@ import mineplex.core.shop.ShopBase; import mineplex.core.shop.page.ShopPageBase; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.game.modules.compass.menu.page.CompassPage; -public class CompassMenu extends ShopBase +public class CompassMenu extends ShopBase { private CompassModule _compassModule; public CompassMenu(CompassModule module) { - super(module.getGame().getArcadeManager(), module.getGame().getArcadeManager().GetClients(), module.getGame().getArcadeManager().GetDonation(), "Spectate Menu"); + super(module.getGame(), module.getGame().getArcadeManager().GetClients(), module.getGame().getArcadeManager().GetDonation(), "Spectate Menu"); this._compassModule = module; } @Override - protected ShopPageBase> buildPagesFor(Player player) + protected ShopPageBase> buildPagesFor(Player player) { return new CompassPage(this, _compassModule, player); } public void update() { - for (ShopPageBase> shopPage : getPlayerPageMap().values()) + for (ShopPageBase> shopPage : getPlayerPageMap().values()) { shopPage.refresh(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/compass/menu/page/CompassPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/compass/menu/page/CompassPage.java index c126adb79..a4f88d31a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/compass/menu/page/CompassPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/compass/menu/page/CompassPage.java @@ -21,6 +21,7 @@ import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageInventory; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.modules.compass.CompassEntry; import nautilus.game.arcade.game.modules.compass.CompassModule; @@ -28,7 +29,7 @@ import nautilus.game.arcade.game.modules.compass.menu.CompassMenu; import nautilus.game.arcade.game.modules.compass.menu.button.CompassButton; public class CompassPage extends - ShopPageInventory + ShopPageInventory { private CompassModule _compassModule; private IButton[] _buttons; @@ -36,7 +37,7 @@ public class CompassPage extends public CompassPage(CompassMenu menu, CompassModule compassModule, Player player) { - super(compassModule.getGame().getArcadeManager(), + super(compassModule.getGame(), menu, compassModule.getGame().getArcadeManager().GetClients(), compassModule.getGame().getArcadeManager().GetDonation(), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/SetGamePage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/SetGamePage.java index ef38a29ed..4a24f5090 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/SetGamePage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/SetGamePage.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.gui.privateServer.page; import java.util.ArrayList; +import java.util.List; import mineplex.core.common.util.C; import mineplex.core.game.GameCategory; @@ -89,16 +90,24 @@ public class SetGamePage extends BasePage private void addGameButton(int slot, final GameType type) { - String infoString = ChatColor.RESET + C.cGray + "Make this next Game Type"; - String space = "§1"; - String left = ChatColor.YELLOW + "Left-Click " + C.cGray + "for a §fRandom Map§7."; - String right = ChatColor.YELLOW + "Right-Click " + C.cGray + "to §fChoose Map§7."; - String[] normLore = new String[]{infoString, space, left, right}; + List lore = new ArrayList<>(); + lore.add(ChatColor.RESET + C.cGray + "Make this next Game Type"); + lore.add("§1"); + if (type == GameType.UHC || type == GameType.UHCSolo || type == GameType.UHCSoloSpeed || type == GameType.UHCTeamsSpeed) + { + lore.add(ChatColor.YELLOW + "Left-Click " + C.cGray + "to select"); + } + else + { + lore.add(ChatColor.YELLOW + "Left-Click " + C.cGray + "for a §fRandom Map§7."); + lore.add(ChatColor.YELLOW + "Right-Click " + C.cGray + "to §fChoose Map§7."); + } if (_manager.hasWarning().contains(type)) { - normLore = new String[]{infoString, space, left, right, "§2", "§c§lWARNING: §fThis game was rejected!"}; + lore.add("§2"); + lore.add("§c§lWARNING: §fThis game was rejected!"); } - ShopItem shopItem = new ShopItem(type.GetMaterial(), type.GetMaterialData(), type.GetName(), normLore, 1, false, false); + ShopItem shopItem = new ShopItem(type.GetMaterial(), type.GetMaterialData(), type.GetName(), lore.toArray(new String[lore.size()]), 1, false, false); addButton(slot, shopItem, new IButton() { @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index 49e45ee5e..47ea01a43 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -117,7 +117,7 @@ public class GameHostManager implements Listener legendGames.add(GameType.WitherAssault); legendGames.add(GameType.Wizards); legendGames.add(GameType.Build); - //legendGames.add(GameType.UHC); + legendGames.add(GameType.UHC); legendGames.add(GameType.MineStrike); legendGames.add(GameType.Skywars); legendGames.add(GameType.SpeedBuilders); @@ -561,16 +561,23 @@ public class GameHostManager implements Listener @EventHandler public void whitelistCommand(PlayerCommandPreprocessEvent event) { - if (_host == null || !event.getPlayer().equals(_host)) + if (_host == null) return; - if (isCommunityServer()) - return; - + if (!event.getMessage().toLowerCase().startsWith("/whitelist")) return; - if (!isPrivateServer()) + if (!event.getPlayer().equals(_host)) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("MPS", "You do not have permission to whitelist players. Ask the MPS host")); return; + } + if (isCommunityServer() || !isPrivateServer()) + { + event.setCancelled(true); + return; + } event.setCancelled(true); 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 7e063dd51..d87447cc1 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 @@ -1,8 +1,9 @@ package nautilus.game.arcade.managers; -import mineplex.core.Managers; -import mineplex.core.PlayerSelector; -import mineplex.core.common.util.UtilLambda; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.FireworkEffect.Type; @@ -14,11 +15,13 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import mineplex.core.PlayerSelector; import mineplex.core.bonuses.event.CarlSpinnerEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilLambda; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextBottom; @@ -32,13 +35,13 @@ import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.mount.Mount; import mineplex.core.mount.types.MountDragon; -import mineplex.core.titles.Titles; import mineplex.core.portal.GenericServer; import mineplex.core.portal.Intent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.RestartServerEvent; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.events.GamePrepareCountdownCommence; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -50,20 +53,6 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.uhc.UHC; import nautilus.game.arcade.gametutorial.TutorialPhase; import nautilus.game.arcade.gametutorial.TutorialText; -import org.bukkit.ChatColor; -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.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; public class GameManager implements Listener { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java index 4c8db7903..f1834bdaf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java @@ -7,7 +7,7 @@ import mineplex.core.boosters.Booster; import mineplex.core.common.Rank; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.*; -import mineplex.core.titles.tracks.GemCollectorTrack; +import mineplex.core.titles.tracks.standard.GemCollectorTrack; import mineplex.minecraft.game.core.combat.CombatComponent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.serverdata.Utility; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/NextBestGameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/NextBestGameManager.java index 80e803d08..b74132e1c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/NextBestGameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/NextBestGameManager.java @@ -409,6 +409,9 @@ public class NextBestGameManager implements Listener private void handle(Player player) { + if (getGame().IsAlive(player)) + return; + Party party = _partyManager.getPartyByPlayer(player); if (party != null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java index 11fa85b5c..047e69531 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java @@ -111,8 +111,7 @@ public class GameChatManager implements Listener } else { - if (rank != Rank.ALL) - rankStr = rank.getTag(true, true) + " " + C.Reset; + rankStr = rank.getTag(true, true) + " " + C.Reset; } //Party Chat diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsStatTracker.java index 7a24f23d1..d7d729926 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsStatTracker.java @@ -5,7 +5,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.titles.tracks.WarriorTrack; +import mineplex.core.titles.tracks.standard.WarriorTrack; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.Game; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinStatTracker.java index 68c9de226..fd0b57ccb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinStatTracker.java @@ -6,7 +6,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import mineplex.core.titles.tracks.PeacefulTrack; +import mineplex.core.titles.tracks.standard.PeacefulTrack; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java index 76c0c5c84..f6f2cee55 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java @@ -1,5 +1,6 @@ package mineplex.gemhunters; +import mineplex.core.aprilfools.AprilFoolsManager; import net.minecraft.server.v1_8_R3.MinecraftServer; import org.bukkit.Bukkit; @@ -14,6 +15,7 @@ import mineplex.core.TimingsFix; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; +import mineplex.core.beta.BetaWhitelist; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.boosters.BoosterManager; import mineplex.core.chat.Chat; @@ -51,6 +53,7 @@ import mineplex.core.party.PartyManager; import mineplex.core.pet.PetManager; import mineplex.core.portal.GenericServer; import mineplex.core.portal.Portal; +import mineplex.core.powerplayclub.PowerPlayClubRepository; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; @@ -292,8 +295,10 @@ public class GemHunters extends JavaPlugin new WorldListeners(this); new TimeCycle(this); new UndergroundMobs(this); - new DebugListeners(this); - + new DebugListeners(this); + + AprilFoolsManager.getInstance(); + // UpdateEvent!!! new Updater(this); @@ -311,7 +316,7 @@ public class GemHunters extends JavaPlugin require(TwoFactorAuth.class); // beta whitelist - //new BetaWhitelist(clientManager, new PowerPlayClubRepository(this, clientManager, donationManager)); + new BetaWhitelist(clientManager, new PowerPlayClubRepository(this, clientManager, donationManager)); } @Override diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java index a48e843d7..342b1851c 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/quest/QuestModule.java @@ -4,6 +4,8 @@ import java.util.List; import java.util.UUID; import java.util.concurrent.TimeUnit; +import net.md_5.bungee.api.ChatColor; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -39,7 +41,6 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.gemhunters.economy.EconomyModule; import mineplex.gemhunters.quest.command.ResetQuestsCommand; import mineplex.gemhunters.quest.types.ChestOpenerQuest; -import mineplex.gemhunters.quest.types.CraftingQuest; import mineplex.gemhunters.quest.types.EnjoyTheViewQuest; import mineplex.gemhunters.quest.types.GiveItemQuest; import mineplex.gemhunters.quest.types.KillMostValuableQuest; @@ -49,7 +50,6 @@ import mineplex.gemhunters.quest.types.SamitoDQuest; import mineplex.gemhunters.quest.types.SpecificChestOpenerQuest; import mineplex.gemhunters.quest.types.WalkingQuest; import mineplex.gemhunters.world.WorldDataModule; -import net.md_5.bungee.api.ChatColor; @ReflectivelyCreateMiniPlugin public class QuestModule extends MiniClientPlugin @@ -89,7 +89,7 @@ public class QuestModule extends MiniClientPlugin new KillMostValuableQuest(17, "Equality", "Slay the most valuable player in the game.", 100, 1500), - new CraftingQuest(18, "Light em up", "Craft " + F.count("5 Torches"), 25, 250, Material.TORCH, 5) + //new CraftingQuest(18, "Light em up", "Craft " + F.count("5 Torches"), 25, 250, Material.TORCH, 5) }; private final EconomyModule _economy;