diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 0439fa106..eb76c8be4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -382,30 +382,105 @@ public enum Achievement AchievementCategory.MASTER_BUILDERS), //Castle Siege - CASTLE_SIEGE_WINS("FOR THE KING!", 600, + CASTLE_SIEGE_WINS("FOR THE KING!", 0, new String[]{"Castle Siege.ForTheKing"}, new String[]{"Win as Defenders 50 times"}, + new int[][]{ new int[]{0,0,10000}}, new int[]{50}, + "", + new String[0], AchievementCategory.CASTLE_SIEGE), - CASTLE_SIEGE_KINGSLAYER("Kingslayer", 800, + CASTLE_SIEGE_KINGSLAYER("Kingslayer", 0, new String[]{"Castle Siege.KingSlayer"}, new String[]{"Get the killing blow on the King"}, + new int[][]{ new int[]{0,0,4000}}, new int[]{1}, + "", + new String[0], AchievementCategory.CASTLE_SIEGE), - CASTLE_SIEGE_BLOOD_THIRSTY("Blood Thirsty", 1200, + CASTLE_SIEGE_BLOOD_THIRSTY("Blood Thirsty", 0, new String[]{"Castle Siege.BloodThirsty"}, new String[]{"Kill 50 Undead in a single game"}, + new int[][]{ new int[]{0,0,8000}}, new int[]{1}, + "", + new String[0], AchievementCategory.CASTLE_SIEGE), - CASTLE_SIEGE_ASSASSIN("Assassin", 1000, + CASTLE_SIEGE_ASSASSIN("Assassin", 0, new String[]{"Castle Siege.Assassin"}, new String[]{"Do 50% or more of the damage to the king"}, + new int[][]{ new int[]{0,0,8000}}, new int[]{1}, + "", + new String[0], AchievementCategory.CASTLE_SIEGE), - + + CASTLE_SIEGE_CLOSE_CALL("Slash or Burn", 0, + new String[]{"Castle Siege.CloseCall"}, + new String[]{"Win the Game as Undead within the last 70 seconds of the game"}, + new int[][]{ new int[]{0,0,8000}}, + new int[]{1}, + "", + new String[0], + AchievementCategory.CASTLE_SIEGE), + + CASTLE_SIEGE_WOLF_KILL("Canine Revenge", 0, + new String[]{"Castle Siege.WolfKill"}, + new String[]{"As a Castle Wolf, Kill 12 Undead in One Game"}, + new int[][]{ new int[]{0,0,7000}}, + new int[]{1}, + "", + new String[0], + AchievementCategory.CASTLE_SIEGE), + + CASTLE_SIEGE_KING_GUARD("Royal Guard", 0, + new String[]{"Castle Siege.KingGuard"}, + new String[]{"Kill 5 Undead within 8 blocks of the King in the last 70 seconds"}, + new int[][]{ new int[]{0,0,8000}}, + new int[]{1}, + "", + new String[0], + AchievementCategory.CASTLE_SIEGE), + + CASTLE_SIEGE_KING_FULL("Not Even a Scratch", 0, + new String[]{"Castle Siege.KingFull"}, + new String[]{"Win the Game as Defense with the King at Full Health"}, + new int[][]{ new int[]{0,0,8000}}, + new int[]{1}, + "", + new String[0], + AchievementCategory.CASTLE_SIEGE), + + CASTLE_SIEGE_FIRST_BLOOD("Vigilante", 0, + new String[]{"Castle Siege.FirstBlood"}, + new String[]{"Get 5 First Bloods"}, + new int[][]{ new int[]{0,0,6000}}, + new int[]{5}, + "", + new String[0], + AchievementCategory.CASTLE_SIEGE), + + CASTLE_SIEGE_TNT_KILLER("Defusal Squadron", 0, + new String[]{"Castle Siege.TNTKiller"}, + new String[]{"Kill 5 TNT Carriers in One Game as Defenders"}, + new int[][]{ new int[]{0,0,7000}}, + new int[]{1}, + "", + new String[0], + AchievementCategory.CASTLE_SIEGE), + + CASTLE_SIEGE_HORSE_KILLER("Equestrian Elimination", 0, + new String[]{"Castle Siege.HorseKiller"}, + new String[]{"Kill 25 Horses"}, + new int[][]{ new int[]{0,0,6000}}, + new int[]{25}, + "", + new String[0], + AchievementCategory.CASTLE_SIEGE), + //Castle Assault CASTLE_ASSAULT_KILL_STREAK("Kill Streak", 0, new String[]{"Castle Assault.KillStreak", "Castle Assault TDM.KillStreak"}, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 7e846e8d5..c159880f0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -89,9 +89,31 @@ public enum AchievementCategory Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CastleAssault.getGameId(), GameDisplay.CastleAssaultTDM.getGameId()), CASTLE_SIEGE("Castle Siege", null, - new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Kills as Defenders"), new StatDisplay("Deaths as Defenders"), - new StatDisplay("Kills as Undead"), new StatDisplay("Deaths as Undead"), StatDisplay.GEMS_EARNED }, - Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CastleSiege.getGameId()), + new StatDisplay[] + { + StatDisplay.WINS, + StatDisplay.GAMES_PLAYED, + null, + new StatDisplay(C.Bold + "Total", true), + StatDisplay.KILLS, + new StatDisplay("Assists", "Defender Assists", "Undead Assists"), + StatDisplay.DEATHS, + null, + new StatDisplay(C.Bold + "Defenders", true), + null, + StatDisplay.fromGame("Kills", GameDisplay.CastleSiege, "Defenders Kills"), + StatDisplay.fromGame("Assists", GameDisplay.CastleSiege, "Defenders Assists"), + StatDisplay.fromGame("Deaths", GameDisplay.CastleSiege, "Defenders Deaths"), + null, + new StatDisplay(C.Bold + "Undead", true), + null, + StatDisplay.fromGame("Kills", GameDisplay.CastleSiege, "Undead Kills"), + StatDisplay.fromGame("Assists", GameDisplay.CastleSiege, "Undead Assists"), + StatDisplay.fromGame("Deaths", GameDisplay.CastleSiege, "Undead Deaths"), + null, + StatDisplay.GEMS_EARNED, + }, + Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, "Undead Summoner & Castle Paladin Kit", false, GameDisplay.CastleSiege.getGameId()), BAWK_BAWK_BATTLES("Bawk Bawk Battles", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED }, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java index d68117cf7..e5d931a7c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java @@ -57,14 +57,15 @@ public class AchievementPage extends ShopPageBase achievements = getAchievements(); + int currentIndex = Math.max(ACHIEVEMENT_MIDDLE_INDEX - (achievements.size() / 2), 27); boolean hasAllAchievements = true; int achievementCount = 0; + boolean overflow = false; - ArrayList masterAchievementLore = new ArrayList(); + ArrayList masterAchievementLore = new ArrayList<>(); masterAchievementLore.add(" "); - List achievements = getAchievements(); for (Achievement achievement : achievements) { AchievementData data = getPlugin().get(_targetStats, achievement); @@ -93,13 +94,12 @@ public class AchievementPage extends ShopPageBase lore = new ArrayList(); + ArrayList lore = new ArrayList<>(); lore.add(" "); for (String descLine : achievement.getDesc()) { lore.add(ChatColor.RESET + descLine); } - if (!hasUnlocked && achievement.isOngoing()) { @@ -107,11 +107,64 @@ public class AchievementPage extends ShopPageBase 0) { lore.add(" "); lore.add(C.cYellow + "Reward: " + C.cGreen + achievement.getGemReward() + " Gems"); } + + if (!hasUnlocked && achievement.getLevelUpRewards().length > 0) + { + int[][] rewards = achievement.getLevelUpRewards(); + + if (data.getLevel() < rewards.length) + { + int[] thisRewards = rewards[data.getLevel()]; + int greaterThanZero = 0; + + for (int reward : thisRewards) + { + if (reward > 0) + { + greaterThanZero++; + } + } + + lore.add(" "); + + if (greaterThanZero == 1) + { + String rewardString = C.cYellow + "Reward: "; + + for (int i = 0; i < thisRewards.length; i++) + { + int reward = thisRewards[i]; + + if (reward > 0) + { + rewardString += getFormattedReward(reward, i); + break; + } + } + + lore.add(rewardString); + } + else + { + lore.add(C.cYellow + "Rewards:"); + + for (int i = 0; i < thisRewards.length; i++) + { + int reward = thisRewards[i]; + + if (reward > 0) + { + lore.add(C.cWhite + " - " + getFormattedReward(reward, i)); + } + } + } + } + } if (hasUnlocked && data.getLevel() == achievement.getMaxLevel()) { @@ -126,23 +179,28 @@ public class AchievementPage extends ShopPageBase 0) { - String itemName = ChatColor.RESET + _category.getFriendlyName() + " Master Achievement"; + String itemName = C.Bold + _category.getFriendlyName() + " Master Achievement"; masterAchievementLore.add(" "); if (getPlayer().getName().equalsIgnoreCase(_targetName)) { if (_category.getReward() != null) - masterAchievementLore.add(C.cYellow + C.Bold + "Reward: " + ChatColor.RESET + _category.getReward()); + masterAchievementLore.add(C.cYellow + "Reward: " + ChatColor.RESET + _category.getReward()); else - masterAchievementLore.add(C.cYellow + C.Bold + "Reward: " + ChatColor.RESET + "Coming Soon..."); + masterAchievementLore.add(C.cYellow + "Reward: " + ChatColor.RESET + "Coming Soon..."); } - addItem(40, new ShopItem(hasAllAchievements ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK, (byte) 0, itemName, masterAchievementLore.toArray(new String[0]), 1, false, true)); + addItem(overflow ? 49 : 40, new ShopItem(hasAllAchievements ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK, (byte) 0, itemName, masterAchievementLore.toArray(new String[0]), 1, false, true)); } addBackButton(); @@ -161,7 +219,6 @@ public class AchievementPage extends ShopPageBase, AntiHackAction> ACTIONS = ImmutableMap., AntiHackAction>builder() .put(KillauraTypeA.class, new ImmediateBanAction(200)) - //.put(KillauraTypeD.class, new BanwaveAction(1500)) + .put(KillauraTypeD.class, new BanwaveAction(1500)) .put(KillauraTypeF.class, new BanwaveAction(600)) - .put(Glide.class, new ImmediateBanAction(10000)) - .put(Speed.class, new ImmediateBanAction(10000)) + .put(Glide.class, new ImmediateBanAction(7500)) + .put(Speed.class, new ImmediateBanAction(7500)) .put(HeadRoll.class, new ImmediateBanAction(2000)) .put(Toggle.class, new ImmediateBanAction(500)) - .put(Timer.class, new ImmediateBanAction(15000)) + .put(Timer.class, new ImmediateBanAction(10000)) .put(BadPackets.class, new GEPBanAction(300)) .put(KillauraTypeB.class, new GEPBanAction(100)) .build(); @@ -468,11 +468,6 @@ public class AntiHack extends MiniPlugin @EventHandler public void onHack(PlayerViolationEvent event) { - if (event.getCheckClass() == Toggle.class) - { - return; - } - if (_ignoredChecks.contains(event.getCheckClass())) { return; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/ClientMessage.java b/Plugins/Mineplex.Core/src/mineplex/core/message/ClientMessage.java index c27e778fa..64956db8f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/ClientMessage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/ClientMessage.java @@ -6,4 +6,4 @@ public class ClientMessage public String LastAdminTo; public long LastToTime; public int SpamCounter; -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index e5b4e60a6..f1d0435ad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -284,6 +284,10 @@ public class MessageManager extends MiniClientPlugin // Send UtilPlayer.message(to, C.cGold + "§l" + from.getName() + " > " + to.getName() + C.cYellow + " §l" + message); + if (_punish.GetClient(to.getName()).IsMuted() && _preferences.get(to).isActive(Preference.INFORM_MUTED)) + { + UtilPlayer.message(from, F.main(getName(), F.elem(to.getName()) + " is currently muted and cannot reply to you!")); + } } public void DoMessageAdmin(Player from, Player to, String message) @@ -366,7 +370,8 @@ public class MessageManager extends MiniClientPlugin "Mmm...Steak!", "Poop! Poop everywhere!", "I'm so forgetful. Like I was going to say somethin...wait what were we talking about?", - "Mmm...Steak!" + "Mmm...Steak!", + "#BlameAlex" ); } @@ -380,7 +385,7 @@ public class MessageManager extends MiniClientPlugin if (_randomMessage.isEmpty()) return "meow"; - return _randomMessage.get(UtilMath.r(_randomMessage.size())); + return UtilMath.randomElement(_randomMessage); } public void Help(Player caller) @@ -413,7 +418,7 @@ public class MessageManager extends MiniClientPlugin // Message the sender RedisMessageCallback message = new RedisMessageCallback(globalMessage, true, to.getName(), - C.cPurple + "-> " + toRank + " " + to.getName() + " " + C.cPurple + globalMessage.getMessage()); + C.cPurple + "-> " + toRank + " " + to.getName() + " " + C.cPurple + globalMessage.getMessage(), false); // Inform Admins for (Player staff : UtilServer.getPlayers()) @@ -437,8 +442,7 @@ public class MessageManager extends MiniClientPlugin if (canMessage != null) { - - RedisMessageCallback message = new RedisMessageCallback(globalMessage, false, null, canMessage); + RedisMessageCallback message = new RedisMessageCallback(globalMessage, false, null, canMessage, false); message.publish(); @@ -452,9 +456,11 @@ public class MessageManager extends MiniClientPlugin UtilPlayer.message(to, message); to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f); + + boolean informMuted = _punish.GetClient(to.getName()).IsMuted() && _preferences.get(to).isActive(Preference.INFORM_MUTED); // Message the sender - RedisMessageCallback redisMessage = new RedisMessageCallback(globalMessage, false, to.getName(), message); + RedisMessageCallback redisMessage = new RedisMessageCallback(globalMessage, false, to.getName(), message, informMuted); redisMessage.publish(); } @@ -474,6 +480,11 @@ public class MessageManager extends MiniClientPlugin if (target != null) { target.sendMessage(message.getMessage()); + + if (message.informMuted()) + { + UtilPlayer.message(target, F.main(getName(), F.elem(message.getLastReplied()) + " is currently muted and cannot reply to you!")); + } target.playSound(target.getLocation(), Sound.NOTE_PIANO, 2f, 2f); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/RedisMessage.java b/Plugins/Mineplex.Core/src/mineplex/core/message/redis/RedisMessage.java index 941ea76e5..2cd47cc02 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/RedisMessage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/redis/RedisMessage.java @@ -70,4 +70,4 @@ public class RedisMessage extends ServerCommand { // Utilitizes a callback functionality to seperate dependencies } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/RedisMessageCallback.java b/Plugins/Mineplex.Core/src/mineplex/core/message/redis/RedisMessageCallback.java index 11a634d37..e5218ebe0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/RedisMessageCallback.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/redis/RedisMessageCallback.java @@ -12,16 +12,17 @@ public class RedisMessageCallback extends ServerCommand private String _message; private String _setLastMessage; private String _target; - private boolean _staffMessage; + private boolean _staffMessage, _informMuted; private UUID _uuid; - public RedisMessageCallback(RedisMessage globalMessage, boolean staffMessage, String receivedPlayer, String message) + public RedisMessageCallback(RedisMessage globalMessage, boolean staffMessage, String receivedPlayer, String message, boolean informMuted) { _target = globalMessage.getSender(); _message = message; _setLastMessage = receivedPlayer; _uuid = globalMessage.getUUID(); _staffMessage = staffMessage; + _informMuted = informMuted; if (globalMessage.getSendingServer() != null) { @@ -33,6 +34,11 @@ public class RedisMessageCallback extends ServerCommand { return _staffMessage; } + + public boolean informMuted() + { + return _informMuted; + } public String getLastReplied() { @@ -59,4 +65,4 @@ public class RedisMessageCallback extends ServerCommand { // Utilitizes a callback functionality to seperate dependencies } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java index 3aba5513f..4cca2246e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/Preference.java @@ -50,7 +50,9 @@ public enum Preference implements Permission PARTY_DISPLAY_INVENTORY_UI(true, PreferenceCategory.SOCIAL, Material.CHEST, "Display Parties GUI"), - RANDOM_MESSAGES(true, PreferenceCategory.USER, Material.COMMAND, "Send random messages", "Got nothing to say? We got you covered!") + RANDOM_MESSAGES(true, PreferenceCategory.USER, Material.COMMAND, "Send Random Messages", "Got nothing to say? We got you covered!"), + + INFORM_MUTED(false, PreferenceCategory.USER, Material.BARRIER, "Inform When Muted", "Inform people who message you if you are muted!") ; private static final Map PREFERENCE_MAP = Maps.newHashMap(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeDetailsButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeDetailsButton.java index 11a12c356..b1d53fe15 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeDetailsButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeDetailsButton.java @@ -9,6 +9,8 @@ import org.bukkit.inventory.ItemStack; import com.google.common.collect.Lists; import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.menu.IconButton; import mineplex.core.progression.ProgressiveKit; @@ -36,7 +38,7 @@ public class KitUpgradeDetailsButton extends IconButton for (String detail : details) { - lore.add(C.cGray + detail); + lore.addAll(UtilText.splitLine(detail, LineFormat.LORE)); } lore.add(""); 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 c36f5a604..ef311d470 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/TrackManager.java @@ -23,6 +23,7 @@ import mineplex.core.titles.commands.GiveTrackCommand; import mineplex.core.titles.tracks.award.AlienInvasionTrack; import mineplex.core.titles.tracks.award.AprilFools2017Track; import mineplex.core.titles.tracks.award.Bridges2017Track; +import mineplex.core.titles.tracks.award.CastleSiegeTesterTrack; import mineplex.core.titles.tracks.award.ClansRaidTrack; import mineplex.core.titles.tracks.custom.DongerTrack; import mineplex.core.titles.tracks.custom.EarlyBirdTrack; @@ -107,6 +108,7 @@ public class TrackManager extends MiniPlugin registerTrack(new AprilFools2017Track()); registerTrack(new AlienInvasionTrack()); registerTrack(new ClansRaidTrack()); + registerTrack(new CastleSiegeTesterTrack()); // Staff tracks registerTrack(new BuilderTrack()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/CastleSiegeTesterTrack.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/CastleSiegeTesterTrack.java new file mode 100644 index 000000000..d71ecf911 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/award/CastleSiegeTesterTrack.java @@ -0,0 +1,59 @@ +package mineplex.core.titles.tracks.award; + +import java.util.Set; + +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; +import mineplex.core.titles.tracks.custom.ScrollAnimation; + +public class CastleSiegeTesterTrack extends Track +{ + + private static final String TITLE = "Castle Sieger"; + private static String[] buildAnimation() + { + return new ScrollAnimation(TITLE) + .withPrimaryColour(ChatColor.AQUA) + .withSecondaryColour(ChatColor.RED) + .withTertiaryColour(ChatColor.WHITE) + .bold() + .build(); + } + + private static final Set OWNERS = Sets.newHashSet( + "ca871a3f-349c-474c-9c45-c36f2e679ab3", // Moppletop + "852a8acf-7337-40d7-99ec-b08fd99650b5", // KingCrazy_ + "a20d59d1-cfd8-4116-ac27-45d9c7eb4a97", // Artix + "3d4b8e73-bc2f-4c62-baaf-78600141794a", // hazeae24 + "7b133339-2e02-48ef-9dd4-692415933dc5", // Kreshyy + "4e941b23-6e36-48cb-97c4-24f56ea128c1", // DooDooBug25 + "0a4b6d83-8eb0-46aa-bc0f-9b7f04046d52", // Livicus + "4f8f5380-ffe1-418d-97a4-0737c6edf352" // Hils + ); + + public CastleSiegeTesterTrack() + { + super( + "cs-tester", + ChatColor.RED, + "CS Tester", + "Castle Siege Tester", + "This track is awarded to the players who helped test the Castle Siege update. :)", + true); + + special(); + getRequirements() + .addTier(new TrackTier( + TITLE, + null, + player -> OWNERS.contains(player.getUniqueId().toString()), + new TrackFormat(ChatColor.RED, ChatColor.RED) + .animated(2, buildAnimation()) + )); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/ScrollAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/ScrollAnimation.java new file mode 100644 index 000000000..2937c99f4 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/titles/tracks/custom/ScrollAnimation.java @@ -0,0 +1,92 @@ +package mineplex.core.titles.tracks.custom; + +import net.md_5.bungee.api.ChatColor; + +import mineplex.core.common.util.C; + +public class ScrollAnimation +{ + + private final String _input; + private String _primary; + private String _secondary; + private String _tertiary; + private boolean _bold; + + public ScrollAnimation(String input) + { + _input = input; + _primary = ChatColor.WHITE.toString(); + _secondary = _primary; + _tertiary = _primary; + } + + public ScrollAnimation withPrimaryColour(ChatColor colour) + { + _primary = colour.toString(); + return this; + } + + public ScrollAnimation withSecondaryColour(ChatColor colour) + { + _secondary = colour.toString(); + return this; + } + + public ScrollAnimation withTertiaryColour(ChatColor colour) + { + _tertiary = colour.toString(); + return this; + } + + public ScrollAnimation bold() + { + _bold = true; + return this; + } + + public String[] build() + { + String[] output = new String[_input.length() * 2]; + String[] primaryRun = getFrames(_primary, _secondary); + String[] secondaryRun = getFrames(_secondary, _primary); + + System.arraycopy(primaryRun, 0, output, 0, _input.length()); + System.arraycopy(secondaryRun, 0, output, _input.length(), _input.length()); + + return output; + } + + private String[] getFrames(String primary, String secondary) + { + String[] output = new String[_input.length()]; + + for (int i = 0; i < _input.length(); i++) + { + StringBuilder builder = new StringBuilder(_input.length() * 3) + .append(primary) + .append(_bold ? C.Bold : ""); + + for (int j = 0; j < _input.length(); j++) + { + char c = _input.charAt(j); + + if (j == i) + { + builder.append(_tertiary).append(_bold ? C.Bold : ""); + } + else if (j == i + 1) + { + builder.append(secondary).append(_bold ? C.Bold : ""); + } + + builder.append(c); + } + + output[i] = builder.toString(); + } + + return output; + } + +} 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 078ed8369..501bc687a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -176,8 +176,9 @@ public class ServerGameMenu extends ShopPageBase add(24, Material.DIAMOND_CHESTPLATE, C.cYellowB + "Castle Siege " + C.cGray + "Team Game", new String[] { + (_extraValue ? C.cAquaB : C.cWhiteB) + "NEW UPDATES", C.Reset + "", - C.Reset + "Defenders must protect King Sparklez", + C.Reset + "Defenders must protect King Chiss", C.Reset + "from the endless waves of Undead", C.Reset + "until the sun rises!", }, "CS", "Castle_Siege", new SelectCSButton(this)); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java index 2ebe4cac2..82c07bae2 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java @@ -288,10 +288,13 @@ public class CustomDamageEvent extends Event implements Cancellable public void setDamagee(LivingEntity ent) { _damageeEntity = ent; - - _damageePlayer = null; - if (ent instanceof Player) - _damageePlayer = (Player)ent; + _damageePlayer = ent instanceof Player ? (Player) ent : null; + } + + public void setDamager(LivingEntity ent) + { + _damagerEntity = ent; + _damagerPlayer = ent instanceof Player ? (Player) ent : null; } public void changeReason(String initial, String reason) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 5366fd8f1..bd832a5a7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -2,7 +2,9 @@ package nautilus.game.arcade; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; +import java.util.List; import java.util.Set; import net.minecraft.server.v1_8_R3.EntityLiving; @@ -189,7 +191,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation BYPASS_WHITELIST, BYPASS_MPS_WHITELIST, } - + + private static final List TOURNAMENT_CONTROLLERS = Arrays.asList("Malfunction", "adeelzee", "gr8p", "HelloItsMeJack", "Aussi", "Jesusman3", "TyTy2017", "KingShook", "Sw1ck", "doodzee", "Chr1mz", "Giovanna", "xApolloJustice", "bawzee", "MessedUpLogic", "dehfi", "Geothermal", "captainfence", "Ecal", "Raydnn", "Otisdiver", "AussieFighter", "snevahmadaa", "eMoa", "Vilare", "xLouis", "PizzaMan319"); + // Modules private BlockRestore _blockRestore; private Blood _blood; @@ -1417,6 +1421,38 @@ public class ArcadeManager extends MiniPlugin implements IRelation event.SetCancelled(true); } } + + @EventHandler + public void tournamentStopGame(PlayerCommandPreprocessEvent event) + { + if (event.getMessage().trim().equalsIgnoreCase("/tstopgame") && TOURNAMENT_CONTROLLERS.contains(event.getPlayer().getName())) + { + event.setCancelled(true); + + if (GetGame() == null) + { + UtilPlayer.message(event.getPlayer(), F.main("Game", "There is no game to stop!")); + return; + } + + if (GetGame().GetState() == GameState.End || GetGame().GetState() == GameState.WinRoom) + { + UtilPlayer.message(event.getPlayer(), F.main("Game", "The game is already ending, it cannot be ended again")); + return; + } + else if (GetGame().GetState() == GameState.Recruit) + { + GetGame().SetState(GameState.Dead); + } + else + { + GetGame().SetState(GameState.End); + } + + HandlerList.unregisterAll(GetGame()); + GetGame().Announce(C.cAqua + C.Bold + event.getPlayer().getName() + " has stopped the game."); + } + } @EventHandler public void Observer(PlayerCommandPreprocessEvent event) @@ -2010,4 +2046,4 @@ public class ArcadeManager extends MiniPlugin implements IRelation { return _sheetsManager; } -} \ No newline at end of file +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index 80a5490f1..8eb7664ff 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -26,7 +26,7 @@ import nautilus.game.arcade.game.games.buildmavericks.BuildMavericks; import nautilus.game.arcade.game.games.cards.Cards; import nautilus.game.arcade.game.games.castleassault.CastleAssault; import nautilus.game.arcade.game.games.castleassault.CastleAssaultTDM; -import nautilus.game.arcade.game.games.castlesiege.CastleSiege; +import nautilus.game.arcade.game.games.castlesiegenew.CastleSiegeNew; import nautilus.game.arcade.game.games.champions.ChampionsCTF; import nautilus.game.arcade.game.games.champions.ChampionsDominate; import nautilus.game.arcade.game.games.champions.ChampionsTDM; @@ -138,7 +138,7 @@ public enum GameType Bridge(Bridge.class, GameDisplay.Bridge), CastleAssault(CastleAssault.class, GameDisplay.CastleAssault), CastleAssaultTDM(CastleAssaultTDM.class, GameDisplay.CastleAssaultTDM), - CastleSiege(CastleSiege.class, GameDisplay.CastleSiege), + CastleSiege(CastleSiegeNew.class, GameDisplay.CastleSiege), ChampionsCTF(ChampionsCTF.class, GameDisplay.ChampionsCTF), ChampionsDominate(ChampionsDominate.class, GameDisplay.ChampionsDominate), ChampionsTDM(ChampionsTDM.class, GameDisplay.ChampionsTDM), 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 b4c0aa265..bd7caafef 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 @@ -392,6 +392,9 @@ public abstract class Game extends ListenerComponent implements Lifetimed public int PlayersPerTeam = 2; public int TeamCount = 0; + // Split Kit XP + public boolean SplitKitXP = false; + private IPacketHandler _useEntityPacketHandler; private int _deadBodyCount; private NautHashMap _deadBodies = new NautHashMap(); @@ -855,8 +858,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed } UtilServer.getServer().getPluginManager().registerEvents(kit, Manager.getPlugin()); - System.out.println("Kit instance of " + String.valueOf(kit instanceof ProgressingKit)); - if (kit instanceof ProgressingKit) { ProgressingKit progressingKit = (ProgressingKit) kit; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java index 812652c44..3849c5354 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java @@ -37,7 +37,7 @@ public class GameTeam private String name; private ChatColor color; - private PlayerState(String name, ChatColor color) + PlayerState(String name, ChatColor color) { this.name = name; this.color = color; @@ -62,20 +62,20 @@ public class GameTeam private GameTutorial _tutorial; - private HashMap _players = new HashMap(); + private HashMap _players = new HashMap<>(); private ArrayList _spawns; private Creature _teamEntity = null; - private HashSet _kitRestrict = new HashSet(); + private HashSet _kitRestrict = new HashSet<>(); private boolean _visible = true; private boolean _displayTag; //Records order players go out in - protected ArrayList _places = new ArrayList(); + private ArrayList _places = new ArrayList<>(); private long _teamCreatedTime = System.currentTimeMillis(); // Used just for SpectatorPage so that teams remain ordered public GameTeam(Game host, String name, ChatColor color, ArrayList spawns, boolean tags) @@ -114,7 +114,7 @@ public class GameTeam return _spawns; } - public Location fixFacing(Location loc) + private Location fixFacing(Location loc) { if (Host.FixSpawnFacing) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index b8d2ea776..79a53146f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -191,6 +191,7 @@ public class CastleAssault extends TeamGame this.FirstKillReward = 20; this.GemKillDeathRespawn = 1; this.GameTimeout = -1; + this.SplitKitXP = true; new CompassModule() .setGiveCompass(true) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java deleted file mode 100644 index a5a67d2d0..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java +++ /dev/null @@ -1,973 +0,0 @@ -package nautilus.game.arcade.game.games.castlesiege; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.Effect; -import org.bukkit.EntityEffect; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.entity.Creature; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Horse; -import org.bukkit.entity.Horse.Style; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.player.PlayerEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.events.PlayerGameRespawnEvent; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.castlesiege.kits.KitHumanKnight; -import nautilus.game.arcade.game.games.castlesiege.kits.KitHumanMarksman; -import nautilus.game.arcade.game.games.castlesiege.kits.KitHumanPeasant; -import nautilus.game.arcade.game.games.castlesiege.kits.KitUndeadArcher; -import nautilus.game.arcade.game.games.castlesiege.kits.KitUndeadGhoul; -import nautilus.game.arcade.game.games.castlesiege.kits.KitUndeadZombie; -import nautilus.game.arcade.game.modules.compass.CompassModule; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.NullKit; -import nautilus.game.arcade.stats.BloodThirstyStatTracker; -import nautilus.game.arcade.stats.KingDamageStatTracker; -import nautilus.game.arcade.stats.KingSlayerStatTracker; -import nautilus.game.arcade.stats.TeamDeathsStatTracker; -import nautilus.game.arcade.stats.TeamKillsStatTracker; -import nautilus.game.arcade.stats.WinAsTeamStatTracker; - -public class CastleSiege extends TeamGame -{ - public static class KingDamageEvent extends PlayerEvent - { - private static final HandlerList handlers = new HandlerList(); - - public static HandlerList getHandlerList() - { - return handlers; - } - - @Override - public HandlerList getHandlers() - { - return getHandlerList(); - } - - private final double _damage; - - public KingDamageEvent(Player who, double damage) - { - super(who); - - _damage = damage; - } - - public double getDamage() - { - return _damage; - } - } - - public static class KingSlaughterEvent extends PlayerEvent - { - private static final HandlerList handlers = new HandlerList(); - - public static HandlerList getHandlerList() - { - return handlers; - } - - @Override - public HandlerList getHandlers() - { - return getHandlerList(); - } - - public KingSlaughterEvent(Player who) - { - super(who); - } - } - - private ArrayList _lastScoreboard = new ArrayList(); - - private long _tntSpawn = 0; - private ArrayList _tntSpawns = new ArrayList(); - private ArrayList _tntWeakness = new ArrayList(); - - private HashMap _tntCarry = new HashMap(); - private HashSet _tntCarryEnd = new HashSet(); - - private ArrayList _kingLocs; - private Creature _king; - private Location _kingLoc; - private String _kingName; - private Player _kingDamager = null; - private int _kingHealth = 40; - - private ArrayList _peasantSpawns; - private ArrayList _horseSpawns; - - public CastleSiege(ArcadeManager manager) - { - super(manager, GameType.CastleSiege, - - new Kit[] - { - new KitHumanMarksman(manager), - new KitHumanKnight(manager), - //new KitHumanBrawler(manager), - //new KitHumanAssassin(manager), - new NullKit(manager), - new KitHumanPeasant(manager), - new NullKit(manager), - new KitUndeadGhoul(manager), - new KitUndeadArcher(manager), - new KitUndeadZombie(manager), - }, - - new String[] - { - F.elem(C.cAqua + "Defenders") + C.cWhite + " must defend the King.", - F.elem(C.cAqua + "Defenders") + C.cWhite + " win when the sun rises.", - F.elem(C.cAqua + "Defenders") + C.cWhite + " respawn as wolves.", - "", - F.elem(C.cRed + "Undead") + C.cWhite + " must kill the King.", - F.elem(C.cRed + "Undead") + C.cWhite + " lose when the sun rises.", - - }); - - _help = new String[] - { - "Marksmen are extremely important to defence!", - "It's recommended 50%+ of defence are Marksmen.", - "Use Barricades to block the Undeads path.", - "Use TNT to destroy weak points in walls.", - "Weak points are marked by cracked stone brick.", - "Undead can break fences with their axes.", - "Undead Archers must pick up arrows from the ground.", - - }; - - this.StrictAntiHack = true; - - this.HungerSet = 20; - this.DeathOut = false; - this.WorldTimeSet = 14000; //14000 - this.BlockPlaceAllow.add(85); - - _kingName = C.cYellow + C.Bold + "King Sparklez"; - - GameTeam notRedTeam = null; - for (GameTeam team : GetTeamList()) - { - if (team.GetColor() != ChatColor.RED) - { - notRedTeam = team; - break; - } - } - - registerStatTrackers( - new KingSlayerStatTracker(this), - new BloodThirstyStatTracker(this), - new KingDamageStatTracker(this), - - new TeamDeathsStatTracker(this), - new TeamKillsStatTracker(this) - ); - - registerChatStats( - Kills, - Deaths, - KDRatio, - BlankLine, - Assists, - DamageDealt, - DamageTaken - ); - - registerChatStats(); - - new CompassModule() - .setGiveCompass(true) - .setGiveCompassToSpecs(true) - .setGiveCompassToAlive(false) - .register(this); - } - - @Override - public void ParseData() - { - _tntSpawns = WorldData.GetDataLocs("RED"); - _tntWeakness = WorldData.GetDataLocs("BLACK"); - - _kingLocs = WorldData.GetDataLocs("YELLOW"); - - _peasantSpawns = WorldData.GetDataLocs("GREEN"); - _horseSpawns = WorldData.GetDataLocs("BROWN"); - } - - @Override - public void RestrictKits() - { - for (Kit kit : GetKits()) - { - for (GameTeam team : GetTeamList()) - { - if (team.GetColor() == ChatColor.RED) - { - if (kit.GetName().contains("Castle")) - team.GetRestrictedKits().add(kit); - - team.SetName("Undead"); - } - else - { - if (kit.GetName().contains("Undead")) - team.GetRestrictedKits().add(kit); - - team.SetRespawnTime(8); - - team.SetName("Defenders"); - } - } - } - } - - @EventHandler(priority = EventPriority.HIGH) - public void registerTeamTracker(GameStateChangeEvent event) - { - if (event.GetState() == GameState.Recruit) - { - GameTeam notRed = null; - - for (GameTeam team : GetTeamList()) - { - if (team.GetColor() == ChatColor.RED) - continue; - - notRed = team; - break; - } - - if (notRed != null) - { - registerStatTrackers(new WinAsTeamStatTracker(this, notRed, "ForTheKing")); - System.out.println("Successfully registered For the King StatTrak"); - } - } - } - - @EventHandler - public void MoveKits(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - return; - - for (int i = 0; i < WorldData.GetDataLocs("PINK").size() && i < 3; i++) - { - if (GetKits().length <= 5 + i) - continue; - - this.CreatureAllowOverride = true; - Entity ent = GetKits()[5 + i].SpawnEntity(WorldData.GetDataLocs("PINK").get(i)); - this.CreatureAllowOverride = false; - - Manager.GetLobby().addKitLocation(ent, GetKits()[5 + i], WorldData.GetDataLocs("PINK").get(i)); - } - } - - @EventHandler - public void HorseSpawn(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - return; - - for (Location loc : _horseSpawns) - { - this.CreatureAllowOverride = true; - Horse horse = loc.getWorld().spawn(loc, Horse.class); - this.CreatureAllowOverride = false; - - horse.setAdult(); - horse.setAgeLock(true); - horse.setColor(org.bukkit.entity.Horse.Color.BLACK); - horse.setStyle(Style.BLACK_DOTS); - horse.setMaxDomestication(1); - horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); - horse.getInventory().setArmor(new ItemStack(Material.IRON_BARDING)); - - horse.setMaxHealth(60); - horse.setHealth(horse.getMaxHealth()); - - horse.setCustomName("War Horse"); - } - } - - @EventHandler - public void HorseInteract(PlayerInteractEntityEvent event) - { - if (!(event.getRightClicked() instanceof Horse)) - return; - - Player player = event.getPlayer(); - GameTeam team = GetTeam(player); - - if (team == null || team.GetColor() == ChatColor.RED || !IsAlive(player)) - { - event.setCancelled(true); - } - } - - @EventHandler - public void HorseDamageCancel(CustomDamageEvent event) - { - if (!(event.GetDamageeEntity() instanceof Horse)) - return; - - Player player = event.GetDamagerPlayer(true); - if (player == null) - return; - - if (!IsAlive(player)) - return; - - if (GetTeam(player) == null) - return; - - if (GetTeam(player).GetColor() == ChatColor.RED) - return; - - event.SetCancelled("Horse Team Damage"); - } - - @EventHandler(priority = EventPriority.HIGH) - public void GameStateChange(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - return; - - //Spawn King - this.CreatureAllowOverride = true; - - _kingLoc = _kingLocs.get(UtilMath.r(_kingLocs.size())); - - _king = (Creature) _kingLoc.getWorld().spawnEntity(_kingLoc, EntityType.ZOMBIE); - - _king.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); - _king.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); - _king.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); - _king.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); - _king.getEquipment().setItemInHand(new ItemStack(Material.DIAMOND_SWORD)); - - _king.setCustomName(_kingName); - _king.setCustomNameVisible(true); - - _king.setRemoveWhenFarAway(false); - - this.CreatureAllowOverride = false; - } - - @EventHandler(priority = EventPriority.HIGH) - public void SetDefenderRespawn(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - return; - - //Change to Peasant Spawns - this.GetTeam(ChatColor.AQUA).SetSpawns(_peasantSpawns); - } - - - @EventHandler - public void KingTarget(EntityTargetEvent event) - { - event.setCancelled(true); - } - - @EventHandler - public void KingDamage(CustomDamageEvent event) - { - if (_king == null || !_king.isValid()) - return; - - if (!event.GetDamageeEntity().equals(_king)) - return; - - event.SetCancelled("King Damage"); - - Player damager = event.GetDamagerPlayer(true); - if (damager == null) return; - - GameTeam team = GetTeam(damager); - - if (team != null && team.GetColor() == ChatColor.RED) - { - if (!Recharge.Instance.use(damager, "Damage King", 400, false, false)) - return; - - if (!IsAlive(damager)) - { - return; - } - - _king.playEffect(EntityEffect.HURT); - - _kingDamager = damager; - _kingHealth--; - - Bukkit.getPluginManager().callEvent(new KingDamageEvent(damager, 1)); - - if (_kingHealth < 0) - _kingHealth = 0; - - WriteScoreboard(); - - if (_kingHealth <= 0) - _king.damage(500); - - EndCheck(); - } - } - - @EventHandler - public void KingUpdate(UpdateEvent event) - { - if (GetState() != GameState.Live) - return; - - if (event.getType() != UpdateType.SEC) - return; - - if (_king == null) - return; - - if (UtilMath.offset(_king.getLocation(), _kingLoc) > 6) - { - _king.teleport(_kingLoc); - } - else - { - UtilEnt.CreatureMove(_king, _kingLoc, 1f); - } - } - - @EventHandler - public void PlayerDeath(PlayerGameRespawnEvent event) - { - if (GetTeam(ChatColor.AQUA).HasPlayer(event.GetPlayer())) - SetKit(event.GetPlayer(), GetKits()[3], true); - } - - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - WriteScoreboard(); - } - - public void WriteScoreboard() - { - //Get Values - HashMap _scoreGroup = new HashMap(); - _scoreGroup.put(C.cAqua + "Defenders", 0); - _scoreGroup.put(C.cDAqua + "Wolves", 0); - _scoreGroup.put(C.cRed + "Undead", 0); - - for (Player player : UtilServer.getPlayers()) - { - if (!IsAlive(player)) - continue; - - Kit kit = GetKit(player); - if (kit == null) continue; - - if (kit.GetName().contains("Castle")) - { - if (kit.GetName().contains("Wolf")) - { - _scoreGroup.put(C.cDAqua + "Wolves", 1 + _scoreGroup.get(C.cDAqua + "Wolves")); - } - else - { - _scoreGroup.put(C.cAqua + "Defenders", 1 + _scoreGroup.get(C.cAqua + "Defenders")); - } - } - else if (kit.GetName().contains("Undead")) - { - _scoreGroup.put(C.cRed + "Undead", 1 + _scoreGroup.get(C.cRed + "Undead")); - } - } - - //Wipe Last - Scoreboard.reset(); - - //Teams - for (String group : _scoreGroup.keySet()) - { - Scoreboard.writeNewLine(); - Scoreboard.write(group); - Scoreboard.write(ChatColor.getLastColors(group) + _scoreGroup.get(group) + " Players"); - } - - //King - if (_king != null && _king.isValid()) - { - Scoreboard.writeNewLine(); - Scoreboard.write(C.cYellow + C.Bold + "King"); - Scoreboard.write(_kingHealth + " Health"); - } - - long timeLeft = 24000 - WorldTimeSet; - timeLeft = timeLeft / 20 * 1000; - - - if (timeLeft > 0) - { - Scoreboard.writeNewLine(); - Scoreboard.write(C.cYellow + C.Bold + "Sun Rise"); - Scoreboard.write(UtilTime.MakeStr(timeLeft, 0)); - } - else - { - Scoreboard.writeNewLine(); - Scoreboard.write(C.cYellow + C.Bold + "Sun Rise"); - Scoreboard.write("Undead Burning!"); - - for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) - Manager.GetCondition().Factory().Ignite("Sun Damage", player, player, 5, false, false); - } - - Scoreboard.draw(); - } - - @Override - public void EndCheck() - { - if (!IsLive()) - return; - - if (this.WorldTimeSet > 24100 || GetTeam(ChatColor.RED).GetSize() == 0) - { - SetCustomWinLine(_kingName + ChatColor.RESET + " has survived the siege!"); - - AnnounceEnd(GetTeam(ChatColor.AQUA)); - - for (GameTeam team : GetTeamList()) - { - if (WinnerTeam != null && team.equals(WinnerTeam)) - { - for (Player player : team.GetPlayers(false)) - { - AddGems(player, 10, "Winning Team", false, false); - } - } - - for (Player player : team.GetPlayers(false)) - if (player.isOnline()) - AddGems(player, 10, "Participation", false, false); - } - - SetState(GameState.End); - } - - if (!_king.isValid() || GetTeam(ChatColor.AQUA).GetSize() == 0) - { - if (_kingDamager != null) - { - SetCustomWinLine(C.cRed + _kingDamager.getName() + C.cWhite + " slaughtered " + _kingName + ChatColor.RESET + "!"); - AddGems(_kingDamager, 20, "King Slayer", false, false); - - Bukkit.getPluginManager().callEvent(new KingSlaughterEvent(_kingDamager)); - } - else - SetCustomWinLine(_kingName + ChatColor.RESET + " has died!"); - - AnnounceEnd(GetTeam(ChatColor.RED)); - - for (GameTeam team : GetTeamList()) - { - if (WinnerTeam != null && team.equals(WinnerTeam)) - { - for (Player player : team.GetPlayers(false)) - { - AddGems(player, 10, "Winning Team", false, false); - } - } - - for (Player player : team.GetPlayers(false)) - if (player.isOnline()) - AddGems(player, 10, "Participation", false, false); - } - - SetState(GameState.End); - } - } - - @EventHandler - public void TNTSpawn(UpdateEvent event) - { - if (GetState() != GameState.Live) - return; - - if (event.getType() != UpdateType.SEC) - return; - - if (!UtilTime.elapsed(this.GetStateTime(), 20000)) - return; - - if (!UtilTime.elapsed(_tntSpawn, 25000)) - return; - - if (_tntSpawns.isEmpty()) - return; - - Location loc = _tntSpawns.get(UtilMath.r(_tntSpawns.size())); - - if (loc.getBlock().getTypeId() == 46) - return; - - loc.getBlock().setTypeId(46); - _tntSpawn = System.currentTimeMillis(); - } - - @EventHandler(priority = EventPriority.LOW) - public void TNTPickup(PlayerInteractEvent event) - { - if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) - return; - - if (event.getClickedBlock().getTypeId() != 46) - return; - - event.setCancelled(true); - - Player player = event.getPlayer(); - - if (!IsAlive(player)) - return; - - if (!GetTeam(ChatColor.RED).HasPlayer(player)) - return; - - if (_tntCarry.containsKey(player)) - return; - - event.getClickedBlock().setTypeId(0); - - FallingBlock tnt = player.getWorld().spawnFallingBlock(player.getEyeLocation(), 46, (byte) 0); - - player.eject(); - player.setPassenger(tnt); - - _tntCarry.put(player, tnt); - - UtilPlayer.message(player, F.main("Game", "You picked up " + F.skill("TNT") + ".")); - UtilPlayer.message(player, F.main("Game", F.elem("Right-Click") + " to detonate yourself.")); - } - - @EventHandler(priority = EventPriority.NORMAL) - public void TNTUse(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) - return; - - Player player = event.getPlayer(); - - if (!_tntCarry.containsKey(player)) - return; - - event.setCancelled(true); - - for (Location loc : _tntSpawns) - { - if (UtilMath.offset(player.getLocation(), loc) < 16) - { - UtilPlayer.message(player, F.main("Game", "You cannot " + F.skill("Detonate") + " so far from the Castle.")); - return; - } - } - - _tntCarry.remove(player).remove(); - - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); - tnt.setFuseTicks(0); - UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void TNTDeath(PlayerDeathEvent event) - { - Player player = event.getEntity(); - - if (!_tntCarry.containsKey(player)) - return; - - //Remove the TNT - _tntCarry.get(player).remove(); - - //Flag for Removal - _tntCarryEnd.add(player); - - - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); - tnt.setFuseTicks(0); - UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void TNTDamageDivert(ProjectileHitEvent event) - { - Iterator playerIterator = _tntCarry.keySet().iterator(); - - while (playerIterator.hasNext()) - { - Player player = playerIterator.next(); - - if (player.getPassenger() == null) - continue; - - double dist = UtilMath.offset(player.getPassenger().getLocation(), event.getEntity().getLocation().add(event.getEntity().getVelocity())); - - if (dist < 2) - { - int damage = (int) (5 * (event.getEntity().getVelocity().length() / 3d)); - - //Damage Event - Manager.GetDamage().NewDamageEvent(player, (LivingEntity)event.getEntity().getShooter(), event.getEntity(), - DamageCause.CUSTOM, damage, true, false, false, - null, GetName()); - - event.getEntity().remove(); - } - - if (_tntCarryEnd.contains(player)) - { - playerIterator.remove(); - } - } - - _tntCarryEnd.clear(); - } - - - @EventHandler - public void TNTExpire(UpdateEvent event) - { - if (event.getType() != UpdateType.FASTER) - return; - - Iterator tntIterator = _tntCarry.keySet().iterator(); - - while (tntIterator.hasNext()) - { - Player player = tntIterator.next(); - FallingBlock block = _tntCarry.get(player); - - if (player.isDead() || !block.isValid() || block.getTicksLived() > 1500) - { - player.eject(); - block.remove(); - - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); - tnt.setFuseTicks(0); - - tntIterator.remove(); - continue; - } - - //Firework - UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false); - } - } - - @EventHandler - public void TNTWeakness(ExplosionPrimeEvent event) - { - Location weakness = null; - for (Location loc : _tntWeakness) - { - if (UtilMath.offset(loc, event.getEntity().getLocation()) < 4) - { - weakness = loc; - break; - } - } - - if (weakness == null) - return; - - _tntWeakness.remove(weakness); - - final Location extra = weakness; - - for (int i = 0; i < 10; i++) - { - Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() - { - public void run() - { - TNTPrimed tnt = extra.getWorld().spawn(extra.clone().add(3 - UtilMath.r(6), 5 + UtilMath.r(2), 3 - UtilMath.r(6)), TNTPrimed.class); - tnt.setFuseTicks(0); - tnt.setIsIncendiary(true); - } - }, i * 3); - } - - weakness.getWorld().playSound(weakness, Sound.EXPLODE, 16f, 0.8f); - } - - @EventHandler(priority = EventPriority.HIGH) - public void AttackerBlockBreak(org.bukkit.event.block.BlockBreakEvent event) - { - GameTeam team = GetTeam(event.getPlayer()); - if (team == null) - return; - - if (team.GetColor() != ChatColor.RED) - return; - - if (event.getBlock().getTypeId() == 85) - event.setCancelled(false); - } - - @EventHandler - public void DefenderBlockPlace(org.bukkit.event.block.BlockPlaceEvent event) - { - GameTeam team = GetTeam(event.getPlayer()); - if (team == null) - return; - - if (team.GetColor() != ChatColor.AQUA) - return; - - if (event.getBlock().getTypeId() != 85) - return; - - for (Block block : UtilBlock.getSurrounding(event.getBlock(), false)) - { - if (block.isLiquid()) - { - event.setCancelled(true); - UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Barricade") + " in water.")); - } - } - - if (event.getBlockAgainst().getTypeId() == 85) - { - event.setCancelled(true); - UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Barricade") + " on each other.")); - } - - if (_king != null && UtilMath.offset(_king.getLocation(), event.getBlock().getLocation().add(0.5, 0.5, 0.5)) < 4) - { - event.setCancelled(true); - UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Barricade") + " near " + F.elem(C.cAqua + _kingName) + ".")); - } - } - - @EventHandler - public void DefenderBlockInteract(PlayerInteractEvent event) - { - if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) - return; - - GameTeam team = GetTeam(event.getPlayer()); - if (team == null) - return; - - if (team.GetColor() != ChatColor.AQUA) - return; - - if (event.getClickedBlock() == null || event.getClickedBlock().getTypeId() != 85) - return; - - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, event.getClickedBlock().getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, - ViewDist.LONG, UtilServer.getPlayers()); - event.getClickedBlock().getWorld().playSound(event.getClickedBlock().getLocation(), Sound.NOTE_STICKS, 2f, 1f); - Manager.GetBlockRestore().add(event.getClickedBlock(), 0, (byte) 0, 1000); - } - - @EventHandler - public void DayTimer(UpdateEvent event) - { - if (GetState() != GameState.Live) - return; - - if (event.getType() != UpdateType.TICK) - return; - - WorldTimeSet = (WorldTimeSet + 1); - } - - @EventHandler - public void SnowDamage(UpdateEvent event) - { - if (GetState() != GameState.Live) - return; - - if (event.getType() != UpdateType.FAST) - return; - - for (Player player : GetPlayers(true)) - if (player.getLocation().getBlock().getTypeId() == 78) - { - //Damage Event - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.DROWNING, 2, false, true, false, - "Snow", "Snow Damage"); - - player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, 80); - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHuman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHuman.java deleted file mode 100644 index 6c4da8994..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHuman.java +++ /dev/null @@ -1,18 +0,0 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; - -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; -import org.bukkit.entity.EntityType; -import org.bukkit.inventory.ItemStack; - -public abstract class KitHuman extends ProgressingKit -{ - public KitHuman(ArcadeManager manager, String name, KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand) - { - super(manager, name, name.toLowerCase().replace(" ", ""), kitAvailability, kitDesc, kitPerks, entityType, itemInHand); - } - - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanKnight.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanKnight.java deleted file mode 100644 index ec8a3ddbc..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanKnight.java +++ /dev/null @@ -1,94 +0,0 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkConstructor; -import nautilus.game.arcade.kit.perks.PerkMammoth; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.inventory.ItemStack; - -public class KitHumanKnight extends KitHuman -{ - - private static final String[] DESCRIPTION = { - "Robust knight, also able to construct defenses.", - " ", - receiveItem("oak fence", 1, 40, 2), - "Take " + C.cGreen + "75%" + C.cWhite + " knockback", - "Deal " + C.cGreen + "125%" + C.cWhite + " knockback", - }; - - private static final Perk[] PERKS = { - new PerkMammoth(), - new PerkConstructor("Constructor", 40, 2, Material.FENCE, "Castle Barricade", true) - }; - - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD), - ItemStackFactory.Instance.CreateStack(Material.BOW), - ItemStackFactory.Instance.CreateStack(Material.ARROW, 64), - ItemStackFactory.Instance.CreateStack(Material.FENCE, (byte) 0, 2, F.item("Castle Barricade")), - ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP), - ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP), - ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP), - ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP) - }; - - private static final ItemStack[] ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.IRON_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.IRON_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.IRON_CHESTPLATE), - ItemStackFactory.Instance.CreateStack(Material.IRON_HELMET) - }; - - public static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD); - - public KitHumanKnight(ArcadeManager manager) - { - super(manager, "Castle Knight", KitAvailability.Gem, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); - } - - @EventHandler - public void FireItemResist(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - if (Manager.GetGame() == null) - return; - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!HasKit(player)) - continue; - - Manager.GetCondition().Factory().FireItemImmunity(GetName(), player, player, 1.9, false); - } - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(PLAYER_ITEMS); - player.getInventory().setArmorContents(ARMOR); - } - - @Override - public void SpawnCustom(LivingEntity ent) - { - ent.getEquipment().setHelmet(new ItemStack(Material.IRON_HELMET)); - ent.getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); - ent.getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); - ent.getEquipment().setBoots(new ItemStack(Material.IRON_BOOTS)); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanMarksman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanMarksman.java deleted file mode 100644 index fcd021465..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanMarksman.java +++ /dev/null @@ -1,96 +0,0 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; - -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkFletcher; - -public class KitHumanMarksman extends KitHuman -{ - - private static final String[] DESCRIPTION = { - "Skilled human marksman, can fletch arrows.", - " ", - receiveArrowString(1, 2, 4), - "Charge your Bow to use " + C.cGreen + "Barrage" - }; - - private static final Perk[] PERKS = { - new PerkBarrage(5, 250, true, false), - new PerkFletcher(2, 4, false), - }; - - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD), - ItemStackFactory.Instance.CreateStack(Material.BOW), - ItemStackFactory.Instance.CreateStack(Material.ARROW, 32), - ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP), - ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP) - }; - - private static final ItemStack[] ARMOR = { - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), - ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET) - }; - - public static final ItemStack IN_HAND = new ItemStack(Material.BOW); - - public KitHumanMarksman(ArcadeManager manager) - { - super(manager, "Castle Marksman", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); - } - - @EventHandler - public void FireItemResist(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - { - return; - } - - if (Manager.GetGame() == null) - { - return; - } - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!HasKit(player)) - { - continue; - } - - Manager.GetCondition().Factory().FireItemImmunity(GetName(), player, player, 1.9, false); - } - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(PLAYER_ITEMS); - player.getInventory().setArmorContents(ARMOR); - } - - @Override - public void SpawnCustom(LivingEntity ent) - { - ent.getEquipment().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET)); - ent.getEquipment().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE)); - ent.getEquipment().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS)); - ent.getEquipment().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS)); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanPeasant.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanPeasant.java deleted file mode 100644 index c1ec3e24f..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanPeasant.java +++ /dev/null @@ -1,77 +0,0 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; - -import mineplex.core.disguise.disguises.DisguiseWolf; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkKnockbackGive; -import nautilus.game.arcade.kit.perks.PerkStrength; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.inventory.ItemStack; - -public class KitHumanPeasant extends KitHuman -{ - - private static final String[] DESCRIPTION = { - "OINK! OINK!" - }; - - private static final Perk[] PERKS = { - new PerkStrength(1), - new PerkKnockbackGive(2) - }; - - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.BONE, (byte) 0, 0, "Wolf Bite") - }; - - public static final ItemStack IN_HAND = new ItemStack(Material.IRON_HOE); - - public KitHumanPeasant(ArcadeManager manager) - { - super(manager, "Castle Wolf", KitAvailability.Hide, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); - } - - @EventHandler - public void FireItemResist(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - { - return; - } - - if (Manager.GetGame() == null) - { - return; - } - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!HasKit(player)) - { - continue; - } - - Manager.GetCondition().Factory().FireItemImmunity(GetName(), player, player, 1.9, false); - } - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(PLAYER_ITEMS); - - player.setHealth(4); - - DisguiseWolf disguise = new DisguiseWolf(player); - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndead.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndead.java deleted file mode 100644 index 31db5ed38..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndead.java +++ /dev/null @@ -1,21 +0,0 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; - -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.ProgressingKit; -import org.bukkit.entity.EntityType; -import org.bukkit.inventory.ItemStack; - -public abstract class KitUndead extends ProgressingKit -{ - public KitUndead(ArcadeManager manager, String name, KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand) - { - super(manager, name, name.toLowerCase().replace(" ", ""), kitAvailability, kitDesc, kitPerks, entityType, itemInHand); - } - - public KitUndead(ArcadeManager manager, String name, KitAvailability kitAvailability, int cost, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand) - { - super(manager, name, name.toLowerCase().replace(" ", ""), kitAvailability, cost, kitDesc, kitPerks, entityType, itemInHand); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadArcher.java deleted file mode 100644 index ebdefc25a..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadArcher.java +++ /dev/null @@ -1,74 +0,0 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilInv; -import mineplex.core.disguise.disguises.DisguiseSkeleton; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkIronSkin; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.inventory.ItemStack; - -public class KitUndeadArcher extends KitUndead -{ - - private static final String[] DESCRIPTION = { - "Makes use of arrows scavenged from human archers.", - " ", - "Take " + C.cGreen + "-1" + C.cWhite + " damage from attacks" - }; - - private static final Perk[] PERKS = { - new PerkIronSkin(1) - }; - - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.STONE_AXE), - ItemStackFactory.Instance.CreateStack(Material.BOW) - }; - - public static final ItemStack IN_HAND = new ItemStack(Material.BOW); - - public KitUndeadArcher(ArcadeManager manager) - { - super(manager, "Undead Archer", KitAvailability.Gem, DESCRIPTION, PERKS, EntityType.SKELETON, IN_HAND); - - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(PLAYER_ITEMS); - - DisguiseSkeleton disguise = new DisguiseSkeleton(player); - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } - - @EventHandler - public void ArrowPickup(PlayerPickupItemEvent event) - { - if (event.getItem().getItemStack().getType() != Material.ARROW) - return; - - if (!HasKit(event.getPlayer())) - return; - - if (UtilInv.contains(event.getPlayer(), Material.ARROW, (byte)0, 4)) - return; - - event.getItem().remove(); - - event.getPlayer().getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.ARROW)); - - event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ITEM_PICKUP, 1f, 1f); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadGhoul.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadGhoul.java deleted file mode 100644 index 1c893a7a6..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadGhoul.java +++ /dev/null @@ -1,67 +0,0 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; - -import mineplex.core.common.util.C; -import mineplex.core.disguise.disguises.DisguisePigZombie; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkLeap; -import nautilus.game.arcade.kit.perks.PerkSpeed; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.inventory.ItemStack; - -public class KitUndeadGhoul extends KitUndead -{ - - private static final String[] DESCRIPTION = { - "Weak, but able to jump around with ease.", - " ", - click(false, "your axe to use " + C.cGreen + "Ghoul Leap"), - }; - - private static final Perk[] PERKS = { - new PerkLeap("Ghoul Leap", 1.2, 0.8, 8000), - new PerkSpeed(0) - }; - - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.STONE_AXE), - }; - - public static final ItemStack IN_HAND = new ItemStack(Material.STONE_AXE); - - public KitUndeadGhoul(ArcadeManager manager) - { - super(manager, "Undead Ghoul", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.PIG_ZOMBIE, IN_HAND); - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(PLAYER_ITEMS); - - DisguisePigZombie disguise = new DisguisePigZombie(player); - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - disguise.setCustomNameVisible(true); - Manager.GetDisguise().disguise(disguise); - } - - @EventHandler - public void PickupArrow(PlayerPickupItemEvent event) - { - if (!HasKit(event.getPlayer())) - { - return; - } - - if (event.getItem().getItemStack().getType() == Material.ARROW) - { - event.setCancelled(true); - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadZombie.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadZombie.java deleted file mode 100644 index 9d9eb4b75..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadZombie.java +++ /dev/null @@ -1,67 +0,0 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; - -import mineplex.core.common.util.C; -import mineplex.core.disguise.disguises.DisguiseZombie; -import mineplex.core.itemstack.ItemStackFactory; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkRegeneration; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.inventory.ItemStack; - -public class KitUndeadZombie extends KitUndead -{ - - private static final String[] DESCRIPTION = { - "Regenerates rapidly", - " ", - "Receive " + C.cGreen + "Regeneration III" - }; - - private static final Perk[] PERKS = { - new PerkRegeneration(2) - }; - - private static final ItemStack[] PLAYER_ITEMS = { - ItemStackFactory.Instance.CreateStack(Material.STONE_AXE), - }; - - public static final ItemStack IN_HAND = new ItemStack(Material.STONE_AXE); - - public KitUndeadZombie(ArcadeManager manager) - { - super(manager, "Undead Zombie", KitAvailability.Gem, 5000, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); - - } - - @Override - public void GiveItems(Player player) - { - player.getInventory().addItem(PLAYER_ITEMS); - - DisguiseZombie disguise = new DisguiseZombie(player); - - if (Manager.GetGame().GetTeam(player) != null) - { - disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); - disguise.setCustomNameVisible(true); - } - - Manager.GetDisguise().disguise(disguise); - } - - @EventHandler - public void PickupArrow(PlayerPickupItemEvent event) - { - if (!HasKit(event.getPlayer())) - return; - - if (event.getItem().getItemStack().getType() == Material.ARROW) - event.setCancelled(true); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeHorseManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeHorseManager.java new file mode 100644 index 000000000..a1ba93f08 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeHorseManager.java @@ -0,0 +1,136 @@ +package nautilus.game.arcade.game.games.castlesiegenew; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Horse.Style; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.inventory.ItemStack; + +public class CastleSiegeHorseManager implements Listener +{ + + private static final int MAX_HEALTH = 60; + private static final ItemStack SADDLE = new ItemStack(Material.SADDLE); + private static final ItemStack ARMOUR = new ItemStack(Material.IRON_BARDING); + + private final CastleSiegeNew _host; + + CastleSiegeHorseManager(CastleSiegeNew host) + { + _host = host; + } + + @EventHandler + public void horseSpawn(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + _host.CreatureAllowOverride = true; + + for (Location location : _host.WorldData.GetDataLocs("BROWN")) + { + Horse horse = location.getWorld().spawn(location, Horse.class); + + horse.setColor(Horse.Color.BLACK); + horse.setStyle(Style.BLACK_DOTS); + horse.setMaxDomestication(1); + horse.getInventory().setSaddle(SADDLE); + horse.getInventory().setArmor(ARMOUR); + + horse.setMaxHealth(MAX_HEALTH); + horse.setHealth(MAX_HEALTH); + + horse.setCustomName("War Horse"); + } + + _host.CreatureAllowOverride = false; + } + + @EventHandler + public void horseInteract(PlayerInteractEntityEvent event) + { + if (!(event.getRightClicked() instanceof Horse) || !_host.IsLive()) + { + return; + } + + Player player = event.getPlayer(); + + if (UtilPlayer.isSpectator(player) || !_host.getDefenders().HasPlayer(player)) + { + player.sendMessage(F.main("Game", "You cannot mount horses.")); + event.setCancelled(true); + } + else + { + ((Horse) event.getRightClicked()).setOwner(player); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void horseDamage(CustomDamageEvent event) + { + if (event.isCancelled()) + { + return; + } + + LivingEntity entity = event.GetDamageeEntity(); + + if (!(entity instanceof Horse)) + { + return; + } + + Player damager = event.GetDamagerPlayer(true); + + if (damager == null || _host.getUndead().HasPlayer(damager)) + { + return; + } + + event.SetCancelled("Horse Team Damage"); + } + + @EventHandler + public void horseDeath(EntityDeathEvent event) + { + Entity entity = event.getEntity(); + + if (entity instanceof Horse) + { + Player killer = ((Horse) entity).getKiller(); + + if (killer != null) + { + _host.AddStat(killer, "HorseKiller", 1, false, false); + } + + event.setDroppedExp(0); + event.getDrops().clear(); + } + } + + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + event.getEntity().eject(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeKing.java new file mode 100644 index 000000000..1b75a96e1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeKing.java @@ -0,0 +1,212 @@ +package nautilus.game.arcade.game.games.castlesiegenew; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import org.bukkit.Effect; +import org.bukkit.EntityEffect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class CastleSiegeKing implements Listener +{ + + private static final int MAX_HEALTH = 40; + private static final int DAMAGE_RATE = 400; + private static final int KING_PROTECTION_RANGE_SQUARED = 4; + private static final int KING_FENCE_RANGE_SQUARED = 25; + private static final int KING_TELEPORT_RANGE_SQUARED = 36; + + private final CastleSiegeNew _host; + private Location _location; + private LivingEntity _entity; + + private final Map _damagers; + private Player _lastDamager; + + CastleSiegeKing(CastleSiegeNew host) + { + _host = host; + _damagers = new HashMap<>(); + } + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + _location = _host.WorldData.GetDataLocs("YELLOW").get(0); + spawnEntity(); + } + + private void spawnEntity() + { + _host.CreatureAllowOverride = true; + + boolean moppleOnline = UtilPlayer.searchExact("Moppletop") != null; + _entity = _location.getWorld().spawn(_location, Zombie.class); + UtilEnt.vegetate(_entity); + UtilEnt.silence(_entity, true); + _entity.setCustomName(moppleOnline ? C.cGreenB + "Queen Moppletop" : C.cYellowB + "King Chiss"); + _entity.setCustomNameVisible(true); + _entity.setRemoveWhenFarAway(false); + _entity.setMaxHealth(MAX_HEALTH); + _entity.setHealth(MAX_HEALTH); + + EntityEquipment equipment = _entity.getEquipment(); + + equipment.setItemInHand(new ItemStack(Material.DIAMOND_SWORD)); + equipment.setHelmet(new ItemStack(Material.DIAMOND_HELMET)); + equipment.setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); + equipment.setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); + equipment.setBoots(new ItemStack(Material.DIAMOND_BOOTS)); + + reset(); + + _host.CreatureAllowOverride = false; + } + + private void reset() + { + _entity.teleport(_location); + + List lookAts = _host.WorldData.GetDataLocs("ORANGE"); + if (!lookAts.isEmpty()) + { + UtilEnt.CreatureLook(_entity, lookAts.get(0)); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void entityDamage(CustomDamageEvent event) + { + if (event.isCancelled() || _entity == null || !_entity.equals(event.GetDamageeEntity())) + { + return; + } + + event.SetCancelled("King"); + + Player damager = event.GetDamagerPlayer(true); + + if (damager == null) + { + return; + } + + if (_host.getDefenders().HasPlayer(damager) || !Recharge.Instance.use(damager, "Damage King", DAMAGE_RATE, false, false)) + { + return; + } + + // Store the damager + _damagers.putIfAbsent(damager, 0); + _damagers.put(damager, _damagers.get(damager) + 1); + _lastDamager = damager; + + _entity.playEffect(EntityEffect.HURT); + _entity.getWorld().playEffect(_entity.getLocation().add(0, 0.5, 0), Effect.STEP_SOUND, Material.REDSTONE_BLOCK); + _entity.setHealth(_entity.getHealth() - 1); + } + + @EventHandler + public void updateMovement(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || _entity == null) + { + return; + } + + double dist = UtilMath.offsetSquared(_entity.getLocation(), _location); + + if (dist > KING_TELEPORT_RANGE_SQUARED) + { + reset(); + } + else if (dist > KING_PROTECTION_RANGE_SQUARED) + { + UtilEnt.CreatureMove(_entity, _location, 1); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void blockPlace(BlockPlaceEvent event) + { + if (_entity == null) + { + return; + } + + Player player = event.getPlayer(); + Block block = event.getBlock(); + + if (event.isCancelled()) + { + return; + } + + for (Block nearby : UtilBlock.getSurrounding(block, false)) + { + if (nearby.isLiquid()) + { + event.setCancelled(true); + player.sendMessage(F.main("Game", "You cannot place " + F.elem("Barricade") + " in water.")); + return; + } + else if (nearby.getType() == Material.VINE) + { + event.setCancelled(true); + player.sendMessage(F.main("Game", "You cannot place " + F.elem("Barricade") + " near vines.")); + return; + } + } + + if (UtilMath.offsetSquared(_entity.getLocation(), block.getLocation()) < KING_FENCE_RANGE_SQUARED) + { + event.setCancelled(true); + player.sendMessage(F.main("Game", "You cannot place " + F.elem("Barricade") + " near " + _entity.getCustomName() + C.mBody + ".")); + } + } + + public LivingEntity getEntity() + { + return _entity; + } + + public Map getDamagers() + { + return _damagers; + } + + public Player getLastDamager() + { + return _lastDamager; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeNew.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeNew.java new file mode 100644 index 000000000..f3c30678c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeNew.java @@ -0,0 +1,607 @@ +package nautilus.game.arcade.game.games.castlesiegenew; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import com.mineplex.anticheat.checks.combat.KillauraTypeD; + +import mineplex.core.Managers; +import mineplex.core.achievement.Achievement; +import mineplex.core.achievement.AchievementCategory; +import mineplex.core.antihack.AntiHack; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.condition.ConditionFactory; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.FirstBloodEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerGameRespawnEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.castlesiegenew.kits.KitHumanKnight; +import nautilus.game.arcade.game.games.castlesiegenew.kits.KitHumanMarksman; +import nautilus.game.arcade.game.games.castlesiegenew.kits.KitHumanPaladin; +import nautilus.game.arcade.game.games.castlesiegenew.kits.KitHumanWolf; +import nautilus.game.arcade.game.games.castlesiegenew.kits.KitUndeadArcher; +import nautilus.game.arcade.game.games.castlesiegenew.kits.KitUndeadGhoul; +import nautilus.game.arcade.game.games.castlesiegenew.kits.KitUndeadSummoner; +import nautilus.game.arcade.game.games.castlesiegenew.kits.KitUndeadZombie; +import nautilus.game.arcade.game.modules.SpawnShieldModule; +import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.NullKit; +import nautilus.game.arcade.stats.BloodThirstyStatTracker; +import nautilus.game.arcade.stats.TeamDeathsStatTracker; +import nautilus.game.arcade.stats.TeamKillsStatTracker; +import nautilus.game.arcade.stats.WinAsTeamStatTracker; + +public class CastleSiegeNew extends TeamGame +{ + + private static final String[] DESCRIPTION = { + C.cAqua + "Defenders" + C.cWhite + " must defend the King.", + C.cAqua + "Defenders" + C.cWhite + " win when the sun rises.", + C.cAqua + "Defenders" + C.cWhite + " respawn as wolves.", + "", + C.cRed + "Undead" + C.cWhite + " must kill the King.", + C.cRed + "Undead" + C.cWhite + " lose when the sun rises." + }; + private static final String[] TIPS = { + "TNT randomly spawns at 3 different locations outside the undead forest.", + "Right-click TNT to pick it up.", + "TNT will automatically explode 30 seconds after being picked up.", + "Undead respawn instantly.", + "Defenders can right-click a fence to pass through it.", + "Avoid retreating as Defenders.", + "Castle Marksmen are important to defense because of their arrows.", + "Defenders respawn as wolves with no armor or weapons.", + "Wolves must wait 6 seconds in between respawns.", + "Coordination and teamwork are important to winning as Defenders." + }; + private static final Achievement[] ACHIEVEMENTS = Achievement.getByCategory(AchievementCategory.CASTLE_SIEGE).toArray(new Achievement[0]); + public static Achievement[] getGameAchievements() + { + return ACHIEVEMENTS; + } + private static final int START_TIME = 14000; + private static final int UNDEAD_BURN_TIME = 24000; + private static final int DEFENDER_WIN_TIME = UNDEAD_BURN_TIME + 200; + private static final int WOLF_RESPAWN_TIME = 6; + private static final long FENCE_NO_CLIP_TIME = TimeUnit.SECONDS.toMillis(2); + private static final int MAX_ARROW_TICKS = 30 * 20; + + private final Set _listeners = new HashSet<>(); + + private GameTeam _defenders; + private GameTeam _undead; + private final Set _wolves = new HashSet<>(); + + private CastleSiegeKing _king; + + private List _kitNPCSpawns; + private ArrayList _wolfSpawns; + + private Kit _wolfKit; + + public CastleSiegeNew(ArcadeManager manager) + { + super(manager, GameType.CastleSiege, new Kit[] + { + new KitHumanWolf(manager), + new KitHumanMarksman(manager), + new KitHumanKnight(manager), + new KitHumanPaladin(manager), + new NullKit(manager), + new KitUndeadGhoul(manager), + new KitUndeadArcher(manager), + new KitUndeadZombie(manager), + new KitUndeadSummoner(manager) + + }, DESCRIPTION); + + _help = TIPS; + + StrictAntiHack = true; + HungerSet = 20; + DeathOut = false; + WorldTimeSet = START_TIME; + WorldSoilTrample = true; + BlockBreakAllow.add(Material.FENCE.getId()); + BlockPlaceAllow.add(Material.FENCE.getId()); + InventoryClick = true; + SplitKitXP = true; + + manager.GetCreature().SetDisableCustomDrops(true); + + registerStatTrackers( + new BloodThirstyStatTracker(this, "KingGuard", 5, player -> getDefenders().HasPlayer(player), player -> UtilMath.offsetSquared(player, getKing().getEntity()) < 8 * 8 && WorldTimeSet > UNDEAD_BURN_TIME - 60 * 20), + new BloodThirstyStatTracker(this, "WolfKill", 12, this::isWolf, player -> true), + new BloodThirstyStatTracker(this, "BloodThirsty", 50, player -> true, player -> GetTeam(player).equals(getUndead())), + new TeamKillsStatTracker(this), + new TeamDeathsStatTracker(this) + ); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageDealt, + DamageTaken + ); + + _king = new CastleSiegeKing(this); + _listeners.add(_king); + + _listeners.add(new CastleSiegeTNTManager(this)); + _listeners.add(new CastleSiegeHorseManager(this)); + + new CompassModule() + .register(this); + + // Disable specific GWEN checks for this game + AntiHack antiHack = Managers.get(AntiHack.class); + antiHack.addIgnoredCheck(KillauraTypeD.class); + } + + @Override + public void ParseData() + { + _defenders = GetTeam(ChatColor.AQUA); + _defenders.SetName("Defenders"); + _defenders.SetRespawnTime(WOLF_RESPAWN_TIME); + + _undead = GetTeam(ChatColor.RED); + _undead.SetName("Undead"); + + boolean undead = false; + + for (Kit kit : GetKits()) + { + if (kit instanceof NullKit) + { + undead = true; + } + else if (undead) + { + _defenders.GetRestrictedKits().add(kit); + } + else + { + _undead.GetRestrictedKits().add(kit); + } + } + + _kitNPCSpawns = WorldData.GetDataLocs("PINK"); + _wolfSpawns = WorldData.GetDataLocs("GREEN"); + + for (Kit kit : GetKits()) + { + if (kit.GetName().contains("Wolf")) + { + _wolfKit = kit; + break; + } + } + + _listeners.forEach(UtilServer::RegisterEvents); + + new SpawnShieldModule() + .registerShield(_wolves::contains, WorldData.GetCustomLocs("129"), UtilAlg.getAverageLocation(_wolfSpawns)) + .register(this); + } + + @EventHandler + @Override + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !InProgress()) + { + return; + } + + Scoreboard.writeNewLine(); + + Scoreboard.write(_defenders.GetFormattedName()); + Scoreboard.write((_defenders.GetPlayers(true).size() - _wolves.size()) + " Players"); + + Scoreboard.writeNewLine(); + + Scoreboard.write(C.cDAquaB + "Wolves"); + Scoreboard.write(_wolves.size() + " Players"); + + Scoreboard.writeNewLine(); + + Scoreboard.write(_undead.GetFormattedName()); + Scoreboard.write(_undead.GetPlayers(true).size() + " Players"); + + Scoreboard.writeNewLine(); + + Scoreboard.write(_king.getEntity().getCustomName()); + Scoreboard.write((int) _king.getEntity().getHealth() + " Health"); + + Scoreboard.writeNewLine(); + + // Convert ticks to milliseconds + int timeLeft = (UNDEAD_BURN_TIME - WorldTimeSet) * 50; + Scoreboard.write(C.cGoldB + "Sunrise"); + + if (timeLeft > 0) + { + Scoreboard.write(UtilTime.MakeStr(timeLeft)); + } + else + { + Scoreboard.write("Undead Burning!"); + } + + Scoreboard.draw(); + } + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + // Register Defender win tracker + registerStatTrackers(new WinAsTeamStatTracker(this, _defenders, "ForTheKing")); + + CreatureAllowOverride = true; + + // Move Kit NPCS + Location lookAt = UtilAlg.getAverageLocation(_undead.GetSpawns()); + int i = 0; + for (Kit kit : GetKits()) + { + if (kit instanceof NullKit || _undead.GetRestrictedKits().contains(kit) || _kitNPCSpawns.size() <= i) + { + continue; + } + + Location location = _kitNPCSpawns.get(i++); + Entity entity = kit.SpawnEntity(location); + UtilEnt.CreatureLook(entity, lookAt); + UtilEnt.addFlag(entity, UtilEnt.FLAG_ENTITY_COMPONENT); + + Manager.GetLobby().addKitLocation(entity, kit, location); + } + + CreatureAllowOverride = false; + } + + @EventHandler + public void advanceTime(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK || !IsLive()) + { + return; + } + + WorldTimeSet++; + } + + @EventHandler + public void burnUndead(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !IsLive()) + { + return; + } + + if (WorldTimeSet >= UNDEAD_BURN_TIME) + { + ConditionFactory factory = Manager.GetCondition().Factory(); + + for (Player player : _undead.GetPlayers(true)) + { + factory.Ignite("Sun Damage", player, null, 2, false, false); + } + } + } + + @EventHandler + public void setWolfSpawns(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + _defenders.SetSpawns(_wolfSpawns); + } + + @EventHandler + public void setWolfKit(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (Player player : GetPlayers(true)) + { + Kit kit = GetKit(player); + + if (kit instanceof KitHumanWolf) + { + SetKit(player, GetKits()[1], false); + } + } + } + + @EventHandler + public void setWolfKit(PlayerGameRespawnEvent event) + { + Player player = event.GetPlayer(); + + if (_defenders.HasPlayer(player) && _wolves.add(player)) + { + SetKit(player, _wolfKit, true); + } + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _wolves.remove(event.getPlayer()); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + { + return; + } + + LivingEntity king = _king.getEntity(); + + if (WorldTimeSet > DEFENDER_WIN_TIME || _undead.GetPlayers(true).isEmpty()) + { + // King at full health + if (king.getHealth() == king.getMaxHealth()) + { + _defenders.GetPlayers(true).forEach(player -> AddStat(player, "KingFull", 1, true, false)); + } + + SetCustomWinLine(king.getCustomName() + C.Reset + " has survived the siege!"); + AnnounceEnd(_defenders); + } + else if (king.isDead() || !king.isValid() || _defenders.GetPlayers(true).isEmpty()) + { + String winLine = king.getCustomName() + " " + C.Reset; + Map damagers = _king.getDamagers(); + + if (damagers.isEmpty()) + { + winLine += "has died!"; + } + else + { + Player mostDamager = null; + int mostDamage = 0; + + for (Entry entry : damagers.entrySet()) + { + if (mostDamager == null || mostDamage < entry.getValue()) + { + mostDamager = entry.getKey(); + mostDamage = entry.getValue(); + } + } + + // Not possible but keeps the IDE happy + if (mostDamager == null) + { + return; + } + + if (mostDamager.equals(_king.getLastDamager())) + { + winLine += "was slaughtered by " + _undead.GetColor() + mostDamager.getName(); + } + else + { + winLine += "was killed by " + _undead.GetColor() + _king.getLastDamager().getName() + C.Reset + " while " + _undead.GetColor() + mostDamager.getName() + C.Reset + " dealt most of the damage!"; + } + + // 50%+ damage to the king + if (mostDamage >= (king.getMaxHealth() - king.getHealth()) * 0.5) + { + AddStat(mostDamager, "Assassin", 1, true, false); + } + + // Player who killed the king + AddStat(_king.getLastDamager(), "KingSlayer", 1, true, false); + } + + if (WorldTimeSet > UNDEAD_BURN_TIME - 60 * 20) + { + _undead.GetPlayers(true).forEach(player -> AddStat(player, "CloseCall", 1, true, false)); + } + + SetCustomWinLine(winLine); + AnnounceEnd(_undead); + } + else + { + return; + } + + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { + for (Player player : team.GetPlayers(false)) + { + AddGems(player, 10, "Winning", false, false); + } + } + + for (Player player : team.GetPlayers(false)) + { + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + } + } + } + + SetState(GameState.End); + } + + @Override + public void disable() + { + super.disable(); + _wolves.clear(); + _listeners.forEach(UtilServer::Unregister); + _listeners.clear(); + } + + @EventHandler + public void allowNoClipFences(PlayerInteractEvent event) + { + Block block = event.getClickedBlock(); + + if (event.isCancelled() || block == null || block.getType() != Material.FENCE) + { + return; + } + + Player player = event.getPlayer(); + + if (UtilPlayer.isSpectator(player) || !_defenders.HasPlayer(player) || player.getItemInHand() != null && player.getItemInHand().getType() == Material.FENCE) + { + return; + } + + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, block.getLocation().add(0.5, 0.5, 0.5), 0.2F, 0.2F, 0.2F, 0.01F, 3, ViewDist.SHORT); + block.getWorld().playSound(block.getLocation(), Sound.NOTE_STICKS, 1, 1); + Manager.GetBlockRestore().add(block, Material.AIR.getId(), (byte) 0, FENCE_NO_CLIP_TIME); + } + + @EventHandler + public void removeFences(ItemSpawnEvent event) + { + if (event.getEntity().getItemStack().getType() == Material.FENCE) + { + event.setCancelled(true); + } + } + + @EventHandler + public void removeOldArrows(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + for (Entity entity : WorldData.World.getEntities()) + { + if (entity instanceof Arrow && entity.getTicksLived() > MAX_ARROW_TICKS) + { + entity.remove(); + } + } + } + + @EventHandler + public void pickupArrows(PlayerPickupItemEvent event) + { + if (event.getItem().getItemStack().getType() != Material.ARROW) + { + return; + } + + Kit kit = GetKit(event.getPlayer()); + + event.setCancelled(kit == null || !(kit instanceof KitUndeadArcher)); + } + + @EventHandler + public void firstBlood(FirstBloodEvent event) + { + AddStat(event.getPlayer(), "FirstBlood", 1, true, false); + } + + @EventHandler + public void handleResistance(CustomDamageEvent event) + { + Player damagee = event.GetDamageePlayer(); + + if (damagee == null) + { + return; + } + + for (PotionEffect effect : damagee.getActivePotionEffects()) + { + if (effect.getType().toString().equals(PotionEffectType.DAMAGE_RESISTANCE.toString())) + { + event.AddMod("Resistance", (effect.getAmplifier() + 1) * -0.2 * event.GetDamage()); + } + } + } + + public boolean isWolf(Player player) + { + return _wolves.contains(player); + } + + public CastleSiegeKing getKing() + { + return _king; + } + + public GameTeam getDefenders() + { + return _defenders; + } + + public GameTeam getUndead() + { + return _undead; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeTNTManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeTNTManager.java new file mode 100644 index 000000000..42559f753 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/CastleSiegeTNTManager.java @@ -0,0 +1,322 @@ +package nautilus.game.arcade.game.games.castlesiegenew; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; + +import org.bukkit.Color; +import org.bukkit.Effect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseLiving; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; + +public class CastleSiegeTNTManager implements Listener +{ + + private static final long SPAWN_TIME = TimeUnit.SECONDS.toMillis(25); + private static final ItemStack TNT_HELMET = new ItemStack(Material.TNT); + private static final int TOO_FAR_FROM_CASTLE_SQUARED = 256; + private static final int TNT_WEAKNESS_DISTANCE_SQUARED = 16; + private static final long TNT_MAX_TIME = TimeUnit.SECONDS.toMillis(30); + private static final long REGENERATION_TIME = TimeUnit.SECONDS.toMillis(15); + + private final CastleSiegeNew _host; + + private final Map _tntCarrier; + private List _tntSpawns; + private List _tntWeaknesses; + private long _lastTNT; + + CastleSiegeTNTManager(CastleSiegeNew host) + { + _host = host; + _tntCarrier = new HashMap<>(); + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + _lastTNT = System.currentTimeMillis(); + _tntSpawns = _host.WorldData.GetDataLocs("RED"); + _tntWeaknesses = _host.WorldData.GetDataLocs("BLACK"); + } + + @EventHandler + public void spawnTnt(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || !_host.IsLive() || !UtilTime.elapsed(_lastTNT, SPAWN_TIME)) + { + return; + } + + _lastTNT = System.currentTimeMillis(); + + Location location = UtilAlg.Random(_tntSpawns); + + if (location == null || location.getBlock().getType() == Material.TNT) + { + return; + } + + MapUtil.QuickChangeBlockAt(location, Material.TNT); + location.getWorld().playEffect(location.clone().add(0, 0.5, 0), Effect.STEP_SOUND, Material.TNT); + } + + @EventHandler(priority = EventPriority.LOW) + public void tntPickup(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + { + return; + } + + Player player = event.getPlayer(); + Block block = event.getClickedBlock(); + + if (block == null || block.getType() != Material.TNT || UtilPlayer.isSpectator(player) || !_host.getUndead().HasPlayer(player) || _tntCarrier.containsKey(player)) + { + return; + } + + event.setCancelled(true); + + DisguiseBase disguise = _host.getArcadeManager().GetDisguise().getActiveDisguise(player); + + if (disguise != null && disguise instanceof DisguiseLiving) + { + DisguiseLiving disguiseLiving = (DisguiseLiving) disguise; + player.getInventory().setHelmet(TNT_HELMET); + disguiseLiving.setHelmet(TNT_HELMET); + _host.getArcadeManager().GetDisguise().updateDisguise(disguiseLiving); + } + + MapUtil.QuickChangeBlockAt(block.getLocation(), Material.AIR); + + player.sendMessage(F.main("Game", "You picked up " + F.skill("TNT") + ".")); + player.sendMessage(F.main("Game", F.elem("Click") + " to " + F.skill("Detonate") + " yourself.")); + _tntCarrier.put(player, System.currentTimeMillis()); + } + + @EventHandler + public void tntDetonate(PlayerInteractEvent event) + { + if (event.isCancelled() || event.getAction() == Action.PHYSICAL) + { + return; + } + + Player player = event.getPlayer(); + + if (!_tntCarrier.containsKey(player)) + { + return; + } + + event.setCancelled(true); + detonate(player, true); + } + + @EventHandler + public void updateExpire(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK || !_host.IsLive()) + { + return; + } + + for (Entry entry : _tntCarrier.entrySet()) + { + long timeLeft = entry.getValue() + TNT_MAX_TIME - System.currentTimeMillis(); + double percentage = (double) (System.currentTimeMillis() - entry.getValue()) / (double) TNT_MAX_TIME; + + if (timeLeft < 0) + { + detonate(entry.getKey(), false); + continue; + } + + UtilTextBottom.displayProgress(C.Bold + "TNT Detonation", percentage, UtilTime.MakeStr(timeLeft), entry.getKey()); + } + } + + @EventHandler + public void updateFireworks(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + for (Player player : _tntCarrier.keySet()) + { + UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, true, false); + } + } + + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + Player killed = event.getEntity(); + Player killer = killed.getKiller(); + + if (killer != null && _tntCarrier.containsKey(killed)) + { + _host.AddStat(killer, "TNTKiller", 1, false, false); + } + + detonate(killed, false); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + detonate(event.getPlayer(), false); + } + + private void detonate(Player player, boolean triggered) + { + if (!_tntCarrier.containsKey(player) || !Recharge.Instance.use(player, "Prevent Double Detonation", 1000, false, false)) + { + return; + } + + Location playerLocation = player.getLocation(); + + for (Location location : _tntSpawns) + { + if (UtilMath.offsetSquared(location, playerLocation) < TOO_FAR_FROM_CASTLE_SQUARED) + { + if (triggered) + { + player.sendMessage(F.main("Game", "You cannot " + F.skill("Detonate") + " so far from the Castle.")); + } + else + { + _tntCarrier.remove(player); + player.getInventory().setHelmet(null); + } + + return; + } + } + + // Handle Weaknesses + for (Location location : _tntWeaknesses) + { + if (UtilMath.offsetSquared(playerLocation, location) < TNT_WEAKNESS_DISTANCE_SQUARED) + { + for (int i = 0; i < 10; i++) + { + UtilServer.runSyncLater(() -> + { + + TNTPrimed primed = player.getWorld().spawn(UtilAlg.getRandomLocation(location, 2, 2, 2), TNTPrimed.class); + primed.setFuseTicks(0); + primed.setIsIncendiary(true); + + }, i * 3); + } + break; + } + } + + _tntCarrier.remove(player); + + TNTPrimed primed = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + primed.setFuseTicks(0); + + player.sendMessage(F.main("Game", "You used " + F.skill("Detonate") + ".")); + _host.getArcadeManager().GetDamage().NewDamageEvent(player, null, null, DamageCause.BLOCK_EXPLOSION, 5000, false, true, true, player.getName(), "Explosion"); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void entityExplode(EntityExplodeEvent event) + { + BlockRestore restore = _host.getArcadeManager().GetBlockRestore(); + + int lowestY = Integer.MAX_VALUE; + + for (Block block : event.blockList()) + { + int y = block.getLocation().getBlockY(); + + if (y < lowestY) + { + lowestY = y; + } + } + + for (Block block : event.blockList()) + { + Material material = block.getType(); + byte materialData = block.getData(); + + if ( + material == Material.SMOOTH_BRICK && materialData == 2 || + material == Material.IRON_FENCE || + material == Material.FENCE + ) + { + continue; + } + + restore.add(block, Material.AIR.getId(), (byte) 0, (long) (REGENERATION_TIME + (block.getLocation().getBlockY() - lowestY) * 2000 + Math.random() * 1750)); + } + } + + @EventHandler + public void tntClick(InventoryClickEvent event) + { + Inventory inventory = event.getClickedInventory(); + ItemStack itemStack = event.getCurrentItem(); + + if (inventory != null && itemStack != null && itemStack.getType() == Material.TNT) + { + event.setCancelled(true); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitCastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitCastleSiege.java new file mode 100644 index 000000000..024978df7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitCastleSiege.java @@ -0,0 +1,94 @@ +package nautilus.game.arcade.game.games.castlesiegenew.kits; + +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.disguise.disguises.DisguiseInsentient; +import mineplex.core.disguise.disguises.DisguiseSkeleton; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.castlesiegenew.CastleSiegeNew; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.inventory.ItemStack; + +import java.lang.reflect.InvocationTargetException; + +public abstract class KitCastleSiege extends ProgressingKit +{ + + private static final ItemStack AXE = new ItemStack(Material.STONE_AXE); + private static final ItemStack AXE_5 = new ItemStack(Material.IRON_AXE); + protected static final String REPLACE_AXE = receiveItem("Iron Axe", 1); + + public KitCastleSiege(ArcadeManager manager, String name, KitAvailability kitAvailability, String[] kitDesc, Perk[][] kitPerks, String[][] upgrades, EntityType entityType, ItemStack itemInHand) + { + this(manager, name, kitAvailability, 0, kitDesc, kitPerks, upgrades, entityType, itemInHand); + } + + public KitCastleSiege(ArcadeManager manager, String name, KitAvailability kitAvailability, int cost, String[] kitDesc, Perk[][] kitPerks, String[][] upgrades, EntityType entityType, ItemStack itemInHand) + { + super(manager, name, name.toLowerCase().replace(" ", ""), kitAvailability, cost, kitDesc, kitPerks, upgrades, entityType, itemInHand); + } + + public void disguise(Player player, Class clazz) + { + DisguiseManager disguiseManager = Manager.GetDisguise(); + + try + { + DisguiseInsentient disguise = clazz.getConstructor(Entity.class).newInstance(player); + GameTeam gameTeam = Manager.GetGame().GetTeam(player); + + if (gameTeam != null) + { + disguise.setName(gameTeam.GetColor() + player.getName()); + } + else + { + disguise.setName(player.getName()); + } + + disguise.showArmor(); + disguise.setCustomNameVisible(true); + + if (_witherSkeleton) + { + DisguiseSkeleton disguiseSkeleton = (DisguiseSkeleton) disguise; + disguiseSkeleton.SetSkeletonType(SkeletonType.WITHER); + } + + disguiseManager.disguise(disguise); + } + catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } + + protected void giveItems(Player player) + { + int level = getUpgradeLevel(player.getUniqueId()); + + switch (level) + { + case 5: + player.getInventory().addItem(AXE_5); + break; + default: + player.getInventory().addItem(AXE); + break; + } + } + + @Override + public boolean showUpgrades() + { + return true; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitHumanKnight.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitHumanKnight.java new file mode 100644 index 000000000..c46ddb126 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitHumanKnight.java @@ -0,0 +1,127 @@ +package nautilus.game.arcade.game.games.castlesiegenew.kits; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkConstructor; +import nautilus.game.arcade.kit.perks.PerkMammoth; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class KitHumanKnight extends KitCastleSiege +{ + + private static final String[] DESCRIPTION = { + "Master fencer at your service; both the sport, and the job..", + "", + receiveItem("Fence", 1, 40, 2), + "Take " + C.cGreen + "85%" + C.cWhite + " knockback", + "Deal " + C.cGreen + "115%" + C.cWhite + " knockback", + }; + + private static final Perk[][] PERKS = { + { + new PerkMammoth(), + new PerkConstructor("Constructor", 40, 2, Material.FENCE, "Castle Barricade", true) + }, + { + new PerkMammoth(), + new PerkConstructor("Constructor", 38, 2, Material.FENCE, "Castle Barricade", true) + }, + { + new PerkMammoth(), + new PerkConstructor("Constructor", 36, 2, Material.FENCE, "Castle Barricade", true) + }, + { + new PerkMammoth(), + new PerkConstructor("Constructor", 34, 3, Material.FENCE, "Castle Barricade", true) + }, + { + new PerkMammoth(), + new PerkConstructor("Constructor", 30, 3, Material.FENCE, "Castle Barricade", true) + }, + { + new PerkMammoth(), + new PerkConstructor("Constructor", 25, 3, Material.FENCE, "Castle Barricade", true) + } + }; + + private static final String REDUCE_COOLDOWN_2 = reduceCooldown("Constructor", 2); + private static final String REDUCE_COOLDOWN_4 = reduceCooldown("Constructor", 4); + private static final String REDUCE_COOLDOWN_5 = reduceCooldown("Constructor", 5); + private static final String[][] UPGRADES = { + { + REDUCE_COOLDOWN_2 + }, + { + REDUCE_COOLDOWN_2 + }, + { + REDUCE_COOLDOWN_2, + increaseNumber("Constructor", "Maximum Fences", 1, "Fences") + }, + { + REDUCE_COOLDOWN_4, + receiveItem("Diamond Helmet", 1) + }, + { + REDUCE_COOLDOWN_5, + receiveItem("Diamond Chestplate", 1) + } + }; + + private static final ItemStack[] PLAYER_ITEMS = { + ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD), + ItemStackFactory.Instance.CreateStack(Material.BOW), + ItemStackFactory.Instance.CreateStack(Material.ARROW, 64), + ItemStackFactory.Instance.CreateStack(Material.FENCE, (byte) 0, 2, F.item("Castle Barricade")), + ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP), + ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP), + ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP), + ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP) + }; + + private static final ItemStack[] ARMOR = { + ItemStackFactory.Instance.CreateStack(Material.IRON_BOOTS), + ItemStackFactory.Instance.CreateStack(Material.IRON_LEGGINGS), + ItemStackFactory.Instance.CreateStack(Material.IRON_CHESTPLATE), + ItemStackFactory.Instance.CreateStack(Material.IRON_HELMET) + }; + + public static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD); + + public KitHumanKnight(ArcadeManager manager) + { + super(manager, "Castle Knight", KitAvailability.Gem, DESCRIPTION, PERKS, UPGRADES, EntityType.ZOMBIE, IN_HAND); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + player.getInventory().setArmorContents(ARMOR); + + int level = getUpgradeLevel(player.getUniqueId()); + + if (level >= 4) + { + player.getInventory().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); + } + if (level >= 5) + { + player.getInventory().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); + } + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + ent.getEquipment().setArmorContents(ARMOR); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitHumanMarksman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitHumanMarksman.java new file mode 100644 index 000000000..b86afd35d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitHumanMarksman.java @@ -0,0 +1,114 @@ +package nautilus.game.arcade.game.games.castlesiegenew.kits; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.smash.perks.skeleton.PerkBarrage; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkFletcher; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class KitHumanMarksman extends KitCastleSiege +{ + + private static final String[] DESCRIPTION = { + "Arms steady; fire at will.", + "", + receiveArrowString(1, 2, 4), + "Charge your Bow to use " + C.cGreen + "Barrage" + }; + + private static final Perk[][] PERKS = { + { + new PerkBarrage(5, 250, true, false), + new PerkFletcher(2, 4, false), + }, + { + new PerkBarrage(5, 250, true, false), + new PerkFletcher(2, 4, false), + }, + { + new PerkBarrage(5, 250, true, false), + new PerkFletcher(1, 4, false), + }, + { + new PerkBarrage(6, 250, true, false), + new PerkFletcher(1, 4, false), + }, + { + new PerkBarrage(7, 250, true, false), + new PerkFletcher(1, 4, false), + }, + { + new PerkBarrage(9, 250, true, false), + new PerkFletcher(1, 4, false), + } + }; + + private static final String MORE_BARRAGE_ARROWS_1 = increaseNumber("Barrage", "Arrows Fired", 2, "Arrows"); + private static final String MORE_BARRAGE_ARROWS_2 = increaseNumber("Barrage", "Arrows Fired", 2, "Arrows"); + private static final String[][] UPGRADES = { + { + receiveItem("Extra Mushroom Stews", 2) + }, + { + reduceCooldown("Fletched Arrows", 1) + }, + { + MORE_BARRAGE_ARROWS_1 + }, + { + MORE_BARRAGE_ARROWS_1 + }, + { + MORE_BARRAGE_ARROWS_2 + } + }; + + private static final ItemStack[] PLAYER_ITEMS = { + ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD), + ItemStackFactory.Instance.CreateStack(Material.BOW), + ItemStackFactory.Instance.CreateStack(Material.ARROW, 32), + ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP), + ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP) + }; + + private static final ItemStack[] ARMOR = { + ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS), + ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS), + ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE), + ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET) + }; + + public static final ItemStack IN_HAND = new ItemStack(Material.BOW); + + public KitHumanMarksman(ArcadeManager manager) + { + super(manager, "Castle Marksman", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADES, EntityType.ZOMBIE, IN_HAND); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + player.getInventory().setArmorContents(ARMOR); + + int level = getUpgradeLevel(player.getUniqueId()); + + if (level >= 1) + { + player.getInventory().addItem(PLAYER_ITEMS[3], PLAYER_ITEMS[3]); + } + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + ent.getEquipment().setArmorContents(ARMOR); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitHumanPaladin.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitHumanPaladin.java new file mode 100644 index 000000000..003d32316 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitHumanPaladin.java @@ -0,0 +1,153 @@ +package nautilus.game.arcade.game.games.castlesiegenew.kits; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.castlesiegenew.CastleSiegeNew; +import nautilus.game.arcade.game.games.castlesiegenew.perks.PerkPaladinBoost; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkIronSkin; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import java.util.concurrent.TimeUnit; + +public class KitHumanPaladin extends KitCastleSiege +{ + + private static final String[] DESCRIPTION = { + "Stand your ground, we got this!", + "", + click(false, "your sword") + " to give buffs to nearby humans and wolves", + "Wolves receive " + C.cGreen + "Speed I" + C.cWhite + " and Humans receive " + C.cGreen + "Resistance I", + "Take " + C.cGreen + "10%" + C.cWhite + " less damage from attacks", + }; + + private static final String BOOST = C.cGreen + "Morale Royale" + C.cWhite; + private static final int EIGHT_TICKS = 8 * 20; + private static final int NINE_TICKS = 9 * 20; + private static final int TEN_TICKS = 10 * 20; + private static final Perk[][] PERKS = { + { + new PerkIronSkin(0.1, true), + new PerkPaladinBoost(TimeUnit.SECONDS.toMillis(28), + new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, EIGHT_TICKS, 0, false, false) + ) + }, + { + new PerkIronSkin(0.1, true), + new PerkPaladinBoost(TimeUnit.SECONDS.toMillis(28), + new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, NINE_TICKS, 0, false, false), + new PotionEffect(PotionEffectType.REGENERATION, NINE_TICKS, 0, false, false) + ) + }, + { + new PerkIronSkin(0.1, true), + new PerkPaladinBoost(TimeUnit.SECONDS.toMillis(27), + new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, NINE_TICKS, 0, false, false), + new PotionEffect(PotionEffectType.REGENERATION, NINE_TICKS, 0, false, false), + new PotionEffect(PotionEffectType.HEALTH_BOOST, NINE_TICKS, 0, false, false) + ) + }, + { + new PerkIronSkin(0.1, true), + new PerkPaladinBoost(TimeUnit.SECONDS.toMillis(27), + new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, TEN_TICKS, 0, false, false), + new PotionEffect(PotionEffectType.REGENERATION, TEN_TICKS, 1, false, false), + new PotionEffect(PotionEffectType.HEALTH_BOOST, TEN_TICKS, 0, false, false) + ) + }, + { + new PerkIronSkin(0.1, true), + new PerkPaladinBoost(TimeUnit.SECONDS.toMillis(26), + new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, TEN_TICKS, 1, false, false), + new PotionEffect(PotionEffectType.REGENERATION, TEN_TICKS, 1, false, false), + new PotionEffect(PotionEffectType.HEALTH_BOOST, TEN_TICKS, 0, false, false) + ) + }, + { + new PerkIronSkin(0.2, true), + new PerkPaladinBoost(TimeUnit.SECONDS.toMillis(24), + new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, TEN_TICKS, 1, false, false), + new PotionEffect(PotionEffectType.REGENERATION, TEN_TICKS, 1, false, false), + new PotionEffect(PotionEffectType.HEALTH_BOOST, TEN_TICKS, 1, false, false) + ) + } + }; + + private static String giveEffect(String effect) + { + return BOOST + " gives " + C.cGreen + effect; + } + + private static final String REDUCE_COOLDOWN = reduceCooldown(BOOST, 1); + private static final String INCREASE_LENGTH = increaseNumber(BOOST, "Buff Length", 1, "seconds"); + + private static final String[][] UPGRADES = { + { + INCREASE_LENGTH, + giveEffect("Regeneration I") + }, + { + REDUCE_COOLDOWN, + giveEffect("Health Boost I") + }, + { + INCREASE_LENGTH, + giveEffect("Regeneration II") + }, + { + REDUCE_COOLDOWN, + giveEffect("Resistance II") + }, + { + C.cWhite + "Take " + C.cGreen + "20%" + C.cWhite + " less damage from attacks", + giveEffect("Health Boost II") + } + }; + + private static final ItemStack[] PLAYER_ITEMS = { + ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD), + ItemStackFactory.Instance.CreateStack(Material.BOW), + ItemStackFactory.Instance.CreateStack(Material.ARROW, 48), + ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP), + ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP), + ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP), + ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP) + }; + + private static final ItemStack[] ARMOR = { + ItemStackFactory.Instance.CreateStack(Material.GOLD_BOOTS), + ItemStackFactory.Instance.CreateStack(Material.GOLD_LEGGINGS), + ItemStackFactory.Instance.CreateStack(Material.GOLD_CHESTPLATE), + ItemStackFactory.Instance.CreateStack(Material.GOLD_HELMET) + }; + + public static final ItemStack IN_HAND = new ItemStack(Material.STONE_SWORD); + + public KitHumanPaladin(ArcadeManager manager) + { + super(manager, "Castle Paladin", KitAvailability.Achievement, DESCRIPTION, PERKS, UPGRADES, EntityType.ZOMBIE, IN_HAND); + + setAchievementRequirements(CastleSiegeNew.getGameAchievements()); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + player.getInventory().setArmorContents(ARMOR); + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + ent.getEquipment().setArmorContents(ARMOR); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitHumanWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitHumanWolf.java new file mode 100644 index 000000000..30b72a660 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitHumanWolf.java @@ -0,0 +1,131 @@ +package nautilus.game.arcade.game.games.castlesiegenew.kits; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.disguise.disguises.DisguiseWolf; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkKnockbackGive; +import nautilus.game.arcade.kit.perks.PerkStrength; +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; + +import java.util.concurrent.TimeUnit; + +public class KitHumanWolf extends KitCastleSiege +{ + + private static final String[] DESCRIPTION = { + "My bark is as strong as my bite.", + "", + C.cWhiteB + "THIS KIT IS GIVEN TO DEFENDERS WHEN THEY " + C.cRedB + "DIE" + }; + + private static final Perk[][] PERKS = { + { + new PerkStrength(1), + new PerkKnockbackGive(2) + }, + { + new PerkStrength(1), + new PerkKnockbackGive(2) + }, + { + new PerkStrength(1), + new PerkKnockbackGive(2) + }, + { + new PerkStrength(1), + new PerkKnockbackGive(2) + }, + { + new PerkStrength(1), + new PerkKnockbackGive(2) + }, + { + new PerkStrength(1), + new PerkKnockbackGive(2) + } + }; + + private static final String MORE_HEALTH = increase("Starting Health", 0.5); + + private static final String[][] UPGRADES = { + { + MORE_HEALTH + }, + { + MORE_HEALTH + }, + { + MORE_HEALTH + }, + { + MORE_HEALTH + }, + { + MORE_HEALTH + }, + }; + + private static final long COOLDOWN = TimeUnit.SECONDS.toMillis(80); + private static final String WOLF_BITE = "Wolf Bite"; + private static final ItemStack[] PLAYER_ITEMS = { + new ItemBuilder(Material.BONE) + .setTitle(C.cYellowB + WOLF_BITE) + .addLore("Hitting any Undead will do 3 Hearts of damage!", "80 second cooldown.") + .build() + }; + + public static final ItemStack IN_HAND = new ItemStack(Material.IRON_HOE); + + public KitHumanWolf(ArcadeManager manager) + { + super(manager, "Castle Wolf", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADES, EntityType.WOLF, IN_HAND); + } + + @Override + public void GiveItems(Player player) + { + int level = getUpgradeLevel(player.getUniqueId()); + + player.setHealth(5 + level); + player.getInventory().addItem(PLAYER_ITEMS); + disguise(player, DisguiseWolf.class); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void damage(CustomDamageEvent event) + { + if (event.isCancelled() || !Manager.GetGame().IsLive()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + Player damager = event.GetDamagerPlayer(false); + + if (damager == null || damager.getItemInHand() == null || damager.getItemInHand().getType() != Material.BONE || !Recharge.Instance.usable(damager, WOLF_BITE)) + { + return; + } + + Recharge.Instance.useForce(damager, WOLF_BITE, COOLDOWN, true); + damager.sendMessage(F.main("Game", "You used " + F.skill(WOLF_BITE) + " on " + F.name(damagee.getName()) + ".")); + damager.getWorld().playSound(damager.getLocation(), Sound.WOLF_BARK, 1, 0.6F); + damagee.getWorld().playEffect(damagee.getLocation().add(0, 0.5, 0), Effect.STEP_SOUND, Material.REDSTONE_BLOCK); + Manager.GetDamage().NewDamageEvent(damagee, damager, null, DamageCause.CUSTOM, 3, true, true, true, damager.getName(), WOLF_BITE); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitUndeadArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitUndeadArcher.java new file mode 100644 index 000000000..83e2a32bd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitUndeadArcher.java @@ -0,0 +1,94 @@ +package nautilus.game.arcade.game.games.castlesiegenew.kits; + +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguiseSkeleton; +import mineplex.core.gadget.gadgets.particle.king.CastleManager; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkFletcher; +import nautilus.game.arcade.kit.perks.PerkIronSkin; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class KitUndeadArcher extends KitCastleSiege +{ + + private static final String[] DESCRIPTION = { + "I've got a bone to pick with you.", + " ", + "You can pickup arrows shot from Defenders", + "Take " + C.cGreen + "-1" + C.cWhite + " damage from attacks", + receiveArrowString(1, 8, 2) + }; + + private static final Perk[][] PERKS = { + { + new PerkFletcher(8, 2, true), + new PerkIronSkin(1) + }, + { + new PerkFletcher(7, 2, true), + new PerkIronSkin(1) + }, + { + new PerkFletcher(7, 3, true), + new PerkIronSkin(1) + }, + { + new PerkFletcher(6, 3, true), + new PerkIronSkin(1) + }, + { + new PerkFletcher(6, 4, true), + new PerkIronSkin(1) + }, + { + new PerkFletcher(6, 4, true), + new PerkIronSkin(1) + } + }; + + private static final String REDUCE_ARROW_COOLDOWN = reduceCooldown("Fletched Arrows", 1); + private static final String ARROW_MAX = increaseNumber("Fletched Arrows", "maximum amount", 1, "arrow"); + + private static final String[][] UPGRADES = { + { + REDUCE_ARROW_COOLDOWN + }, + { + ARROW_MAX + }, + { + REDUCE_ARROW_COOLDOWN + }, + { + ARROW_MAX + }, + { + REPLACE_AXE + } + }; + + private static final ItemStack[] PLAYER_ITEMS = { + new ItemStack(Material.BOW) + }; + + public static final ItemStack IN_HAND = new ItemStack(Material.BOW); + + public KitUndeadArcher(ArcadeManager manager) + { + super(manager, "Undead Archer", KitAvailability.Gem, 2000, DESCRIPTION, PERKS, UPGRADES, EntityType.SKELETON, IN_HAND); + } + + @Override + public void GiveItems(Player player) + { + giveItems(player); + player.getInventory().addItem(PLAYER_ITEMS); + disguise(player, DisguiseSkeleton.class); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitUndeadGhoul.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitUndeadGhoul.java new file mode 100644 index 000000000..3034eb8e6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitUndeadGhoul.java @@ -0,0 +1,84 @@ +package nautilus.game.arcade.game.games.castlesiegenew.kits; + +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguisePigZombie; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkLeap; +import nautilus.game.arcade.kit.perks.PerkSpeed; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class KitUndeadGhoul extends KitCastleSiege +{ + + private static final String[] DESCRIPTION = { + "The walls thought they were too high for me; I proved them wrong.", + "", + click(false, "your axe to use " + C.cGreen + "Ghoul Leap"), + }; + + private static final String LEAP = "Ghoul Leap"; + private static final Perk[][] PERKS = { + { + new PerkLeap(LEAP, 1.2, 0.8, 8000), + new PerkSpeed(0) + }, + { + new PerkLeap(LEAP, 1.2, 0.8, 7500), + new PerkSpeed(0) + }, + { + new PerkLeap(LEAP, 1.2, 0.8, 7000), + new PerkSpeed(0) + }, + { + new PerkLeap(LEAP, 1.2, 0.8, 6500), + new PerkSpeed(0) + }, + { + new PerkLeap(LEAP, 1.2, 0.8, 6000), + new PerkSpeed(0) + }, + { + new PerkLeap(LEAP, 1.2, 0.8, 6000), + new PerkSpeed(0) + } + }; + + private static final String[][] UPGRADES = { + { + reduceCooldown(LEAP, 1) + }, + { + reduceCooldown(LEAP, 1) + }, + { + reduceCooldown(LEAP, 1) + }, + { + reduceCooldown(LEAP, 1) + }, + { + REPLACE_AXE + } + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.STONE_AXE); + + public KitUndeadGhoul(ArcadeManager manager) + { + super(manager, "Undead Ghoul", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADES, EntityType.PIG_ZOMBIE, IN_HAND); + } + + @Override + public void GiveItems(Player player) + { + giveItems(player); + disguise(player, DisguisePigZombie.class); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitUndeadSummoner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitUndeadSummoner.java new file mode 100644 index 000000000..65c62d8c0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitUndeadSummoner.java @@ -0,0 +1,112 @@ +package nautilus.game.arcade.game.games.castlesiegenew.kits; + +import java.util.concurrent.TimeUnit; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.disguise.disguises.DisguiseSkeleton; +import mineplex.core.itemstack.ItemBuilder; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.castlesiegenew.CastleSiegeNew; +import nautilus.game.arcade.game.games.castlesiegenew.perks.MobPotion; +import nautilus.game.arcade.game.games.castlesiegenew.perks.PerkMobPotions; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitUndeadSummoner extends KitCastleSiege +{ + + private static final String[] DESCRIPTION = { + "Say hello to my little friend.", + "", + click(false, "your eggs to spawn undead mobs to help you fight") + }; + + private static final String REDUCE_COOLDOWN = reduceCooldown("Undead Eggs", 2); + + private static final MobPotion SILVER_FISH = new MobPotion( + new ItemBuilder(Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.SLIME)) + .setTitle(C.cGreen + "Slime Egg") + .build(), EntityType.SLIME, 3); + private static final MobPotion ZOMBIE = new MobPotion( + new ItemBuilder(Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.ZOMBIE)) + .setTitle(C.cGreen + "Zombie Egg") + .build(), EntityType.ZOMBIE, 1); + private static final MobPotion SPIDER = new MobPotion( + new ItemBuilder(Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.SPIDER)) + .setTitle(C.cGreen + "Spider Egg") + .build(), EntityType.SPIDER, 1); + + private static final Perk[][] PERKS = { + { + new PerkMobPotions(TimeUnit.SECONDS.toMillis(32), SILVER_FISH), + }, + { + new PerkMobPotions(TimeUnit.SECONDS.toMillis(32), SILVER_FISH, ZOMBIE), + }, + { + new PerkMobPotions(TimeUnit.SECONDS.toMillis(32), SILVER_FISH, ZOMBIE, SPIDER), + }, + { + new PerkMobPotions(TimeUnit.SECONDS.toMillis(30), SILVER_FISH, ZOMBIE, SPIDER), + }, + { + new PerkMobPotions(TimeUnit.SECONDS.toMillis(28), SILVER_FISH, ZOMBIE, SPIDER), + }, + { + new PerkMobPotions(TimeUnit.SECONDS.toMillis(28), SILVER_FISH, ZOMBIE, SPIDER), + } + }; + + private static final String[][] UPGRADES = { + { + receiveItem("Zombie Egg", 1) + }, + { + receiveItem("Spider Egg", 1) + }, + { + REDUCE_COOLDOWN + }, + { + REDUCE_COOLDOWN + }, + { + REPLACE_AXE + } + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.BONE); + + public KitUndeadSummoner(ArcadeManager manager) + { + super(manager, "Undead Summoner", KitAvailability.Achievement, DESCRIPTION, PERKS, UPGRADES, EntityType.SKELETON, IN_HAND); + + setAchievementRequirements(CastleSiegeNew.getGameAchievements()); + _witherSkeleton = true; + } + + @Override + public void GiveItems(Player player) + { + giveItems(player); + disguise(player, DisguiseSkeleton.class); + + int level = getUpgradeLevel(player.getUniqueId()); + Perk[] perks = PERKS[level]; + + for (Perk perk : perks) + { + for (MobPotion potion : ((PerkMobPotions) perk).getMobPotions()) + { + player.getInventory().addItem(potion.getItemStack()); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitUndeadZombie.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitUndeadZombie.java new file mode 100644 index 000000000..8b5ac6ada --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/kits/KitUndeadZombie.java @@ -0,0 +1,81 @@ +package nautilus.game.arcade.game.games.castlesiegenew.kits; + +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguiseZombie; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkRegeneration; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class KitUndeadZombie extends KitCastleSiege +{ + + private static final String[] DESCRIPTION = { + "Keep those arrows coming.", + "", + "Receive " + C.cGreen + "Regeneration III" + }; + + private static final Perk[][] PERKS = { + { + new PerkRegeneration(2) + }, + { + new PerkRegeneration(2) + }, + { + new PerkRegeneration(2) + }, + { + new PerkRegeneration(2) + }, + { + new PerkRegeneration(2) + }, + { + new PerkRegeneration(2) + } + }; + + private static final String MORE_HEALTH = "Increase your max health by 1 heart."; + + private static final String[][] UPGRADES = { + { + MORE_HEALTH + }, + { + MORE_HEALTH + }, + { + MORE_HEALTH + }, + { + MORE_HEALTH + }, + { + REPLACE_AXE + }, + }; + + public static final ItemStack IN_HAND = new ItemStack(Material.STONE_AXE); + + public KitUndeadZombie(ArcadeManager manager) + { + super(manager, "Undead Zombie", KitAvailability.Gem, 5000, DESCRIPTION, PERKS, UPGRADES, EntityType.ZOMBIE, IN_HAND); + } + + @Override + public void GiveItems(Player player) + { + giveItems(player); + disguise(player, DisguiseZombie.class); + + int level = getUpgradeLevel(player.getUniqueId()); + + player.setMaxHealth(20 + level * 2); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/perks/MobPotion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/perks/MobPotion.java new file mode 100644 index 000000000..528acbfdc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/perks/MobPotion.java @@ -0,0 +1,34 @@ +package nautilus.game.arcade.game.games.castlesiegenew.perks; + +import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; + +public class MobPotion +{ + + private final ItemStack _itemStack; + private final EntityType _entityType; + private final int _amount; + + public MobPotion(ItemStack itemStack, EntityType entityType, int amount) + { + _itemStack = itemStack; + _entityType = entityType; + _amount = amount; + } + + public ItemStack getItemStack() + { + return _itemStack; + } + + public EntityType getEntityType() + { + return _entityType; + } + + public int getAmount() + { + return _amount; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/perks/PerkMobPotions.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/perks/PerkMobPotions.java new file mode 100644 index 000000000..78271b31b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/perks/PerkMobPotions.java @@ -0,0 +1,266 @@ +package nautilus.game.arcade.game.games.castlesiegenew.perks; + +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.castlesiegenew.CastleSiegeNew; +import nautilus.game.arcade.kit.Perk; + +public class PerkMobPotions extends Perk +{ + + private static final long MAX_TIME = TimeUnit.SECONDS.toMillis(16); + private static final long COOLDOWN = TimeUnit.SECONDS.toMillis(2); + private static final int HEALTH = 20; + private static final PotionEffect SPEED = new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1, false, false); + + private final MobPotion[] _mobPotions; + private final Set _entities = new HashSet<>(); + private final long _cooldown; + + public PerkMobPotions(long cooldown, MobPotion... mobPotions) + { + super("Mob Egg"); + + _cooldown = cooldown; + _mobPotions = mobPotions; + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + Player player = event.getPlayer(); + + if (!hasPerk(player)) + { + return; + } + + MobPotion clickedPotion = null; + ItemStack itemStack = player.getItemInHand(); + + if (itemStack == null) + { + return; + } + + for (MobPotion potion : _mobPotions) + { + if (potion.getItemStack().isSimilar(itemStack)) + { + clickedPotion = potion; + break; + } + } + + if (clickedPotion == null) + { + return; + } + + event.setCancelled(true); + + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, false) || !Recharge.Instance.use(player, ChatColor.stripColor(clickedPotion.getItemStack().getItemMeta().getDisplayName()), _cooldown, true, true)) + { + return; + } + + Manager.GetGame().CreatureAllowOverride = true; + + Location location = player.getEyeLocation(); + + for (int i = 0; i < clickedPotion.getAmount(); i++) + { + LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(location, clickedPotion.getEntityType()); + entity.setVelocity(location.getDirection().add(new Vector(Math.random() - 0.5, 0, Math.random() - 0.5))); + entity.addPotionEffect(SPEED); + entity.setCustomName(player.getName() + "'s Minion"); + entity.setCustomNameVisible(true); + entity.setMaxHealth(HEALTH); + entity.setHealth(HEALTH); + + if (entity instanceof Slime) + { + ((Slime) entity).setSize(1); + } + + _entities.add(new SummonedEntity(entity, player)); + } + + Manager.GetGame().CreatureAllowOverride = false; + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + _entities.removeIf(entity -> + { + if (UtilTime.elapsed(entity.SpawnedAt, MAX_TIME)) + { + entity.Summoned.setHealth(0); + return true; + } + + return entity.Summoned.isDead(); + }); + } + + @EventHandler + public void entityTarget(EntityTargetEvent event) + { + for (SummonedEntity entity : _entities) + { + if (!event.getEntity().equals(entity.Summoned)) + { + continue; + } + + LivingEntity target = getNewTarget(entity); + + if (target == null) + { + event.setCancelled(true); + return; + } + + event.setTarget(target); + return; + } + } + + @EventHandler + public void entityDeath(EntityDeathEvent event) + { + for (SummonedEntity entity : _entities) + { + if (!event.getEntity().equals(entity.Summoned)) + { + continue; + } + + event.setDroppedExp(0); + event.getDrops().clear(); + return; + } + } + + @EventHandler + public void entityDamage(CustomDamageEvent event) + { + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(false); + + for (SummonedEntity entity : _entities) + { + if (entity.Summoned.equals(damagee)) + { + Player damagerPlayer = event.GetDamagerPlayer(true); + CastleSiegeNew game = (CastleSiegeNew) Manager.GetGame(); + + if (damager == null || !game.getUndead().HasPlayer(damagerPlayer)) + { + return; + } + + event.SetCancelled("Team Mob"); + return; + } + else if (entity.Summoned.equals(damager)) + { + event.setDamager(entity.Owner); + return; + } + } + } + + @EventHandler + public void updateDamage(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (SummonedEntity entity : _entities) + { + // Slimes are weird and don't damage players normally. + if (entity.Summoned instanceof Slime) + { + LivingEntity target = entity.Summoned; + + for (Player player : UtilPlayer.getNearby(target.getLocation(), 2)) + { + if (player.equals(entity.Owner)) + { + return; + } + + Manager.GetDamage().NewDamageEvent(player, entity.Owner, null, DamageCause.CUSTOM, 2, true, true, false, entity.Summoned.getCustomName(), "Minion"); + } + } + } + } + + public MobPotion[] getMobPotions() + { + return _mobPotions; + } + + private LivingEntity getNewTarget(SummonedEntity entity) + { + return UtilPlayer.getClosest(entity.Summoned.getLocation(), 10, entity.OwnerTeam.GetPlayers(true)); + } + + private class SummonedEntity + { + + LivingEntity Summoned; + Player Owner; + GameTeam OwnerTeam; + long SpawnedAt; + + SummonedEntity(LivingEntity summoned, Player owner) + { + Summoned = summoned; + Owner = owner; + OwnerTeam = Manager.GetGame().GetTeam(owner); + SpawnedAt = System.currentTimeMillis(); + } + } + + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/perks/PerkPaladinBoost.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/perks/PerkPaladinBoost.java new file mode 100644 index 000000000..b80bbad6a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiegenew/perks/PerkPaladinBoost.java @@ -0,0 +1,84 @@ +package nautilus.game.arcade.game.games.castlesiegenew.perks; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.castlesiegenew.CastleSiegeNew; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class PerkPaladinBoost extends Perk +{ + + private static final int RADIUS = 6; + + private final long _cooldown; + private final PotionEffect[] _effects; + + public PerkPaladinBoost(long cooldown, PotionEffect... effects) + { + super("Morale Royale"); + + _cooldown = cooldown; + _effects = effects; + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (event.isCancelled() || !UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + Player player = event.getPlayer(); + ItemStack itemStack = player.getItemInHand(); + + if (!hasPerk(player) || !UtilItem.isSword(itemStack) || !Recharge.Instance.use(player, GetName(), _cooldown, true, true)) + { + return; + } + + CastleSiegeNew game = (CastleSiegeNew) Manager.GetGame(); + GameTeam team = game.GetTeam(player); + + player.sendMessage(F.main("Game", "You used " + F.skill(GetName()) + ".")); + + for (Player nearby : UtilPlayer.getNearby(player.getLocation(), RADIUS)) + { + if (!team.HasPlayer(nearby)) + { + continue; + } + + UtilParticle.PlayParticleToAll(ParticleType.HEART, nearby.getLocation().add(0, 1.2, 0), 0.5F, 0.5F, 0.5F, 0.01F, 8, ViewDist.LONG); + nearby.playSound(nearby.getLocation(), Sound.ZOMBIE_REMEDY, 1, 0.6F); + nearby.sendMessage(F.main("Game", "Paladin " + F.name(player.getName()) + " has given you buffs!")); + + boolean wolf = game.isWolf(nearby); + + for (PotionEffect effect : _effects) + { + if (effect.getType() == PotionEffectType.DAMAGE_RESISTANCE && wolf) + { + effect = new PotionEffect(PotionEffectType.SPEED, effect.getDuration(), 0, effect.isAmbient(), effect.hasParticles()); + } + + nearby.addPotionEffect(effect); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java index 0102bcd04..f2d1cc1d3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java @@ -80,6 +80,8 @@ public class DeathTag extends SoloGame this.PrepareFreeze = false; + SplitKitXP = true; + registerStatTrackers(new ComeAtMeBroStatTracker(this)); registerChatStats( diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/quests/DragonEscapeWinQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/quests/DragonEscapeWinQuestTracker.java index b47de5575..80efbbcc3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/quests/DragonEscapeWinQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/quests/DragonEscapeWinQuestTracker.java @@ -24,6 +24,11 @@ public class DragonEscapeWinQuestTracker extends QuestTracker public void increment(Player player) { + if (!player.isOnline()) + { + return; + } + incrementQuests(player, 1, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), getGame().GetKit(player).GetName() + "Kit", "Parkour"); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java index fa0e6a7ae..d3055e8de 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java @@ -63,8 +63,7 @@ public class Evolution extends SoloGame private ArrayList _mobKits = new ArrayList(); private ArrayList _kits = new ArrayList(); - private Map _startedKit = Maps.newHashMap(); - + private NautHashMap _tokens = new NautHashMap(); private NautHashMap> _evoPlatforms = new NautHashMap>(); @@ -127,9 +126,11 @@ public class Evolution extends SoloGame DeathSpectateSecs = 4.0; CreatureAllow = false; - InventoryClick = false; + InventoryClick = false; InventoryOpenBlock = false; + + SplitKitXP = true; Manager.GetDamage().GetCombatManager().setUseWeaponName(AttackReason.Attack); @@ -153,20 +154,6 @@ public class Evolution extends SoloGame ); } - public void select(UUID player, ProgressingKit kit) - { - _startedKit.put(player, kit); - } - - public ProgressingKit getStartedKit(UUID player, boolean remove) - { - if(remove) - { - return _startedKit.remove(player); - } - return _startedKit.get(player); - } - public EvolveManager getEvolve() { return _evolve; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java index eaedf92cf..18239c0dd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java @@ -319,6 +319,7 @@ public class HideSeek extends TeamGame this.DeathOut = false; this.HungerSet = 20; this.PrepareFreeze = false; + this.SplitKitXP = true; _allowedBlocks = new ArrayList(); _allowedBlocks.add(Material.TNT); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 0a280a292..501ff5469 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -20,8 +20,14 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; +import com.mineplex.anticheat.checks.combat.KillauraTypeD; +import com.mineplex.anticheat.checks.move.Glide; +import com.mineplex.anticheat.checks.move.HeadRoll; +import com.mineplex.anticheat.checks.move.Speed; + import mineplex.core.Managers; import mineplex.core.account.permissions.Permission; +import mineplex.core.antihack.AntiHack; import mineplex.core.common.Pair; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -188,6 +194,13 @@ public class Moba extends TeamGame caller.sendMessage(F.main("Kit", "Sorry that is not a kit!")); }); + + // Disable specific GWEN checks for this game + AntiHack antiHack = Managers.get(AntiHack.class); + antiHack.addIgnoredCheck(Speed.class); + antiHack.addIgnoredCheck(Glide.class); + antiHack.addIgnoredCheck(HeadRoll.class); + antiHack.addIgnoredCheck(KillauraTypeD.class); } protected T registerManager(T listener) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeamBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeamBase.java index bf6878763..cccd272fb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeamBase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeamBase.java @@ -1,12 +1,5 @@ package nautilus.game.arcade.game.games.quiver; -import java.util.HashMap; -import java.util.Map; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; - import mineplex.core.common.MinecraftVersion; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilServer; @@ -25,16 +18,23 @@ import nautilus.game.arcade.game.games.quiver.kits.KitSkyWarrior; import nautilus.game.arcade.game.games.quiver.module.ModuleKillstreak; import nautilus.game.arcade.game.games.quiver.module.ModuleKitNPCS; import nautilus.game.arcade.game.games.quiver.module.ModulePowerup; -import nautilus.game.arcade.game.games.quiver.module.ModuleSpawnBarrier; import nautilus.game.arcade.game.games.quiver.module.ModuleSuperArrow; import nautilus.game.arcade.game.games.quiver.module.ModuleUltimate; import nautilus.game.arcade.game.games.quiver.module.QuiverTeamModule; import nautilus.game.arcade.game.games.quiver.module.game.QuiverPayload; +import nautilus.game.arcade.game.modules.SpawnShieldModule; import nautilus.game.arcade.game.modules.TeamArmorModule; import nautilus.game.arcade.game.modules.VersionModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.stats.WinWithoutBowStatTracker; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; + +import java.util.HashMap; +import java.util.Map; public class QuiverTeamBase extends TeamGame { @@ -82,7 +82,6 @@ public class QuiverTeamBase extends TeamGame getQuiverTeamModule(ModuleKitNPCS.class); getQuiverTeamModule(ModulePowerup.class); getQuiverTeamModule(ModuleUltimate.class); - getQuiverTeamModule(ModuleSpawnBarrier.class); getQuiverTeamModule(ModuleKillstreak.class); new VersionModule(MinecraftVersion.Version1_9).register(this); @@ -107,7 +106,16 @@ public class QuiverTeamBase extends TeamGame .giveHotbarItem() .register(this); } - + + @Override + public void ParseData() + { + new SpawnShieldModule() + .registerShield(GetTeam(ChatColor.RED), WorldData.GetCustomLocs("73")) + .registerShield(GetTeam(ChatColor.AQUA), WorldData.GetCustomLocs("21")) + .register(this); + } + @Override @EventHandler public void ScoreboardUpdate(UpdateEvent event) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/module/ModuleSpawnBarrier.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/module/ModuleSpawnBarrier.java deleted file mode 100644 index f446d55be..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/module/ModuleSpawnBarrier.java +++ /dev/null @@ -1,142 +0,0 @@ -package nautilus.game.arcade.game.games.quiver.module; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; - -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.updater.UpdateType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.games.quiver.QuiverTeamBase; - -public class ModuleSpawnBarrier extends QuiverTeamModule implements Listener -{ - - private static final int DAMAGE_RADIUS = 5; - private static final int VELOCITY_RADIUS = 4; - - private static final String CUSTOM_LOCATION_BARRIER_RED = "73"; - private static final String CUSTOM_LOCATION_BARRIER_BLUE = "21"; - - private Map> _barriers = new HashMap<>(); - - public ModuleSpawnBarrier(QuiverTeamBase base) - { - super(base); - } - - @Override - public void setup() - { - getBase().Manager.registerEvents(this); - - _barriers.put(getBase().GetTeam(ChatColor.RED), getBase().WorldData.GetCustomLocs(CUSTOM_LOCATION_BARRIER_RED)); - _barriers.put(getBase().GetTeam(ChatColor.AQUA), getBase().WorldData.GetCustomLocs(CUSTOM_LOCATION_BARRIER_BLUE)); - - for (List list : _barriers.values()) - { - for (Location location : list) - { - location.getBlock().setType(Material.AIR); - } - } - } - - @Override - public void update(UpdateType updateType) - { - if (updateType == UpdateType.FAST) - { - for (GameTeam gameTeam : _barriers.keySet()) - { - for (Player player : getBase().GetPlayers(true)) - { - if (UtilPlayer.isSpectator(player)) - { - continue; - } - - if (getBase().GetTeam(player).equals(gameTeam)) - { - continue; - } - - for (Location location : gameTeam.GetSpawns()) - { - if (UtilMath.offset(player.getLocation(), location) < DAMAGE_RADIUS) - { - getBase().Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.VOID, 9001, false, true, true, getBase().GetName(), "Spawn Shield"); - } - } - - for (Location location : _barriers.get(gameTeam)) - { - if (UtilMath.offset(player.getLocation(), location) < VELOCITY_RADIUS) - { - UtilAction.velocity(player, UtilAlg.getTrajectory(location, player.getLocation()).normalize().setY(0.4)); - } - } - } - } - } - else if (updateType == UpdateType.SEC) - { - for (GameTeam gameTeam : _barriers.keySet()) - { - for (Player player : getBase().GetPlayers(true)) - { - if (UtilPlayer.isSpectator(player)) - { - continue; - } - - if (getBase().GetTeam(player).equals(gameTeam)) - { - continue; - } - - for (Location location : _barriers.get(gameTeam)) - { - UtilParticle.PlayParticle(ParticleType.BARRIER, location.clone().add(0, 0.5, 0), 0, 0, 0, 0.1F, 1, ViewDist.SHORT, player); - } - } - } - } - } - - @Override - public void finish() - { - UtilServer.Unregister(this); - } - - @EventHandler - public void onCustomDamage(CustomDamageEvent event) - { - if (event.GetDamageeEntity() instanceof Player) - { - Player player = event.GetDamageePlayer(); - - if (UtilMath.offset(player.getLocation(), UtilAlg.findClosest(player.getLocation(), getBase().GetTeam(player).GetSpawns())) < DAMAGE_RADIUS) - { - event.SetCancelled("Spawn Shield"); - } - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeleton/PerkBarrage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeleton/PerkBarrage.java index 8dc18f5ad..7a80433e9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeleton/PerkBarrage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/skeleton/PerkBarrage.java @@ -360,16 +360,8 @@ public class PerkBarrage extends SmashPerk { return; } - - for (Iterator arrowIterator = _arrows.iterator(); arrowIterator.hasNext();) - { - Projectile arrow = arrowIterator.next(); - if (arrow.isDead() || !arrow.isValid()) - { - arrowIterator.remove(); - } - } + _arrows.removeIf(arrow -> arrow.isDead() || !arrow.isValid()); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/SpawnShieldModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/SpawnShieldModule.java new file mode 100644 index 000000000..c85303380 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/SpawnShieldModule.java @@ -0,0 +1,192 @@ +package nautilus.game.arcade.game.modules; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.GameTeam; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.Predicate; + +public class SpawnShieldModule extends Module +{ + + private final Set _shields; + + private int _damage = 5000; + private int _damageRadiusSquared = 25; + private int _velocityRadiusSquared = 9; + private boolean _displayParticles = true; + + public SpawnShieldModule() + { + _shields = new HashSet<>(); + } + + public SpawnShieldModule registerShield(GameTeam team, List barriers) + { + return registerShield(team::HasPlayer, barriers, UtilAlg.getAverageLocation(team.GetSpawns())); + } + + public SpawnShieldModule registerShield(Predicate shouldNotAffect, List barriers, Location center) + { + _shields.add(new Shield(shouldNotAffect, barriers, center)); + return this; + } + + public SpawnShieldModule setDamage(int damage) + { + _damage = damage; + return this; + } + + public SpawnShieldModule setDamageRadius(int radius) + { + _damageRadiusSquared = radius * radius; + return this; + } + + public SpawnShieldModule setVelocityRadius(int radius) + { + _velocityRadiusSquared = radius * radius; + return this; + } + + public SpawnShieldModule setDisplayParticles(boolean display) + { + _displayParticles = display; + return this; + } + + @Override + public void setup() + { + for (Shield shield : _shields) + { + for (Location location : shield.Barriers) + { + location.getBlock().setType(Material.AIR); + } + } + } + + @EventHandler + public void updateShield(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + { + return; + } + + for (Shield shield : _shields) + { + for (Player player : getGame().GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player) || shield.ShouldNotAffect.test(player)) + { + continue; + } + + if (UtilMath.offsetSquared(player.getLocation(), shield.Center) < _damageRadiusSquared) + { + getGame().Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.VOID, _damage, false, true, true, getGame().GetName(), "Spawn Shield"); + } + else + { + for (Location location : shield.Barriers) + { + if (UtilMath.offsetSquared(player.getLocation(), location) < _velocityRadiusSquared) + { + Entity passenger = player.getPassenger(); + + UtilAction.velocity(passenger == null ? player : passenger, UtilAlg.getTrajectory(location, player.getLocation()).setY(0.4)); + break; + } + } + } + } + } + } + + @EventHandler + public void updateParticles(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || !_displayParticles) + { + return; + } + + for (Shield shield : _shields) + { + for (Player player : getGame().GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player) || shield.ShouldNotAffect.test(player)) + { + continue; + } + + for (Location location : shield.Barriers) + { + UtilParticle.PlayParticle(ParticleType.BARRIER, location.clone().add(0, 0.5, 0), 0, 0, 0, 0.1F, 1, ViewDist.SHORT, player); + } + } + } + } + + @Override + public void cleanup() + { + _shields.clear(); + } + + @EventHandler + public void onCustomDamage(CustomDamageEvent event) + { + Player player = event.GetDamageePlayer(); + + if (player == null) + { + return; + } + + for (Shield shield : _shields) + { + if (shield.ShouldNotAffect.test(player) && UtilMath.offsetSquared(player.getLocation(), shield.Center) < _damageRadiusSquared) + { + event.SetCancelled("Spawn Shield"); + return; + } + } + } + + private class Shield + { + + Predicate ShouldNotAffect; + List Barriers; + Location Center; + + Shield(Predicate shouldNotAffect, List barriers, Location center) + { + ShouldNotAffect = shouldNotAffect; + Barriers = barriers; + Center = center; + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java index dbfe01cf6..5794807b0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java @@ -1,16 +1,21 @@ package nautilus.game.arcade.kit; import mineplex.core.achievement.Achievement; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.utils.UtilVariant; import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.events.PlayerKitGiveEvent; - -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.entity.*; -import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; @@ -27,6 +32,7 @@ public abstract class Kit implements Listener protected EntityType _entityType; protected ItemStack _itemInHand; + protected boolean _witherSkeleton; protected Material _displayItem; @@ -66,6 +72,8 @@ public abstract class Kit implements Listener _displayItem = Material.BOOK; if (itemInHand != null) _displayItem = itemInHand.getType(); + + _witherSkeleton = name.contains("Wither") || name.contains("Alpha"); } public LivingEntity getLivingEntity() @@ -75,7 +83,7 @@ public abstract class Kit implements Listener public String GetFormattedName() { - return GetAvailability().GetColor() + "§l" + _kitName; + return GetAvailability().GetColor() + C.Bold + _kitName; } public String GetName() @@ -153,19 +161,22 @@ public abstract class Kit implements Listener { type = EntityType.ZOMBIE; } - - final LivingEntity entity = (LivingEntity) Manager.GetCreature().SpawnEntity(loc, type); + + LivingEntity entity; + + if (_witherSkeleton) + { + entity = UtilVariant.spawnWitherSkeleton(loc); + } + else + { + entity = (LivingEntity) Manager.GetCreature().SpawnEntity(loc, type); + } entity.setRemoveWhenFarAway(false); entity.setCustomName(GetAvailability().GetColor() + GetName() + " Kit"); entity.setCustomNameVisible(true); entity.getEquipment().setItemInHand(_itemInHand); - - if (type == EntityType.SKELETON && (GetName().contains("Wither") || GetName().contains("Alpha"))) - { - Skeleton skel = (Skeleton)entity; - skel.setSkeletonType(SkeletonType.WITHER); - } UtilEnt.vegetate(entity, true); UtilEnt.ghost(entity, true, false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/KitProgressionData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/KitProgressionData.java index ee5caa4e1..40084fc5d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/KitProgressionData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/KitProgressionData.java @@ -8,20 +8,21 @@ import nautilus.game.arcade.game.Game; public class KitProgressionData { - private ProgressingKit _kit; - private Game _game; - private int _xpGained; + private final ProgressingKit _kit; + private final Game _game; + private final long _selectTime; + private long _endTime; - public KitProgressionData(ProgressingKit kit, Game game, int xpGained) + public KitProgressionData(ProgressingKit kit, Game game) { _kit = kit; _game = game; - _xpGained = xpGained; + _selectTime = System.currentTimeMillis(); } - public int getXpGained() + public ProgressingKit getKit() { - return _xpGained; + return _kit; } public Game getGame() @@ -29,8 +30,18 @@ public class KitProgressionData return _game; } - public ProgressingKit getKit() + public long getSelectTime() { - return _kit; + return _selectTime; + } + + public void setEndTime() + { + _endTime = System.currentTimeMillis(); + } + + public long getEndTime() + { + return _endTime; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java index e332af27d..3d67f636c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.kit; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.UUID; @@ -10,9 +9,7 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutEntityStatus; import net.minecraft.server.v1_8_R3.World; import org.bukkit.Bukkit; -import org.bukkit.Color; import org.bukkit.FireworkEffect; -import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -23,7 +20,6 @@ import org.bukkit.entity.Firework; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.FireworkMeta; -import org.bukkit.scheduler.BukkitRunnable; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -32,7 +28,6 @@ import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilText; import mineplex.core.donation.Donor; import mineplex.core.menu.Menu; @@ -45,8 +40,6 @@ import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.shop.item.SalesPackageProcessor; import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.game.games.evolution.Evolution; import nautilus.game.arcade.shop.KitPackage; /** @@ -55,13 +48,6 @@ import nautilus.game.arcade.shop.KitPackage; public abstract class ProgressingKit extends Kit implements ProgressiveKit { - public static final String COOLDOWN = "Cooldown"; - - private static final FireworkEffect EFFECT = FireworkEffect.builder() - .withColor(Color.AQUA) - .with(Type.BALL) - .build(); - private String _internalName; private PlayerKitDataManager _dataManager; private Map> _kitUpgradeDetails; @@ -247,11 +233,6 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit @Override public void onSelected(UUID player) { - if(Manager.GetGame().GetType() == GameType.Evolution) - { - Evolution evolution = (Evolution) Manager.GetGame(); - evolution.select(player, this); - } _dataManager.get(player).setCurrentKit(getInternalName()); Manager.GetGame().SetKit(Bukkit.getPlayer(player), this, true); Manager.getProgressionKitManager().displayParticles(this, player); @@ -288,30 +269,6 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit { PlayerKit playerKit = _dataManager.get(player); playerKit.levelUp(); - - Player bukkitPlayer = UtilServer.getServer().getPlayer(player); - - List circle = circle(bukkitPlayer.getLocation(), 5, 1, true, false, 10); - - new BukkitRunnable() - { - - private int index = 0; - private int total = circle.size(); - - @Override - public void run() - { - Player[] players = UtilServer.getPlayers(); - Location location = circle.get(index); - CustomFirework.spawn(location, EFFECT, players); - if (++index == total) - { - cancel(); - bukkitPlayer.getWorld().strikeLightningEffect(bukkitPlayer.getLocation()); - } - } - }.runTaskTimer(Manager.getPlugin(), 0L, 1L); } @Override @@ -351,33 +308,6 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit return _dataManager.get(player).hasLeveledUp(); } - private List circle(Location loc, Integer r, Integer h, Boolean hollow, Boolean sphere, int plusY) - { - List circleblocks = new ArrayList<>(); - - int cx = loc.getBlockX(); - int cy = loc.getBlockY(); - int cz = loc.getBlockZ(); - - for (int x = cx - r; x <= cx + r; x++) - { - for (int z = cz - r; z <= cz + r; z++) - { - for (int y = (sphere ? cy - r : cy); y < (sphere ? cy + r : cy + h); y++) - { - double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0); - if (dist < r * r && !(hollow && dist < (r - 1) * (r - 1))) - { - Location l = new Location(loc.getWorld(), x, y + plusY, z); - circleblocks.add(l); - } - } - } - } - - return circleblocks; - } - public boolean canEquipKit(Player player) { Donor donor = Manager.GetDonation().Get(player); @@ -443,7 +373,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit public static String receiveItem(String item, int amount) { - return "Receive " + (amount == 1 ? (UtilText.startsWithVowel(item) ? "an" :"a") : C.cGreen + amount) + " " + item; + return C.cWhite + "Receive " + C.cGreen + (amount == 1 ? (UtilText.startsWithVowel(item) ? "an" :"a") : amount) + " " + item; } public static String click(boolean left, String comp) @@ -458,7 +388,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit public static String reduceCooldown(String perk, double time) { - return C.cWhite + "Reduce the cooldown of " + C.cGreen + perk + C.cWhite + " by " + C.cGreen + time + C.cWhite + " seconds" + (time == 1 ? "" : "s") + "."; + return C.cWhite + "Reduce the cooldown of " + C.cGreen + perk + C.cWhite + " by " + C.cGreen + time + C.cWhite + " second" + (time == 1 ? "" : "s") + "."; } public static String increaseNumber(String perk, String increasing, double value, String data) @@ -471,6 +401,11 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit return C.cWhite + "Increase the " + C.cGreen + increasing + C.cWhite + " of " + C.cGreen + perk + C.cWhite + " by " + C.cGreen + percentage + C.cWhite + "%."; } + public static String increase(String increasing, double value) + { + return C.cWhite + "Increase your " + C.cGreen + increasing + C.cWhite + " by " + value + C.cWhite + "."; + } + public static class CustomFirework extends EntityFireworks { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkConstructor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkConstructor.java index 62b42fdbc..24e05e4a1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkConstructor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkConstructor.java @@ -57,7 +57,7 @@ public class PerkConstructor extends Perk for (Player cur : UtilServer.getPlayers()) { - if (!Kit.HasKit(cur)) + if (!hasPerk(cur)) continue; if (!Manager.GetGame().IsAlive(cur)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronSkin.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronSkin.java index 9db6fb6d1..d7b9c6e83 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronSkin.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronSkin.java @@ -33,71 +33,27 @@ public class PerkIronSkin extends Perk } @EventHandler(priority = EventPriority.HIGH) - public void DamageDecrease(CustomDamageEvent event) + public void damageDecrease(CustomDamageEvent event) { - if (event.IsCancelled()) - return; - - if (event.GetCause() == DamageCause.FIRE_TICK) - return; - - if (event.GetDamage() <= 1) + if (event.IsCancelled() || event.GetCause() == DamageCause.FIRE_TICK || event.GetDamage() <= 1) + { return; + } Player damagee = event.GetDamageePlayer(); - if (damagee == null) return; - - if (!Kit.HasKit(damagee)) - return; - - if (!hasPerk(damagee)) + + if (damagee == null || !hasPerk(damagee)) + { return; + } if (_percentage) { - event.AddMult(damagee.getName(), GetName(), _reduction, false); + event.AddMod(damagee.getName(), GetName(), -_reduction * event.GetDamage(), false); } else { event.AddMod(damagee.getName(), GetName(), -_reduction, false); } } - - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void damageDecrease(EntityDamageEvent event) - { - if (Managers.get(DamageManager.class).IsEnabled()) - { - return; - } - - if (event.getCause() == DamageCause.FIRE_TICK) - return; - - if (event.getDamage() <= 1) - return; - - if (!(event.getEntity() instanceof Player)) - return; - - Player damagee = (Player) event.getEntity(); - - if (!Kit.HasKit(damagee)) - return; - - if (!hasPerk(damagee)) - return; - - if (!Manager.IsAlive(damagee)) - return; - - if (_percentage) - { - event.setDamage(event.getDamage() * _reduction); - } - else - { - event.setDamage(event.getDamage() - _reduction); - } - } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackGive.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackGive.java index 63e0019d6..502929b02 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackGive.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackGive.java @@ -28,7 +28,7 @@ public class PerkKnockbackGive extends Perk Player damager = event.GetDamagerPlayer(false); if (damager == null) return; - if (!Kit.HasKit(damager)) + if (!hasPerk(damager)) return; if (!Manager.IsAlive(damager)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLeap.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLeap.java index b34c6daa6..2dd1134f0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLeap.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLeap.java @@ -1,17 +1,7 @@ package nautilus.game.arcade.kit.perks; -import org.bukkit.Effect; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Horse; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerInteractEvent; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilItem; @@ -20,8 +10,19 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.recharge.Recharge; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.perks.event.PerkLeapEvent; +import org.bukkit.Effect; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; +import java.util.HashMap; +import java.util.Map; + public class PerkLeap extends Perk { private String _name; @@ -30,7 +31,7 @@ public class PerkLeap extends Perk private long _recharge; private int _maxUses; - private NautHashMap _uses = new NautHashMap(); + private Map _uses = new HashMap<>(); public PerkLeap(String name, double power, double heightLimit, long recharge) { @@ -80,7 +81,7 @@ public class PerkLeap extends Perk Player player = event.getPlayer(); - if (!Kit.HasKit(player)) + if (!hasPerk(player)) return; //Check Uses diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMammoth.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMammoth.java index 184a581d0..edef9741d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMammoth.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMammoth.java @@ -27,7 +27,7 @@ public class PerkMammoth extends Perk Player damager = event.GetDamagerPlayer(false); if (damager == null) return; - if (!Kit.HasKit(damager)) + if (!hasPerk(damager)) return; event.AddKnockback(GetName(), 1.15d); @@ -42,7 +42,7 @@ public class PerkMammoth extends Perk Player damagee = event.GetDamageePlayer(); if (damagee == null) return; - if (!Kit.HasKit(damagee)) + if (!hasPerk(damagee)) return; event.AddKnockback(GetName(), 0.85d); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRegeneration.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRegeneration.java index 90c42bf57..77a4920dc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRegeneration.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRegeneration.java @@ -33,7 +33,7 @@ public class PerkRegeneration extends Perk for (Player player : Manager.GetGame().GetPlayers(true)) { - if (!Kit.HasKit(player)) + if (!hasPerk(player)) continue; Manager.GetCondition().Factory().Regen(GetName(), player, player, 8, _level, false, false, true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java index 4270a6031..0db04986d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java @@ -113,7 +113,7 @@ public class GamePlayerManager implements Listener if (kit instanceof ProgressingKit) { ProgressingKit progressingKit = (ProgressingKit) kit; - if (progressingKit.isDefault(player.getUniqueId())) + if (progressingKit.canEquipKit(player) && progressingKit.isDefault(player.getUniqueId())) { progressingKit.onSelected(player.getUniqueId()); return; 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 ed8964748..ac9f6c0c2 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 @@ -256,8 +256,6 @@ public class NextBestGameManager implements Listener return; } - Managers.get(ArcadeManager.class).getProgressionKitManager().displayKitData(event.GetPlayer()); - new BukkitRunnable() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java index 35442c7a3..6d3dc6f3c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java @@ -1,5 +1,8 @@ package nautilus.game.arcade.managers; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.UUID; @@ -9,15 +12,12 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerPreLoginEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -30,6 +30,8 @@ import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerKitApplyEvent; +import nautilus.game.arcade.events.PlayerKitGiveEvent; +import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.kit.ChampionsKit; @@ -43,24 +45,69 @@ import nautilus.game.arcade.kit.ProgressingKit; public class ProgressingKitManager implements Listener { - private ArcadeManager _manager; - private Map _data; - private final Map _tasks = Maps.newHashMap(); + private final ArcadeManager _manager; + private final Map> _data; + private final Map _xpGained; + private final Map _tasks; private static final String LINE = ArcadeFormat.Line; private static final String INFO = C.cWhiteB + "Kit Progression Progress"; + private static final String LEVEL_INFO = "Level up a kit by playing with it."; private static final String SPACE = " "; public ProgressingKitManager(ArcadeManager manager) { _manager = manager; - _manager.getPlugin().getServer().getPluginManager().registerEvents(this, _manager.getPlugin()); - _data = Maps.newHashMap(); + UtilServer.RegisterEvents(this); + _data = new HashMap<>(); + _xpGained = new HashMap<>(); + _tasks = new HashMap<>(); + + manager.addCommand(new DebugCommand("kpsetlevel", Rank.ADMIN) + { + @Override + public void Execute(Player caller, String[] args) + { + if (args.length == 0) + { + caller.sendMessage(F.main("Kit", "/" + _aliasUsed + " ")); + return; + } + + Kit kit = manager.GetGame().GetKit(caller); + + if (kit == null || !(kit instanceof ProgressingKit)) + { + return; + } + + int level; + + try + { + level = Integer.parseInt(args[0]); + } + catch (NumberFormatException e) + { + caller.sendMessage(F.main("Kit", "That is not a number.")); + return; + } + + if (level < 0 || level > 5) + { + caller.sendMessage(F.main("Kit", "Please enter a number between 0 and 5.")); + return; + } + + caller.sendMessage(F.main("Kit", "Set the upgrade level for " + F.name(kit.GetName()) + " to " + F.elem(level) + ".")); + ((ProgressingKit) kit).setUpgradeLevel(level, caller.getUniqueId()); + } + }); } public void displayParticles(ProgressingKit kit, UUID player) { - if(_tasks.containsKey(player)) + if (_tasks.containsKey(player)) { //He has one selected _tasks.remove(player).cancel(); @@ -71,13 +118,13 @@ public class ProgressingKitManager implements Listener @Override public void run() { - if(kit.getLivingEntity() == null) + if (kit.getLivingEntity() == null) { cancel(); _tasks.remove(player); return; } - if(Bukkit.getPlayer(player) == null) + if (Bukkit.getPlayer(player) == null) { cancel(); _tasks.remove(player); @@ -100,7 +147,7 @@ public class ProgressingKitManager implements Listener public void entityClick(Player player, Kit kit) { PlayerKitApplyEvent kitEvent = new PlayerKitApplyEvent(_manager.GetGame(), kit, player); - UtilServer.getServer().getPluginManager().callEvent(kitEvent); + UtilServer.CallEvent(kitEvent); if (kitEvent.isCancelled()) { UtilPlayer.message(player, F.main("Game", kitEvent.getCancelMessage())); @@ -115,9 +162,11 @@ public class ProgressingKitManager implements Listener { //Odd, someone else is using a kit system. //Shouldn't ever happen, but we'll be careful. + // + // Wow Tim you really are big headed. - Sam return; } - if(!((ProgressingKit) kit).canEquipKit(player)) + if (!((ProgressingKit) kit).canEquipKit(player)) { return; } @@ -152,6 +201,8 @@ public class ProgressingKitManager implements Listener @EventHandler public void onQuit(PlayerQuitEvent event) { + UUID key = event.getPlayer().getUniqueId(); + try { //Fail safe updating in case a player leaves the game before we do data @@ -179,55 +230,67 @@ public class ProgressingKitManager implements Listener } finally { - _data.remove(event.getPlayer().getUniqueId()); - } - } - - @EventHandler - public void testCommand(PlayerCommandPreprocessEvent event) - { - //This needs to stay in for testing sakes if the issue arises connor - String message = event.getMessage(); - String user = event.getPlayer().getName(); - - if(user.equalsIgnoreCase("Moppletop") || UtilServer.isTestServer()) - { - if(message.startsWith("/kpsetlevel")) - { - event.setCancelled(true); - int level = Integer.parseInt(message.split(" ")[1]); - ProgressingKit kit = (ProgressingKit) _manager.GetGame().GetKit(event.getPlayer()); - kit.setLevel(level, event.getPlayer().getUniqueId()); - event.getPlayer().sendMessage("Set level for "+ kit.GetName() + " to " + level); - } - else if (message.startsWith("/kpclearupgrades")) - { - event.setCancelled(true); - ProgressingKit kit = (ProgressingKit) _manager.GetGame().GetKit(event.getPlayer()); - kit.setUpgradeLevel(0, event.getPlayer().getUniqueId()); - event.getPlayer().sendMessage("Cleared the upgrades for " + kit.GetName()); - } + _data.remove(key); + _xpGained.remove(key); } } @EventHandler public void cancelParticles(GameStateChangeEvent event) { - if(event.GetState() == GameState.Prepare) + if (event.GetState() != GameState.Prepare) { return; } event.GetGame().GetPlayers(true).forEach(this::cancelParticles); } + @EventHandler + public void onKitChange(PlayerKitGiveEvent event) + { + Player player = event.getPlayer(); + Game game = event.getGame(); + Kit kit = event.getKit(); + + if (!game.InProgress() || !(kit instanceof ProgressingKit)) + { + return; + } + + List dataList = _data.get(player.getUniqueId()); + + if (dataList != null) + { + for (KitProgressionData data : dataList) + { + if (data.getKit().equals(kit)) + { + return; + } + else if (data.getEndTime() != 0) + { + continue; + } + + data.setEndTime(); + } + } + + if (game.SplitKitXP || dataList == null) + { + addData(player, game, (ProgressingKit) kit); + } + } @EventHandler public void onChange(GameStateChangeEvent event) { - if (event.GetState() != GameState.Dead) + // Game is over and it actually was live at some point + if (event.GetState() != GameState.Dead || event.GetGame().getGameLiveTime() == 0) { return; } + //Upon coming back into the lobby, reset player kits so they don't have to select it again _manager.getPlugin().getServer().getScheduler().runTaskLater(_manager.getPlugin(), this::resetDefaultKits, 80); //Show the data for the previous game @@ -237,15 +300,17 @@ public class ProgressingKitManager implements Listener private void resetDefaultKits() { - Lists.newArrayList(UtilServer.getPlayers()).forEach(player -> + UtilServer.getPlayersCollection().forEach(player -> { + UUID id = player.getUniqueId(); + for (Kit kit : _manager.GetGame().GetKits()) { //Set default kit if (kit instanceof ProgressingKit) { ProgressingKit progressingKit = (ProgressingKit) kit; - if (progressingKit.isDefault(player.getUniqueId())) + if (progressingKit.canEquipKit(player) && progressingKit.isDefault(id)) { progressingKit.onSelected(player.getUniqueId()); break; @@ -257,29 +322,50 @@ public class ProgressingKitManager implements Listener public void displayKitData(Player player) { - KitProgressionData data = _data.remove(player.getUniqueId()); + UUID key = player.getUniqueId(); + List dataList = _data.remove(key); + Integer xpGained = _xpGained.remove(key); - if (data == null) - { - return; - } - if (!data.getKit().usesXp()) + if (dataList == null || xpGained == null) { return; } + KitProgressionData latestData = dataList.get(dataList.size() - 1); + latestData.setEndTime(); + long totalTime = latestData.getEndTime() - dataList.get(0).getSelectTime(); + player.sendMessage(SPACE); player.sendMessage(LINE); player.sendMessage(INFO); player.sendMessage(SPACE); - int xpGained = data.getXpGained(); + for (KitProgressionData data : dataList) + { + long elapsed = data.getEndTime() - data.getSelectTime(); + int kitXP = (int) (((double) elapsed / (double) totalTime) * xpGained); + + displayKitData(player, data, kitXP); + } + + player.sendMessage(SPACE); + player.sendMessage(LEVEL_INFO); + player.sendMessage(LINE); + } + + private void displayKitData(Player player, KitProgressionData data, int xpGained) + { + if (!data.getKit().usesXp()) + { + return; + } + ProgressingKit kit = data.getKit(); PlayerKit playerKit = _manager.getKitProgressionManager().getDataManager().get(player.getUniqueId()); - if(playerKit.getLevel(kit.getInternalName()) >= 100) + if (playerKit.getLevel(kit.getInternalName()) >= 100) { StringBuilder builder = new StringBuilder(); String kitName = C.cGoldB + kit.getDisplayName(); @@ -291,7 +377,6 @@ public class ProgressingKitManager implements Listener player.sendMessage(C.cWhite + "You maxed out this kit! Great job, and thanks for playing on Mineplex!"); player.sendMessage(SPACE); - player.sendMessage(LINE); return; } @@ -302,7 +387,6 @@ public class ProgressingKitManager implements Listener xpGained = Calculations.getXpForNextLevel(kit.getLevel(player.getUniqueId())); } - kit.setXp(kit.getXp(player.getUniqueId()) + xpGained, player.getUniqueId()); boolean leveledUp = false; @@ -323,59 +407,61 @@ public class ProgressingKitManager implements Listener //Name of the kit builder.append(kitName) - .append(" ") - .append(C.Reset); + .append(" ") + .append(C.Reset); //Current level out of 100 builder.append(C.cYellow) - .append(currentLevel) - .append(C.cGold) - .append("/") - .append(C.cYellow) - .append(100) - .append(" ") - .append(C.Reset); + .append(currentLevel) + .append(C.cGold) + .append("/") + .append(C.cYellow) + .append(100) + .append(" ") + .append(C.Reset); //The amount of XP the player gained builder.append(C.cGreen) - .append("+") - .append(xpGained) - .append(" ") - .append(C.Reset); + .append("+") + .append(xpGained) + .append(" ") + .append(C.Reset); if (!leveledUp) { //The XP required to level up builder.append(C.cYellow) - .append(difference) - .append(" to next level"); - } else + .append(difference) + .append(" to Next Level"); + } + else { builder.append(C.cAquaB) - .append("LEVEL UP! ") - .append(C.cYellow) - .append(Calculations.getXpForNextLevel(currentLevel)) - .append(" to next level"); + .append("LEVEL UP! ") + .append(C.cYellow) + .append(Calculations.getXpForNextLevel(currentLevel)) + .append(" to Next Level"); player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); } //Send the message finally player.sendMessage(builder.toString()); - player.sendMessage(C.cWhite + "Level up by using this kit in game!"); - - player.sendMessage(SPACE); - player.sendMessage(LINE); } public void displayKitData() { - Lists.newArrayList(UtilServer.getPlayers()).forEach(this::displayKitData); + UtilServer.getPlayersCollection().forEach(this::displayKitData); } - public void addData(Player player, int xpGained, Game game, ProgressingKit kit) + private void addData(Player player, Game game, ProgressingKit kit) { - _data.put(player.getUniqueId(), new KitProgressionData(kit, game, xpGained)); + UUID key = player.getUniqueId(); + _data.putIfAbsent(key, new ArrayList<>()); + _data.get(key).add(new KitProgressionData(kit, game)); } + public void setXPEarned(Player player, int xpGained) + { + _xpGained.put(player.getUniqueId(), xpGained); + } } - diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java index 531b19963..02e0f5b19 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java @@ -250,18 +250,20 @@ public abstract class LobbyManager implements Listener { UpdateEnts(); } - - if (event.getType() == UpdateType.FASTEST) + else if (event.getType() == UpdateType.FASTEST) { UpdateFirework(); PlayerSelector.selectPlayers(UtilLambda.and(PlayerSelector.inWorld(Bukkit.getWorld("world")), UtilLambda.not(PlayerSelector.within(getSpawn(), 100)))) .forEach(player -> player.teleport(getSpawn())); } - - if (event.getType() == UpdateType.SLOW) + else if (event.getType() == UpdateType.SLOW) { UpdateAdvertise(); } + else if (event.getType() == UpdateType.SLOWER) + { + cleanupEntities(); + } ScoreboardDisplay(event); } @@ -354,6 +356,11 @@ public abstract class LobbyManager implements Listener } } + private void cleanupEntities() + { + _kits.keySet().removeIf(entity -> entity.isDead() || !entity.isValid()); + } + public Kit GetClickedKit(Entity clicked) { for (LobbyEnt ent : _kits.values()) @@ -877,7 +884,6 @@ public abstract class LobbyManager implements Listener return _kitBlocks; } - public boolean getColorTick() { return _colorTick; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java index 9bcc6165e..a67d3b93e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java @@ -1,12 +1,10 @@ package nautilus.game.arcade.quest; -import java.awt.dnd.DragSourceDropEvent; import java.util.ArrayList; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.block.Block; import org.bukkit.block.Chest; import org.bukkit.block.DoubleChest; import org.bukkit.entity.Player; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java index 665657a3d..77ad5189a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java @@ -51,8 +51,6 @@ public class HitQuestTracker extends QuestTracker if (!event.GetReason().contains("Axe Thrower")) return; - System.out.println("Test2"); - incrementQuests(event.GetDamagerPlayer(true), 1, "Player", "Axe", getGame().GetKit(event.GetDamagerPlayer(true)).GetName() + "Kit"); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BloodThirstyStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BloodThirstyStatTracker.java index c6df42427..7d440d1bd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BloodThirstyStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BloodThirstyStatTracker.java @@ -1,64 +1,74 @@ package nautilus.game.arcade.stats; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - +import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.combat.CombatComponent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.game.Game; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import mineplex.core.common.util.UtilPlayer; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.games.castlesiege.kits.KitUndead; -import nautilus.game.arcade.game.games.hideseek.kits.KitSeeker; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.function.Predicate; public class BloodThirstyStatTracker extends StatTracker { - private final Map _kills = new HashMap<>(); - public BloodThirstyStatTracker(Game game) + private final Map _kills = new HashMap<>(); + private final String _stat; + private final int _amount; + private final Predicate _validKiller; + private final Predicate _validKilled; + + public BloodThirstyStatTracker(Game game, String stat, int amount, Predicate validKiller, Predicate validKilled) { super(game); + + _stat = stat; + _amount = amount; + _validKiller = validKiller; + _validKilled = validKilled; } - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + @EventHandler(priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { - if (getGame().GetState() != Game.GameState.Live) - return; + CombatComponent player = event.GetLog().GetPlayer(); + CombatComponent killer = event.GetLog().GetKiller(); - if (event.GetLog().GetKiller() == null) - return; - - if (!event.GetLog().GetKiller().IsPlayer()) - return; - - Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); - if (killer == null) - return; - - if (event.GetLog().GetPlayer() == null) - return; - - if (!event.GetLog().GetPlayer().IsPlayer()) - return; - - Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName()); - if (player == null) - return; - - if (getGame().GetKit(player) instanceof KitUndead) + if (!getGame().IsLive() || player == null || killer == null || !player.IsPlayer() || !killer.IsPlayer()) { - Integer kills = _kills.get(killer.getUniqueId()); + return; + } - kills = (kills == null ? 0 : kills) + 1; + Player killerPlayer = UtilPlayer.searchExact(killer.GetName()); - _kills.put(killer.getUniqueId(), kills); + if (killerPlayer == null) + { + return; + } - if (kills >= 50) - addStat(killer, "BloodThirsty", 1, true, false); + Player killedPlayer = UtilPlayer.searchExact(player.GetName()); + + if (killedPlayer == null) + { + return; + } + + if (_validKiller != null && !_validKiller.test(killerPlayer) || _validKilled != null && !_validKilled.test(killedPlayer)) + { + return; + } + + int newKills = _kills.getOrDefault(killerPlayer.getUniqueId(), 0) + 1; + + _kills.put(killerPlayer.getUniqueId(), newKills); + + if (newKills >= _amount) + { + addStat(killerPlayer, _stat, 1, true, false); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ExperienceStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ExperienceStatTracker.java index 1e4316316..5839592ca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ExperienceStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ExperienceStatTracker.java @@ -1,19 +1,20 @@ package nautilus.game.arcade.stats; +import java.util.List; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerQuitEvent; + import mineplex.core.common.util.NautHashMap; + import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GemData; import nautilus.game.arcade.game.games.evolution.Evolution; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.ProgressingKit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerQuitEvent; - -import java.util.List; public class ExperienceStatTracker extends StatTracker { @@ -98,18 +99,8 @@ public class ExperienceStatTracker extends StatTracker //Exp int expGained = (int)(((timeExp + gemExp)*mult)*getGame().XpMult); - //Exp - Kit kit = event.GetGame().GetKit(player); - if(event.GetGame().GetType() == GameType.Evolution) - { - Evolution evolution = (Evolution) event.GetGame(); - kit = evolution.getStartedKit(player.getUniqueId(), true); - } - if (kit instanceof ProgressingKit) - { - ProgressingKit progressingKit = (ProgressingKit) kit; - event.GetGame().Manager.getProgressionKitManager().addData(player, expGained, event.GetGame(), progressingKit); - } + // Kit Exp + event.GetGame().getArcadeManager().getProgressionKitManager().setXPEarned(player, expGained); //Record Global and per Game addStat(player, "ExpEarned", expGained, false, true); addStat(player, "ExpEarned", expGained, false, false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingDamageStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingDamageStatTracker.java deleted file mode 100644 index 5b84ac9af..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingDamageStatTracker.java +++ /dev/null @@ -1,54 +0,0 @@ -package nautilus.game.arcade.stats; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; - -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.games.castlesiege.CastleSiege; - -public class KingDamageStatTracker extends StatTracker -{ - private final Map _kingDamage = new HashMap<>(); - private double _totalKingDamage = 0; - - public KingDamageStatTracker(CastleSiege game) - { - super(game); - } - - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onKingDamage(CastleSiege.KingDamageEvent event) - { - if (getGame().GetState() != Game.GameState.Live) - return; - - _totalKingDamage += event.getDamage(); - - Double damage = _kingDamage.get(event.getPlayer().getUniqueId()); - - damage = (damage == null ? 0 : damage) + event.getDamage(); - - _kingDamage.put(event.getPlayer().getUniqueId(), damage); - } - - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onGameStateChange(GameStateChangeEvent event) - { - if (event.GetState() == Game.GameState.End) - { - for (Player player : getGame().GetPlayers(false)) - { - Double damage = _kingDamage.get(player.getUniqueId()); - - if (damage != null && damage >= 0.5 * _totalKingDamage) - addStat(player, "Assassin", 1, true, false); - } - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingSlayerStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingSlayerStatTracker.java deleted file mode 100644 index c229272e5..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingSlayerStatTracker.java +++ /dev/null @@ -1,23 +0,0 @@ -package nautilus.game.arcade.stats; - -import org.bukkit.event.EventHandler; - -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.games.castlesiege.CastleSiege; - -public class KingSlayerStatTracker extends StatTracker -{ - public KingSlayerStatTracker(Game game) - { - super(game); - } - - @EventHandler - public void onKingSlaughtered(CastleSiege.KingSlaughterEvent event) - { - if (getGame().GetState() != Game.GameState.Live) - return; - - addStat(event.getPlayer(), "KingSlayer", 1, true, false); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamDeathsStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamDeathsStatTracker.java index 9993278b3..29f94cbf2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamDeathsStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamDeathsStatTracker.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.stats; +import mineplex.minecraft.game.core.combat.CombatComponent; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -16,28 +17,26 @@ public class TeamDeathsStatTracker extends StatTracker super(game); } - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + @EventHandler(priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { - if (getGame().GetState() != Game.GameState.Live) + CombatComponent component = event.GetLog().GetPlayer(); + + if (!getGame().IsLive() || getGame().GetTeamList().size() < 2 || component == null || !component.IsPlayer()) + { return; + } - if (getGame().GetTeamList().size() < 2) - return; + Player player = UtilPlayer.searchExact(component.GetName()); - if (event.GetLog().GetPlayer() == null) - return; + if (player != null) + { + GameTeam team = getGame().GetTeam(player); - if (!event.GetLog().GetPlayer().IsPlayer()) - return; - - Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName()); - if (player == null) - return; - - GameTeam team = getGame().GetTeam(player); - - if (team != null && team.GetName() != null) - addStat(player, team.GetName() + " Deaths", 1, false, false); + if (team != null && team.GetName() != null) + { + addStat(player, team.GetName() + " Deaths", 1, false, false); + } + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamKillsStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamKillsStatTracker.java index 1a8080ac5..2f804919a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamKillsStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamKillsStatTracker.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.stats; +import mineplex.minecraft.game.core.combat.CombatComponent; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -11,33 +12,54 @@ import nautilus.game.arcade.game.GameTeam; public class TeamKillsStatTracker extends StatTracker { + public TeamKillsStatTracker(Game game) { super(game); } - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + @EventHandler(priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { - if (getGame().GetState() != Game.GameState.Live) + CombatComponent killer = event.GetLog().GetKiller(); + + if (!getGame().IsLive() || getGame().GetTeamList().size() < 2 || killer == null || !killer.IsPlayer()) + { return; + } - if (getGame().GetTeamList().size() < 2) - return; + Player player = UtilPlayer.searchExact(killer.GetName()); - if (event.GetLog().GetKiller() == null) - return; + if (player != null) + { + GameTeam team = getGame().GetTeam(player); - if (!event.GetLog().GetKiller().IsPlayer()) - return; + if (team != null && team.GetName() != null) + { + addStat(player, team.GetName() + " Kills", 1, false, false); + } + } - Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); - if (player == null) - return; + for (CombatComponent attacker : event.GetLog().GetAttackers()) + { + if (!attacker.IsPlayer() || killer.equals(attacker)) + { + continue; + } - GameTeam team = getGame().GetTeam(player); + Player assist = UtilPlayer.searchExact(attacker.GetName()); - if (team != null && team.GetName() != null) - addStat(player, team.GetName() + " Kills", 1, false, false); + if (assist == null) + { + continue; + } + + GameTeam team = getGame().GetTeam(assist); + + if (team != null && team.GetName() != null) + { + addStat(assist, team.GetName() + " Assists", 1, false, false); + } + } } }