diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java index 90dc0fd6c..5e37e0ac5 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java @@ -300,4 +300,36 @@ public class UtilMath { return n - ((int) ((int) n)); } + + public static int getMax(int... ints) + { + if (ints.length < 1) + { + return -1; + } + int max = ints[0]; + + for (int i = 1; i < ints.length; i++) + { + max = Math.max(max, ints[i]); + } + + return max; + } + + public static int getMin(int... ints) + { + if (ints.length < 1) + { + return -1; + } + int min = ints[0]; + + for (int i = 1; i < ints.length; i++) + { + min = Math.min(min, ints[i]); + } + + return min; + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index 19b7b6059..0bb9502f6 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -595,8 +595,13 @@ public class UtilPlayer return nearbyMap; } - + public static Player getClosest(Location loc, Collection ignore) + { + return getClosest(loc, -1, ignore); + } + + public static Player getClosest(Location loc, double maxDist, Collection ignore) { Player best = null; double bestDist = 0; @@ -613,6 +618,11 @@ public class UtilPlayer continue; double dist = UtilMath.offset(cur.getLocation(), loc); + + if (maxDist > 0 && dist > maxDist) + { + continue; + } if (best == null || dist < bestDist) { @@ -623,8 +633,13 @@ public class UtilPlayer return best; } - + public static Player getClosest(Location loc, Entity... ignore) + { + return getClosest(loc, -1, ignore); + } + + public static Player getClosest(Location loc, double maxDist, Entity... ignore) { Player best = null; double bestDist = 0; @@ -655,6 +670,11 @@ public class UtilPlayer } double dist = UtilMath.offset(cur.getLocation(), loc); + + if (maxDist > 0 && dist > maxDist) + { + continue; + } if (best == null || dist < bestDist) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index b3b3c5988..a7c44b7a6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -29,6 +29,7 @@ import mineplex.game.clans.clans.worldevent.api.EventState; import mineplex.game.clans.clans.worldevent.api.WorldEvent; import mineplex.game.clans.clans.worldevent.boss.BossArenaLocationFinder; import mineplex.game.clans.clans.worldevent.command.WorldEventCommand; +import mineplex.game.clans.clans.worldevent.raid.RaidManager; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.core.damage.DamageManager; @@ -49,6 +50,8 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement private long _nextEventStart; + private RaidManager _raidManager; + public WorldEventManager(JavaPlugin plugin, ClansManager clansManager, DamageManager damageManager, LootManager lootManager, BlockRestore blockRestore, ClansRegions clansRegions, SkillFactory skillFactory) { super("World Event", plugin); @@ -64,6 +67,8 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement _skillFactory = skillFactory; + _raidManager = new RaidManager(plugin); + updateNextEventTime(); } @@ -80,6 +85,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement event.stop(true); } _runningEvents.clear(); + _raidManager.onDisable(); } public boolean isInEvent(Location location) @@ -185,6 +191,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement return null; } + public WorldEvent startEventFromType(WorldEventType eventType) { if (eventType != null) @@ -239,6 +246,11 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement return _bossFinder; } + public RaidManager getRaidManager() + { + return _raidManager; + } + private void updateNextEventTime() { // 45 Minutes + (0 - 15 Minutes) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java index 5db224cbd..a0e662bc4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/api/WorldEvent.java @@ -237,14 +237,14 @@ public abstract class WorldEvent implements Listener, ScoreboardElement protected abstract void customTick(); - public final void cleanup() + public final void cleanup(boolean onDisable) { clearCreatures(); restoreBlocks(); - customCleanup(); + customCleanup(onDisable); } - public abstract void customCleanup(); + public abstract void customCleanup(boolean onDisable); public final void stop() { @@ -253,7 +253,7 @@ public abstract class WorldEvent implements Listener, ScoreboardElement public final void stop(boolean onDisable) { - cleanup(); + cleanup(onDisable); if (onDisable) { setState(EventState.REMOVED); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java index fcc770b43..dd34361c2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/BossWorldEvent.java @@ -3,6 +3,7 @@ package mineplex.game.clans.clans.worldevent.boss; import java.util.List; import java.util.stream.Collectors; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -89,6 +90,7 @@ public abstract class BossWorldEvent> extends WorldEv Location drop = event.getCreature().getLastKnownLocation(); UtilServer.CallEvent(new BossDeathEvent(this, drop)); ClansManager.getInstance().runSyncLater(() -> ClansManager.getInstance().getLootManager().dropRare(drop), DELAY_TILL_DROP_REWARD); + Bukkit.broadcastMessage(getDeathMessage()); } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemBoss.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemBoss.java index 23c90c70f..cf729c0ea 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemBoss.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/boss/ironwizard/GolemBoss.java @@ -40,7 +40,7 @@ public class GolemBoss extends BossWorldEvent protected void customTick() {} @Override - public void customCleanup() {} + public void customCleanup(boolean onDisable) {} @Override protected void customStop() {} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidAltar.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidAltar.java new file mode 100644 index 000000000..e185d68e0 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidAltar.java @@ -0,0 +1,197 @@ +package mineplex.game.clans.clans.worldevent.raid; + +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ClansManager; + +public class RaidAltar +{ + private Block _altarBlock; + private RaidType _type; + private List _requiredItems; + + public RaidAltar(Block altarBlock, RaidType type, List requiredItems) + { + _altarBlock = altarBlock; + _type = type; + _requiredItems = requiredItems; + } + + @SuppressWarnings("deprecation") + private boolean has(Player player, Material type, String itemName, List lore, Byte data, Integer amount) + { + int count = 0; + for (ItemStack item : player.getInventory().getContents()) + { + boolean rejected = false; + if (item == null || item.getType() == Material.AIR) + { + continue; + } + if (type != null && item.getType() != type) + { + rejected = true; + } + if (itemName != null && (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName() || !item.getItemMeta().getDisplayName().equals(itemName))) + { + rejected = true; + } + if (lore != null) + { + if (!item.hasItemMeta() || !item.getItemMeta().hasLore()) + { + rejected = true; + } + else + { + List itemLore = item.getItemMeta().getLore(); + if (itemLore.size() != lore.size()) + { + rejected = true; + } + else + { + for (int i = 0; i < lore.size(); i++) + { + if (!itemLore.get(i).equals(lore.get(i))) + { + rejected = true; + } + } + } + } + } + if (data != null) + { + if (item.getData().getData() != data.byteValue()) + { + rejected = true; + } + } + + if (!rejected) + { + count++; + } + } + + if (amount != null) + { + return count >= amount.intValue(); + } + else + { + return count > 0; + } + } + + @SuppressWarnings("deprecation") + private void remove(Player player, Material type, String itemName, List lore, Byte data, int amount) + { + int removed = 0; + for (int i = 0; i < player.getInventory().getContents().length; i++) + { + ItemStack item = player.getInventory().getContents()[i]; + if (removed >= amount) + { + return; + } + boolean rejected = false; + if (item == null || item.getType() == Material.AIR) + { + continue; + } + if (type != null && item.getType() != type) + { + rejected = true; + } + if (itemName != null && (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName() || !item.getItemMeta().getDisplayName().equals(itemName))) + { + rejected = true; + } + if (lore != null) + { + if (!item.hasItemMeta() || !item.getItemMeta().hasLore()) + { + rejected = true; + } + else + { + List itemLore = item.getItemMeta().getLore(); + if (itemLore.size() != lore.size()) + { + rejected = true; + } + else + { + for (int index = 0; index < lore.size(); index++) + { + if (!itemLore.get(index).equals(lore.get(index))) + { + rejected = true; + } + } + } + } + } + if (data != null) + { + if (item.getData().getData() != data.byteValue()) + { + rejected = true; + } + } + + if (!rejected) + { + if (item.getAmount() > (amount - removed)) + { + item.setAmount(item.getAmount() - (amount - removed)); + } + else + { + player.getInventory().setItem(i, null); + } + } + } + + player.updateInventory(); + } + + @SuppressWarnings("deprecation") + public boolean handleInteract(Player player, Block block) + { + if (_altarBlock.equals(block)) + { + for (ItemStack required : _requiredItems) + { + String displayName = ((required.hasItemMeta() && required.getItemMeta().hasDisplayName()) ? required.getItemMeta().getDisplayName() : null); + List lore = ((required.hasItemMeta() && required.getItemMeta().hasLore()) ? required.getItemMeta().getLore() : null); + if (!has(player, required.getType(), displayName, lore, required.getData().getData(), required.getAmount())) + { + UtilPlayer.message(player, F.main(_type.getRaidName() + " Raid", "You do not have the required summoning items for this raid!")); + return true; + } + } + if (ClansManager.getInstance().getWorldEvent().getRaidManager().startRaid(player, _type)) + { + for (ItemStack required : _requiredItems) + { + String displayName = ((required.hasItemMeta() && required.getItemMeta().hasDisplayName()) ? required.getItemMeta().getDisplayName() : null); + List lore = ((required.hasItemMeta() && required.getItemMeta().hasLore()) ? required.getItemMeta().getLore() : null); + remove(player, required.getType(), displayName, lore, required.getData().getData(), required.getAmount()); + } + } + return true; + } + + return false; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidChallenge.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidChallenge.java new file mode 100644 index 000000000..896440803 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidChallenge.java @@ -0,0 +1,62 @@ +package mineplex.game.clans.clans.worldevent.raid; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; + +public abstract class RaidChallenge implements Listener +{ + private T _raid; + private String _name; + private boolean _completed; + + public RaidChallenge(T raid, String name) + { + _raid = raid; + _name = name; + _completed = false; + } + + public abstract void customStart(); + public abstract void customComplete(); + + public T getRaid() + { + return _raid; + } + + public String getName() + { + return _name; + } + + public boolean isComplete() + { + return _completed; + } + + public void start() + { + customStart(); + UtilServer.RegisterEvents(this); + UtilTextMiddle.display("", getName(), getRaid().getPlayers().toArray(new Player[getRaid().getPlayers().size()])); + } + + public void complete() + { + complete(false); + } + + public void complete(boolean onDisable) + { + if (!onDisable) + { + customComplete(); + } + HandlerList.unregisterAll(this); + _completed = true; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidCreature.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidCreature.java new file mode 100644 index 000000000..7d18b0fdc --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidCreature.java @@ -0,0 +1,16 @@ +package mineplex.game.clans.clans.worldevent.raid; + +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; + +import mineplex.game.clans.clans.worldevent.api.EventCreature; + +public abstract class RaidCreature extends EventCreature +{ + public RaidCreature(RaidWorldEvent event, Location spawnLocation, String name, boolean useName, double health, double walkRange, boolean healthRegen, Class entityClass) + { + super(event, spawnLocation, name, useName, health, walkRange, healthRegen, entityClass); + } + + public abstract void handleDeath(Location location); +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java index 1e406352a..a74b712a5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidManager.java @@ -1,13 +1,159 @@ package mineplex.game.clans.clans.worldevent.raid; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.Consumer; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitTask; import mineplex.core.MiniPlugin; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.projectile.ProjectileManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.utils.UtilScheduler; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.worldevent.raid.command.StartRaidCommand; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.DamageManager; public class RaidManager extends MiniPlugin { + private static final int MAX_PARTICIPANTS = 10; + + private Set _raids = new HashSet<>(); + private List _altars = new ArrayList<>(); + public RaidManager(JavaPlugin plugin) { super("Raid Manager", plugin); + + addCommand(new StartRaidCommand(this)); + } + + @Override + public void disable() + { + _raids.forEach(raid -> raid.stop(true)); + _raids.clear(); + } + + public DisguiseManager getDisguiseManager() + { + return ClansManager.getInstance().getDisguiseManager(); + } + + public ProjectileManager getProjectileManager() + { + return ClansManager.getInstance().getProjectile(); + } + + public DamageManager getDamageManager() + { + return ClansManager.getInstance().getDamageManager(); + } + + public BlockRestore getBlockRestore() + { + return ClansManager.getInstance().getBlockRestore(); + } + + public ConditionManager getConditionManager() + { + return ClansManager.getInstance().getCondition(); + } + + public int getActiveRaids() + { + return _raids.size(); + } + + public boolean isInRaid(Location loc) + { + for (RaidWorldEvent event : _raids) + { + if (event.WorldData.World.equals(loc.getWorld())) + { + return true; + } + } + + return false; + } + + public boolean startRaid(Player player, RaidType type) + { + if (_raids.size() >= 5) + { + UtilPlayer.message(player, F.main(type.getRaidName() + " Raid", "There are currently too many ongoing raids to start a new one!")); + return false; + } + Set inside = UtilPlayer.getInRadius(player.getLocation(), 4).keySet(); + if (inside.size() > MAX_PARTICIPANTS) + { + UtilPlayer.message(player, F.main(type.getRaidName() + " Raid", "You cannot start a raid with more than " + MAX_PARTICIPANTS + " participants!")); + return false; + } + inside.forEach(in -> UtilPlayer.message(in, F.main(type.getRaidName() + " Raid", "Summoning ancient power..."))); + createNewRaid(type, raid -> inside.forEach(in -> + { + raid.addPlayer(player); + player.getWorld().strikeLightningEffect(player.getLocation()); + })); + return true; + } + + public void createNewRaid(RaidType type, Consumer raidConsumer) + { + final WorldData data = new WorldData(type.getRaidName()); + BukkitTask task = UtilScheduler.runEvery(UpdateType.TICK, () -> + { + if (data.Loaded) + { + try + { + RaidWorldEvent event = type.getClazz().getConstructor(WorldData.class, RaidManager.class).newInstance(data, this); + raidConsumer.accept(event); + event.start(); + } + catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) + { + UtilServer.runSyncLater(data::uninitialize, 120); + e.printStackTrace(); + } + while (data.LoadChecker == null) {} + data.LoadChecker.cancel(); + } + }); + data.LoadChecker = task; + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (!event.hasBlock()) + { + return; + } + + for (RaidAltar altar : _altars) + { + if (altar.handleInteract(event.getPlayer(), event.getClickedBlock())) + { + event.setCancelled(true); + return; + } + } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidType.java new file mode 100644 index 000000000..ab655304c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidType.java @@ -0,0 +1,27 @@ +package mineplex.game.clans.clans.worldevent.raid; + +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public enum RaidType +{ + CHARLES_WITHERTON("Charles Witherton", WitherRaid.class); + + private String _raidName; + private Class _clazz; + + private RaidType(String raidName, Class clazz) + { + _raidName = raidName; + _clazz = clazz; + } + + public String getRaidName() + { + return _raidName; + } + + public Class getClazz() + { + return _clazz; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java new file mode 100644 index 000000000..09b0fefae --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/RaidWorldEvent.java @@ -0,0 +1,273 @@ +package mineplex.game.clans.clans.worldevent.raid; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.world.ChunkUnloadEvent; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; +import mineplex.game.clans.clans.worldevent.api.EventState; +import mineplex.game.clans.clans.worldevent.api.WorldEvent; +import mineplex.game.clans.spawn.Spawn; + +public abstract class RaidWorldEvent extends WorldEvent +{ + private static int nextId = 0; + + protected RaidManager Manager; + protected WorldData WorldData; + + protected final int Id; + + protected List Players = new ArrayList<>(); + + protected long _forceEnd = -1; + + public RaidWorldEvent(String name, WorldData data, RaidManager manager) + { + super(name, new Location(data.World, data.MinX + ((data.MaxX - data.MinX) / 2), data.MinY + ((data.MaxY - data.MinY) / 2), data.MinZ + ((data.MaxZ - data.MinZ) / 2)), UtilMath.getMax((data.MaxX - data.MinX) / 2, (data.MaxY - data.MinY) / 2, (data.MaxZ - data.MinZ) / 2), false, manager.getDisguiseManager(), manager.getProjectileManager(), manager.getDamageManager(), manager.getBlockRestore(), manager.getConditionManager()); + + Id = nextId++; + Manager = manager; + WorldData = data; + + loadNecessaryChunks(); + customLoad(); + } + + protected abstract void customLoad(); + + protected abstract void afterTeleportIn(); + + private void loadNecessaryChunks() + { + int minX = WorldData.MinX >> 4; + int minZ = WorldData.MinZ >> 4; + int maxX = WorldData.MaxX >> 4; + int maxZ = WorldData.MaxZ >> 4; + + for (int x = minX; x <= maxX; x++) + { + for (int z = minZ; z <= maxZ; z++) + { + WorldData.World.getChunkAt(x, z); + } + } + } + + public mineplex.game.clans.clans.worldevent.raid.WorldData getWorldData() + { + return WorldData; + } + + public List getPlayers() + { + return Players; + } + + public int getId() + { + return Id; + } + + @Override + public void customStart() + { + _forceEnd = System.currentTimeMillis() + UtilTime.convert(90, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + int spawnIndex = 0; + List spawns = WorldData.SpawnLocs.get("Red"); + for (Player player : Players) + { + if (spawnIndex >= spawns.size()) + { + spawnIndex = 0; + } + player.teleport(spawns.get(spawnIndex)); + spawnIndex++; + } + afterTeleportIn(); + } + + @Override + public void customCleanup(boolean onDisable) + { + Players.forEach(player -> player.teleport(Spawn.getNorthSpawn())); + Players.clear(); + if (onDisable) + { + WorldData.uninitialize(); + } + else + { + UtilServer.runSyncLater(WorldData::uninitialize, 120); + } + } + + public void addPlayer(Player player) + { + Players.add(player); + } + + public void setForceEnd(long end) + { + _forceEnd = end; + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + if (getState() != EventState.LIVE) + { + return; + } + if (Players.isEmpty()) + { + stop(); + } + else + { + updateLastActive(); + } + if (_forceEnd != -1 && System.currentTimeMillis() >= _forceEnd) + { + stop(); + } + } + + @EventHandler + public void onCreatureDeath(EventCreatureDeathEvent event) + { + if (!event.getCreature().getEvent().getName().equals(getName())) + { + return; + } + RaidWorldEvent worldEvent = (RaidWorldEvent) event.getCreature().getEvent(); + if (worldEvent.Id != Id) + { + return; + } + if (event.getCreature() instanceof RaidCreature) + { + ((RaidCreature)event.getCreature()).handleDeath(event.getCreature().getLastKnownLocation()); + } + } + + @EventHandler + public void onChunkUnload(ChunkUnloadEvent event) + { + if (getState() == EventState.STOPPED || this.getState() == EventState.REMOVED) + { + return; + } + if (!event.getWorld().equals(WorldData.World)) + { + return; + } + event.setCancelled(true); + } + + @EventHandler + public void breakBlock(BlockBreakEvent event) + { + Block block = event.getBlock(); + Player player = event.getPlayer(); + + if (player.getGameMode() == GameMode.CREATIVE) + { + return; + } + + if (!block.getWorld().equals(WorldData.World)) + { + return; + } + + event.setCancelled(true); + UtilPlayer.message(player, F.main(getName(), "You cannot build here!")); + } + + @EventHandler + public void placeBlock(BlockPlaceEvent event) + { + Block block = event.getBlock(); + Player player = event.getPlayer(); + + if (player.getGameMode() == GameMode.CREATIVE) + { + return; + } + + if (!block.getWorld().equals(WorldData.World)) + { + return; + } + + event.setCancelled(true); + UtilPlayer.message(player, F.main(getName(), "You cannot build here!")); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onQuit(PlayerQuitEvent event) + { + if (Players.remove(event.getPlayer())) + { + event.getPlayer().teleport(Spawn.getNorthSpawn()); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onDie(PlayerDeathEvent event) + { + if (Players.remove(event.getEntity())) + { + UtilServer.runSyncLater(() -> event.getEntity().teleport(Spawn.getNorthSpawn()), 5); + } + } + + @EventHandler + public void onTpHome(ClansCommandExecutedEvent event) + { + if (event.getCommand().equalsIgnoreCase("tphome") || event.getCommand().equalsIgnoreCase("stuck")) + { + if (Players.contains(event.getPlayer())) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport while in a raid!")); + } + } + } + + @Override + public boolean equals(Object object) + { + if (!(object instanceof RaidWorldEvent)) + { + return false; + } + + return ((RaidWorldEvent)object).getId() == getId(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java index 9aa91a1d4..4eee372c0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/WorldData.java @@ -8,7 +8,6 @@ import java.io.FileInputStream; import java.io.FileWriter; import java.io.InputStreamReader; import java.util.ArrayList; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -17,11 +16,8 @@ import org.bukkit.Difficulty; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.WorldCreator; -import org.spigotmc.SpigotConfig; +import org.bukkit.scheduler.BukkitTask; -import com.mineplex.spigot.ChunkPreLoadEvent; - -import mineplex.core.common.api.enderchest.EnderchestWorldLoader; import mineplex.core.common.timing.TimingManager; import mineplex.core.common.util.FileUtil; import mineplex.core.common.util.MapUtil; @@ -37,6 +33,10 @@ public class WorldData public String RaidName; + public boolean Loaded = false; + + protected BukkitTask LoadChecker = null; + public String File = null; public String Folder = null; @@ -56,27 +56,82 @@ public class WorldData public WorldData(String raidName) { - Initialize(); + initialize(); Id = getNewId(); + RaidName = raidName; } - public void Initialize() + private List loadFiles() { - GetFile(); + TimingManager.start("RaidManager LoadFiles"); + + File folder = new File(".." + java.io.File.separatorChar + ".." + java.io.File.separatorChar + "update" + java.io.File.separatorChar + + "maps" + java.io.File.separatorChar + "Clans" + java.io.File.separatorChar + "Raids" + java.io.File.separatorChar + RaidName); + System.out.println(folder.getAbsolutePath() + " -=-=-=-=-="); + if (!folder.exists()) + { + folder.mkdirs(); + } + + List maps = new ArrayList<>(); + + System.out.println("Searching Maps in: " + folder); + + if (folder.listFiles() != null) + { + for (File file : folder.listFiles()) + { + if (!file.isFile()) + { + System.out.println(file.getName() + " is not a file!"); + continue; + } + + String name = file.getName(); + + if (name.length() < 5) + { + continue; + } + + name = name.substring(name.length() - 4, name.length()); + + if (!name.equals(".zip")) + { + System.out.println(file.getName() + " is not a zip."); + continue; + } + + maps.add(file.getName().substring(0, file.getName().length() - 4)); + } + } + + for (String map : maps) + { + System.out.println("Found Map: " + map); + } + + TimingManager.stop("RaidManager LoadFiles"); + + return maps; + } + + public void initialize() + { + getFile(); UtilServer.runAsync(() -> { - WorldData.this.UnzipWorld(); + WorldData.this.unzipWorld(); UtilServer.runSync(() -> { TimingManager.start("WorldData loading world."); - WorldCreator creator = new WorldCreator(GetFolder()); + WorldCreator creator = new WorldCreator(getFolder()); creator.generator(new WorldGenCleanRoom()); World = WorldUtil.LoadWorld(creator); - TimingManager.stop("WorldData loading world."); World.setDifficulty(Difficulty.HARD); @@ -84,99 +139,63 @@ public class WorldData TimingManager.start("WorldData loading WorldConfig."); //Load World Data - WorldData.this.LoadWorldConfig(); + WorldData.this.loadWorldConfig(); TimingManager.stop("WorldData loading WorldConfig."); }); }); } - protected String GetFile() + protected String getFile() { if (File == null) { - GameType game = null; - int gameRandom = UtilMath.r(Host.GetFiles().size()); - int i = 0; - for(GameType type : Host.GetFiles().keySet()) - { - if(i == gameRandom) - { - game = type; - break; - } - i++; - } - Game = game; int map; try { - map = UtilMath.r(Host.GetFiles().get(game).size()); - } catch (IllegalArgumentException e) + map = UtilMath.r(loadFiles().size()); + } + catch (IllegalArgumentException e) { System.out.println("No maps found!"); return null; } - File = Host.GetFiles().get(game).get(map); - - //Don't allow repeat maps. - if (Host.GetFiles().get(game).size() > 1) - { - while (File.equals(Host.Manager.GetGameCreationManager().GetLastMap())) - { - GameType _game = null; - int _gameRandom = UtilMath.r(Host.GetFiles().size()); - int _i = 0; - for(GameType _type : Host.GetFiles().keySet()) - { - if(_i == _gameRandom) - { - _game = _type; - break; - } - _i++; - } - int _map = UtilMath.r(Host.GetFiles().get(game).size()); - File = Host.GetFiles().get(_game).get(_map); - } - } + File = loadFiles().get(map); } - - Host.Manager.GetGameCreationManager().SetLastMap(File); return File; } - public String GetFolder() + public String getFolder() { if (Folder == null) { - Folder = RaidName + Id + "_" + GetGame().GetName() + "_" + GetFile(); + Folder = RaidName + Id + "_" + getFile(); } return Folder; } - protected void UnzipWorld() + protected void unzipWorld() { TimingManager.start("UnzipWorld creating folders"); - String folder = GetFolder(); + String folder = getFolder(); new File(folder).mkdir(); new File(folder + java.io.File.separator + "region").mkdir(); new File(folder + java.io.File.separator + "data").mkdir(); TimingManager.stop("UnzipWorld creating folders"); TimingManager.start("UnzipWorld UnzipToDirectory"); - ZipUtil.UnzipToDirectory("../../update/maps/" + GetGame().GetName() + "/" + GetFile() + ".zip", folder); + ZipUtil.UnzipToDirectory("../../update/maps/Clans/Raids/" + RaidName + "/" + getFile() + ".zip", folder); TimingManager.stop("UnzipWorld UnzipToDirectory"); } - public void LoadWorldConfig() + public void loadWorldConfig() { //Load Track Data String line = null; try { - FileInputStream fstream = new FileInputStream(GetFolder() + java.io.File.separator + "WorldConfig.dat"); + FileInputStream fstream = new FileInputStream(getFolder() + java.io.File.separator + "WorldConfig.dat"); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); @@ -195,20 +214,10 @@ public class WorldData if (tokens[0].length() == 0) continue; - //Name & Author - if (tokens[0].equalsIgnoreCase("MAP_NAME")) - { - MapName = tokens[1]; - } - else if (tokens[0].equalsIgnoreCase("MAP_AUTHOR")) - { - MapAuthor = tokens[1]; - } - //Spawn Locations - else if (tokens[0].equalsIgnoreCase("TEAM_NAME")) + if (tokens[0].equalsIgnoreCase("TEAM_NAME")) { - SpawnLocs.put(tokens[1], new ArrayList()); + SpawnLocs.put(tokens[1], new ArrayList<>()); currentTeam = SpawnLocs.get(tokens[1]); currentDirection = 0; } @@ -218,9 +227,9 @@ public class WorldData } else if (tokens[0].equalsIgnoreCase("TEAM_SPAWNS")) { - for (int i=1 ; i()); + DataLocs.put(tokens[1], new ArrayList<>()); currentData = DataLocs.get(tokens[1]); } else if (tokens[0].equalsIgnoreCase("DATA_LOCS")) { - for (int i=1 ; i()); + CustomLocs.put(tokens[1], new ArrayList<>()); currentData = CustomLocs.get(tokens[1]); } else if (tokens[0].equalsIgnoreCase("CUSTOM_LOCS")) { - for (int i=1 ; i= MinX >> 4 && x <= MaxX >> 4 && z >= MinZ >> 4 && z <= MaxZ >> 4) - { - return; - } - - event.setCancelled(true); - } public int getNewId() { @@ -461,7 +446,7 @@ public class WorldData { if (!DataLocs.containsKey(data)) { - return new ArrayList(); + return new ArrayList<>(); } return DataLocs.get(data); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/command/StartRaidCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/command/StartRaidCommand.java new file mode 100644 index 000000000..5701d38a2 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/command/StartRaidCommand.java @@ -0,0 +1,42 @@ +package mineplex.game.clans.clans.worldevent.raid.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.worldevent.raid.RaidManager; +import mineplex.game.clans.clans.worldevent.raid.RaidType; + +public class StartRaidCommand extends CommandBase +{ + public StartRaidCommand(RaidManager plugin) + { + super(plugin, Rank.ADMIN, "startraid"); + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: /startraid ")); + return; + } + try + { + RaidType type = RaidType.valueOf(args[0]); + Plugin.startRaid(caller, type); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "That is not an existing raid type. Raids:")); + for (RaidType type : RaidType.values()) + { + UtilPlayer.message(caller, C.cGray + " - " + C.cYellow + type.name()); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/WitherRaid.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/WitherRaid.java new file mode 100644 index 000000000..db88e0286 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/WitherRaid.java @@ -0,0 +1,100 @@ +package mineplex.game.clans.clans.worldevent.raid.wither; + +import java.lang.reflect.InvocationTargetException; +import java.util.LinkedList; +import java.util.List; + +import org.bukkit.Location; + +import mineplex.game.clans.clans.worldevent.api.EventState; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.RaidManager; +import mineplex.game.clans.clans.worldevent.raid.RaidType; +import mineplex.game.clans.clans.worldevent.raid.RaidWorldEvent; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.five.ChallengeFive; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.four.ChallengeFour; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.one.ChallengeOne; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.seven.ChallengeSeven; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.three.ChallengeThree; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.two.ChallengeTwo; + +public class WitherRaid extends RaidWorldEvent +{ + private final List>> _challenges = new LinkedList<>(); + private RaidChallenge _currentChallenge; + + public WitherRaid(mineplex.game.clans.clans.worldevent.raid.WorldData data, RaidManager manager) + { + super(RaidType.CHARLES_WITHERTON.getRaidName(), data, manager); + } + + private void nextChallenge() + { + _currentChallenge = null; + + if (_challenges.isEmpty()) + { + return; + } + + Class> clazz = _challenges.remove(0); + try + { + _currentChallenge = clazz.getConstructor(WitherRaid.class).newInstance(this); + _currentChallenge.start(); + } + catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } + + private void teleportToAltar() + { + Location altar = WorldData.getCustomLocs("MAIN_ALTAR").get(0); + Players.forEach(player -> player.teleport(altar)); + } + + @Override + protected void customLoad() + { + WorldData.World.setGameRuleValue("doDaylightCycle", "false"); + WorldData.World.setTime(14000); + _challenges.add(ChallengeOne.class); + _challenges.add(ChallengeTwo.class); + _challenges.add(ChallengeThree.class); + _challenges.add(ChallengeFour.class); + _challenges.add(ChallengeFive.class); + _challenges.add(ChallengeSix.class); + _challenges.add(ChallengeSeven.class); + } + + @Override + protected void afterTeleportIn() + { + nextChallenge(); + } + + @Override + protected void customTick() + { + if (_currentChallenge != null) + { + if (_currentChallenge.isComplete()) + { + teleportToAltar(); + nextChallenge(); + } + } + } + + @Override + protected void customStop() + { + if (_currentChallenge != null) + { + _currentChallenge.complete(getState() == EventState.REMOVED); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/ChallengeFive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/ChallengeFive.java new file mode 100644 index 000000000..dab6871b4 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/ChallengeFive.java @@ -0,0 +1,164 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.five; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.archer.DecayingArcher; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.corpse.ReanimatedCorpse; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.giant.Goliath; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadKnight; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; + +public class ChallengeFive extends RaidChallenge +{ + private Location _altar; + private boolean _teleported = false; + private LinkedList _gates = new LinkedList<>(); + private Goliath _goliath; + + public ChallengeFive(WitherRaid raid) + { + super(raid, "Rapid Escape"); + + _altar = raid.getWorldData().getCustomLocs("MAIN_ALTAR").get(0); + } + + private void teleportIn() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Run!")); + player.teleport(getRaid().getWorldData().getCustomLocs("C_FIVE_ENTER").get(0)); + }); + } + + @Override + public void customStart() + { + int i = 1; + while (getRaid().getWorldData().getAllCustomLocs().containsKey("C_FIVE_G" + i)) + { + List> creatures = new ArrayList<>(); + for (Location loc : getRaid().getWorldData().getCustomLocs("C_FIVE_G" + i + "G")) + { + int type = UtilMath.r(3) + 1; + if (type == 1) + { + UndeadKnight knight = new UndeadKnight(this, loc); + getRaid().registerCreature(knight); + creatures.add(knight); + } + if (type == 2) + { + ReanimatedCorpse corpse = new ReanimatedCorpse(this, loc); + getRaid().registerCreature(corpse); + creatures.add(corpse); + } + if (type == 3) + { + DecayingArcher archer = new DecayingArcher(this, loc); + getRaid().registerCreature(archer); + creatures.add(archer); + } + } + _gates.add(new IronGate(this, getRaid().getWorldData().getCustomLocs("C_FIVE_G" + i), creatures)); + i++; + } + getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Use the third gate!"))); + } + + @SuppressWarnings("deprecation") + @Override + public void customComplete() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "You made it!")); + player.teleport(_altar); + }); + getRaid().getWorldData().getCustomLocs("GATE_THREE").get(0).getBlock().getRelative(BlockFace.DOWN).setType(Material.OBSIDIAN); + Block gate = getRaid().getWorldData().getCustomLocs("GATE_FOUR").get(0).getBlock(); + gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); + gate.setType(Material.SKULL); + gate.setData((byte)1); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC) + { + for (Player player : getRaid().getPlayers()) + { + if (UtilMath.offset(player.getLocation(), getRaid().getWorldData().getCustomLocs("C_FIVE_EXIT").get(0)) <= 3) + { + complete(); + return; + } + } + } + if (event.getType() == UpdateType.TICK) + { + if (!_gates.isEmpty() && _teleported) + { + IronGate gate = _gates.peek(); + if (UtilMath.offset2d(_goliath.getEntity().getLocation(), gate.getCenter()) > 5) + { + Location to = gate.getCenter().clone(); + to.setY(_goliath.getEntity().getLocation().getY()); + _goliath.getEntity().setVelocity(UtilAlg.getTrajectory(_goliath.getEntity().getLocation(), to).normalize().multiply(0.5)); + } + if (gate.update()) + { + _gates.poll(); + } + } + } + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (!event.hasBlock()) + { + return; + } + + Block clicked = event.getClickedBlock(); + if (!_teleported) + { + if (clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_THREE").get(0).getBlock()) || clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_THREE").get(0).getBlock().getRelative(BlockFace.DOWN))) + { + _teleported = true; + teleportIn(); + } + } + } + + @EventHandler + public void onIcePrison(SkillTriggerEvent event) + { + if (getRaid().getPlayers().contains(event.GetPlayer()) && _teleported && (event.GetSkillName().equals("Ice Prison") || event.GetSkillName().equals("Fissure"))) + { + event.SetCancelled(true); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/IronGate.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/IronGate.java new file mode 100644 index 000000000..d9940e37c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/five/IronGate.java @@ -0,0 +1,82 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.five; + +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; + +import mineplex.game.clans.clans.worldevent.api.EventCreature; + +public class IronGate +{ + private ChallengeFive _challenge; + private List _corners; + private List> _guardians; + + public IronGate(ChallengeFive challenge, List corners, List> guardians) + { + _challenge = challenge; + _corners = corners; + _guardians = guardians; + } + + private void open() + { + Location pos1 = _corners.get(0); + Location pos2 = _corners.get(1); + int minX = Math.min(pos1.getBlockX(), pos2.getBlockX()); + int maxX = Math.max(pos1.getBlockX(), pos2.getBlockX()); + int minY = Math.min(pos1.getBlockY(), pos2.getBlockY()); + int maxY = Math.max(pos1.getBlockY(), pos2.getBlockY()) + 3; + int minZ = Math.min(pos1.getBlockZ(), pos2.getBlockZ()); + int maxZ = Math.max(pos1.getBlockZ(), pos2.getBlockZ()); + + for (int x = minX; x <= maxX; x++) + { + for (int y = minY; y <= maxY; y++) + { + for (int z = minZ; z <= maxZ; z++) + { + Block block = _challenge.getRaid().getWorldData().World.getBlockAt(x, y, z); + if (block.getType() == Material.IRON_FENCE) + { + block.setType(Material.AIR); + } + } + } + } + } + + public Location getCenter() + { + Location pos1 = _corners.get(0); + Location pos2 = _corners.get(1); + int minX = Math.min(pos1.getBlockX(), pos2.getBlockX()); + int maxX = Math.max(pos1.getBlockX(), pos2.getBlockX()); + int minY = Math.min(pos1.getBlockY(), pos2.getBlockY()); + int maxY = Math.max(pos1.getBlockY(), pos2.getBlockY()) + 3; + int minZ = Math.min(pos1.getBlockZ(), pos2.getBlockZ()); + int maxZ = Math.max(pos1.getBlockZ(), pos2.getBlockZ()); + + return new Location(_challenge.getRaid().getWorldData().World, minX + ((maxX - minX) / 2), minY + ((maxY - minY) / 2), minZ + ((maxZ - minZ) / 2)); + } + + public boolean update() + { + int alive = 0; + for (EventCreature guardian : _guardians) + { + if (guardian.getHealth() > 0) + { + alive++; + } + } + if (alive < 0) + { + open(); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/ChallengeFour.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/ChallengeFour.java new file mode 100644 index 000000000..7112c0885 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/ChallengeFour.java @@ -0,0 +1,139 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.four; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.silverfish.PitSwarmer; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; + +public class ChallengeFour extends RaidChallenge +{ + private Location _altar; + private boolean _teleported = false; + private List _blocks = new ArrayList<>(); + + public ChallengeFour(WitherRaid raid) + { + super(raid, "Infested Pits"); + + _altar = raid.getWorldData().getCustomLocs("MAIN_ALTAR").get(0); + } + + private void teleportIn() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Complete the parkour!")); + player.teleport(getRaid().getWorldData().getCustomLocs("C_FOUR_ENTER").get(0)); + }); + Location pos1 = getRaid().getWorldData().getCustomLocs("C_FOUR_SF").get(0); + Location pos2 = getRaid().getWorldData().getCustomLocs("C_FOUR_SF").get(1); + int minX = Math.min(pos1.getBlockX(), pos2.getBlockX()); + int maxX = Math.max(pos1.getBlockX(), pos2.getBlockX()); + int minY = Math.min(pos1.getBlockY(), pos2.getBlockY()); + int maxY = Math.max(pos1.getBlockY(), pos2.getBlockY()); + int minZ = Math.min(pos1.getBlockZ(), pos2.getBlockZ()); + int maxZ = Math.max(pos1.getBlockZ(), pos2.getBlockZ()); + + for (int x = minX; x <= maxX; x++) + { + for (int y = minY; y <= maxY; y++) + { + for (int z = minZ; z <= maxZ; z++) + { + Block block = getRaid().getWorldData().World.getBlockAt(x, y, z); + getRaid().registerCreature(new PitSwarmer(this, block.getLocation())); + } + } + } + } + + @Override + public void customStart() + { + for (Location loc : getRaid().getWorldData().getCustomLocs("C_FOUR_FB")) + { + loc.getBlock().setType(Material.NETHER_BRICK); + } + getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Use the second gate!"))); + } + + @SuppressWarnings("deprecation") + @Override + public void customComplete() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Excellent jumping!")); + player.teleport(_altar); + }); + getRaid().getWorldData().getCustomLocs("GATE_TWO").get(0).getBlock().getRelative(BlockFace.DOWN).setType(Material.OBSIDIAN); + Block gate = getRaid().getWorldData().getCustomLocs("GATE_THREE").get(0).getBlock(); + gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); + gate.setType(Material.SKULL); + gate.setData((byte)1); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC) + { + for (Player player : getRaid().getPlayers()) + { + if (UtilMath.offset(player.getLocation(), getRaid().getWorldData().getCustomLocs("C_FOUR_EXIT").get(0)) <= 3) + { + complete(); + return; + } + } + } + if (event.getType() == UpdateType.TICK) + { + _blocks.forEach(FakeBlock::update); + } + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (!event.hasBlock()) + { + return; + } + + Block clicked = event.getClickedBlock(); + if (!_teleported) + { + if (clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_TWO").get(0).getBlock()) || clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_TWO").get(0).getBlock().getRelative(BlockFace.DOWN))) + { + _teleported = true; + teleportIn(); + } + } + } + + @EventHandler + public void onIcePrison(SkillTriggerEvent event) + { + if (getRaid().getPlayers().contains(event.GetPlayer()) && _teleported) + { + event.SetCancelled(true); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/FakeBlock.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/FakeBlock.java new file mode 100644 index 000000000..371bec25e --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/four/FakeBlock.java @@ -0,0 +1,37 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.four; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; + +public class FakeBlock +{ + private ChallengeFour _challenge; + private Block _block; + + public FakeBlock(ChallengeFour challenge, Block block) + { + _challenge = challenge; + _block = block; + _block.setType(Material.NETHER_BRICK); + } + + public void update() + { + boolean aired = false; + for (Player player : _challenge.getRaid().getPlayers()) + { + if (player.getLocation().getBlock().getRelative(BlockFace.DOWN).equals(_block)) + { + _block.setType(Material.AIR); + aired = true; + } + } + + if (!aired) + { + _block.setType(Material.NETHER_BRICK); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/one/ChallengeOne.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/one/ChallengeOne.java new file mode 100644 index 000000000..1edc07d61 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/one/ChallengeOne.java @@ -0,0 +1,104 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.one; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class ChallengeOne extends RaidChallenge +{ + private Location _altar; + private Player _trigger; + + public ChallengeOne(WitherRaid raid) + { + super(raid, "Entering Hell"); + + _altar = raid.getWorldData().getCustomLocs("MAIN_ALTAR").get(0); + } + + private void sealDoor() + { + Location doorBase1 = getRaid().getWorldData().getCustomLocs("C_ONE_TRAP").get(0); + Location doorBase2 = getRaid().getWorldData().getCustomLocs("C_ONE_TRAP").get(1); + int minX = Math.min(doorBase1.getBlockX(), doorBase2.getBlockX()); + int maxX = Math.max(doorBase1.getBlockX(), doorBase2.getBlockX()); + int minY = Math.min(doorBase1.getBlockY(), doorBase2.getBlockY()); + int maxY = Math.max(doorBase1.getBlockY(), doorBase2.getBlockY()) + 1; + int minZ = Math.min(doorBase1.getBlockZ(), doorBase2.getBlockZ()); + int maxZ = Math.max(doorBase1.getBlockZ(), doorBase2.getBlockZ()); + + for (int x = minX; x <= maxX; x++) + { + for (int y = minY; y <= maxY; y++) + { + for (int z = minZ; z <= maxZ; z++) + { + Block block = getRaid().getWorldData().World.getBlockAt(x, y, z); + block.setType(Material.NETHER_BRICK); + } + } + } + } + + private void setupStoneBrickTraps() + { + for (Location loc : getRaid().getWorldData().getCustomLocs("C_ONE_SBT")) + { + Block b = loc.getBlock(); + b.setType(Material.SMOOTH_BRICK); + b.getRelative(BlockFace.UP).setType(Material.SMOOTH_BRICK); + } + } + + @Override + public void customStart() + { + setupStoneBrickTraps(); + getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Enter the Altar Room"))); + } + + @Override + public void customComplete() + { + getRaid().getPlayers().forEach(player -> + { + player.getWorld().strikeLightningEffect(player.getLocation()); + if (_trigger != null) + { + if (UtilMath.offset(player.getLocation(), _altar) >= 17) + { + player.teleport(_trigger); + } + } + }); + sealDoor(); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC) + { + for (Player player : getRaid().getPlayers()) + { + if (UtilMath.offset(player.getLocation(), _altar) <= 5) + { + _trigger = player; + complete(); + return; + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java new file mode 100644 index 000000000..9fadaa068 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/seven/ChallengeSeven.java @@ -0,0 +1,161 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.seven; + +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadKnight; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.wither.CharlesWitherton; + +public class ChallengeSeven extends RaidChallenge +{ + private Location _altar; + private boolean _teleported = false; + private boolean _bottomLayer = false; + private CharlesWitherton _charlie; + private long _lastKnightRespawn; + + public ChallengeSeven(WitherRaid raid) + { + super(raid, "The Final Battle"); + + _altar = raid.getWorldData().getCustomLocs("MAIN_ALTAR").get(0); + } + + private void teleportToBottom() + { + _charlie.getEntity().teleport(getRaid().getWorldData().getCustomLocs("C_SEVEN_RWC").get(0)); + for (Player player : getRaid().getPlayers()) + { + player.teleport(getRaid().getWorldData().getCustomLocs("C_SEVEN_RWC").get(0)); + } + } + + private void teleportIn() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName(), "GUARDS! ATTACK!")); + player.teleport(getRaid().getWorldData().getCustomLocs("C_SEVEN_ENTER").get(0)); + }); + for (Location loc : getRaid().getWorldData().getCustomLocs("C_SEVEN_UK")) + { + getRaid().registerCreature(new UndeadKnight(this, loc)); + } + _lastKnightRespawn = System.currentTimeMillis(); + _charlie = new CharlesWitherton(this, getRaid().getWorldData().getCustomLocs("C_SEVEN_CHARLES").get(0)); + getRaid().registerCreature(_charlie); + for (Location loc : getRaid().getWorldData().getCustomLocs("C_SEVEN_UK")) + { + getRaid().registerCreature(new UndeadKnight(this, loc)); + } + } + + @Override + public void customStart() + { + getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Use the final gate!"))); + } + + @Override + public void customComplete() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "The evil reign of Charles Witherton is over! You will be returned to spawn in 2 minutes!")); + player.teleport(_altar); + }); + List anim = UtilShapes.getCircle(_altar.clone().add(0, 2, 0), true, 3); + int emeralds = UtilMath.rRange((int)Math.ceil(45 / anim.size()), (int)Math.ceil(80 / anim.size())); + for (Location drop : anim) + { + ClansManager.getInstance().getLootManager().dropRare(drop); + drop.getWorld().dropItem(drop, new ItemStack(Material.EMERALD, emeralds)); + } + getRaid().getWorldData().getCustomLocs("GATE_FIVE").get(0).getBlock().getRelative(BlockFace.DOWN).setType(Material.OBSIDIAN); + getRaid().setForceEnd(System.currentTimeMillis() + UtilTime.convert(2, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)); + } + + @EventHandler + public void onDeath(EventCreatureDeathEvent event) + { + if (event.getCreature() instanceof CharlesWitherton) + { + if (((WitherRaid)event.getCreature().getEvent()).getId() == getRaid().getId()) + { + complete(); + } + } + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (!event.hasBlock()) + { + return; + } + + Block clicked = event.getClickedBlock(); + if (!_teleported) + { + if (clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_FIVE").get(0).getBlock()) || clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_FIVE").get(0).getBlock().getRelative(BlockFace.DOWN))) + { + _teleported = true; + teleportIn(); + } + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC) + { + if (_teleported && !_bottomLayer && _charlie != null) + { + if (_charlie.getHealthPercent() <= 0.75) + { + _bottomLayer = true; + teleportToBottom(); + return; + } + + if (UtilTime.elapsed(_lastKnightRespawn, 30000)) + { + _lastKnightRespawn = System.currentTimeMillis(); + long knights = getRaid().getCreatures().stream().filter(UndeadKnight.class::isInstance).count(); + int total = getRaid().getWorldData().getCustomLocs("C_SEVEN_UK").size(); + if (knights < total) + { + long needed = total - knights; + for (int i = 0; i < needed; i++) + { + Location loc = getRaid().getWorldData().getCustomLocs("C_SEVEN_UK").get(i); + getRaid().registerCreature(new UndeadKnight(this, loc)); + } + } + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/six/ChallengeSix.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/six/ChallengeSix.java new file mode 100644 index 000000000..46d3526b3 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/six/ChallengeSix.java @@ -0,0 +1,94 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.six; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.magma.Magmus; + +public class ChallengeSix extends RaidChallenge +{ + private Location _altar; + private boolean _teleported = false; + + public ChallengeSix(WitherRaid raid) + { + super(raid, "Fiery Gates"); + + _altar = raid.getWorldData().getCustomLocs("MAIN_ALTAR").get(0); + } + + private void teleportIn() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Slay the gatekeeper or perish!")); + player.teleport(getRaid().getWorldData().getCustomLocs("C_SIX_ENTER").get(0)); + }); + getRaid().registerCreature(new Magmus(this, getRaid().getWorldData().getCustomLocs("C_SIX_MCS").get(0))); + } + + @Override + public void customStart() + { + getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Use the fourth gate!"))); + } + + @SuppressWarnings("deprecation") + @Override + public void customComplete() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Your final battle awaits!")); + player.teleport(_altar); + }); + getRaid().getWorldData().getCustomLocs("GATE_FOUR").get(0).getBlock().getRelative(BlockFace.DOWN).setType(Material.OBSIDIAN); + Block gate = getRaid().getWorldData().getCustomLocs("GATE_FIVE").get(0).getBlock(); + gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); + gate.setType(Material.SKULL); + gate.setData((byte)1); + _altar.getWorld().dropItem(_altar.clone().add(0, 2, 0), new ItemStack(Material.EMERALD, UtilMath.rRange(15, 20))); + } + + @EventHandler + public void onDeath(EventCreatureDeathEvent event) + { + if (event.getCreature() instanceof Magmus) + { + if (((WitherRaid)event.getCreature().getEvent()).getId() == getRaid().getId()) + { + complete(); + } + } + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (!event.hasBlock()) + { + return; + } + + Block clicked = event.getClickedBlock(); + if (!_teleported) + { + if (clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_FOUR").get(0).getBlock()) || clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_FOUR").get(0).getBlock().getRelative(BlockFace.DOWN))) + { + _teleported = true; + teleportIn(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeThree.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeThree.java new file mode 100644 index 000000000..99daf36c0 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeThree.java @@ -0,0 +1,125 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.three; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.archer.DecayingArcher; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.corpse.ReanimatedCorpse; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadMage; + +public class ChallengeThree extends RaidChallenge +{ + private Location _altar; + private boolean _teleported = false; + private List _torches = new ArrayList<>(); + protected int LitTorches; + private long _lastSpawn; + + public ChallengeThree(WitherRaid raid) + { + super(raid, "Light The Fires"); + + _altar = raid.getWorldData().getCustomLocs("MAIN_ALTAR").get(0); + LitTorches = 0; + } + + private void teleportIn() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Light the torches!")); + player.teleport(getRaid().getWorldData().getCustomLocs("C_THREE_ENTER").get(0)); + }); + getRaid().registerCreature(new UndeadMage(this, getRaid().getWorldData().getCustomLocs("C_THREE_UM").get(0), true, getRaid().getWorldData().getCustomLocs("C_THREE_UMS"), getRaid().getWorldData().getCustomLocs("C_THREE_UMT"))); + } + + @Override + public void customStart() + { + for (Location loc : getRaid().getWorldData().getCustomLocs("C_THREE_TORCH")) + { + loc.getBlock().setType(Material.NETHERRACK); + _torches.add(new ChallengeTorch(this, loc.getBlock())); + } + getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "Use the first gate!"))); + } + + @SuppressWarnings("deprecation") + @Override + public void customComplete() + { + getRaid().getPlayers().forEach(player -> + { + UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "The Torches are lit!")); + player.teleport(_altar); + }); + getRaid().getWorldData().getCustomLocs("GATE_ONE").get(0).getBlock().getRelative(BlockFace.DOWN).setType(Material.OBSIDIAN); + Block gate = getRaid().getWorldData().getCustomLocs("GATE_TWO").get(0).getBlock(); + gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); + gate.setType(Material.SKULL); + gate.setData((byte)1); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC) + { + if (LitTorches >= 4) + { + complete(); + } + } + if (event.getType() == UpdateType.TICK) + { + _torches.forEach(ChallengeTorch::update); + if (UtilTime.elapsed(_lastSpawn, 7000) && _teleported) + { + _lastSpawn = System.currentTimeMillis(); + getRaid().getWorldData().getCustomLocs("C_THREE_RC").forEach(loc -> + { + getRaid().registerCreature(new ReanimatedCorpse(this, loc)); + }); + getRaid().getWorldData().getCustomLocs("C_THREE_DA").forEach(loc -> + { + getRaid().registerCreature(new DecayingArcher(this, loc)); + }); + } + } + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (!event.hasBlock()) + { + return; + } + + Block clicked = event.getClickedBlock(); + if (!_teleported) + { + if (clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_ONE").get(0).getBlock()) || clicked.equals(getRaid().getWorldData().getCustomLocs("GATE_ONE").get(0).getBlock().getRelative(BlockFace.DOWN))) + { + _lastSpawn = System.currentTimeMillis(); + _teleported = true; + teleportIn(); + } + } + _torches.forEach(torch -> torch.handleInteract(clicked)); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeTorch.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeTorch.java new file mode 100644 index 000000000..08482b694 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/three/ChallengeTorch.java @@ -0,0 +1,42 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.three; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; + +public class ChallengeTorch +{ + private ChallengeThree _challenge; + private Block _block; + private long _extinguish; + + public ChallengeTorch(ChallengeThree challenge, Block block) + { + _challenge = challenge; + _block = block; + _extinguish = -1; + } + + public void handleInteract(Block block) + { + if (block.equals(_block)) + { + _challenge.LitTorches++; + _extinguish = System.currentTimeMillis() + 3000; + _block.getRelative(BlockFace.UP).setType(Material.FIRE); + } + } + + public void update() + { + if (_extinguish != -1 && !_challenge.isComplete()) + { + if (_extinguish < System.currentTimeMillis()) + { + _extinguish = -1; + _challenge.LitTorches--; + _block.getRelative(BlockFace.UP).setType(Material.AIR); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/two/ChallengeTwo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/two/ChallengeTwo.java new file mode 100644 index 000000000..a18665263 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/challenge/two/ChallengeTwo.java @@ -0,0 +1,72 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.challenge.two; + +import org.bukkit.DyeColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.worldevent.api.EventCreatureDeathEvent; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadKnight; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadMage; + +public class ChallengeTwo extends RaidChallenge +{ + private Location _altar; + + public ChallengeTwo(WitherRaid raid) + { + super(raid, "Undead Encounter"); + + _altar = raid.getWorldData().getCustomLocs("MAIN_ALTAR").get(0); + } + + private void openStoneBrickTraps() + { + for (Location loc : getRaid().getWorldData().getCustomLocs("C_ONE_SBT")) + { + Block b = loc.getBlock(); + b.setType(Material.AIR); + b.getRelative(BlockFace.UP).setType(Material.AIR); + getRaid().registerCreature(new UndeadKnight(this, loc)); + } + } + + @SuppressWarnings("deprecation") + @Override + public void customStart() + { + openStoneBrickTraps(); + _altar.getBlock().getRelative(BlockFace.DOWN).setData(DyeColor.BLACK.getWoolData()); + getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main("Undead Mage", "MINIONS, ATTACK!"))); + getRaid().registerCreature(new UndeadMage(this, _altar, false, getRaid().getWorldData().getCustomLocs("C_ONE_SBT"), getRaid().getWorldData().getCustomLocs("C_TWO_MTP"))); + } + + @SuppressWarnings("deprecation") + @Override + public void customComplete() + { + getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getRaid().getName() + " Raid", "The Undead Mage has fallen!"))); + Block gate = getRaid().getWorldData().getCustomLocs("GATE_ONE").get(0).getBlock(); + gate.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE); + gate.setType(Material.SKULL); + gate.setData((byte)1); + } + + @EventHandler + public void onDeath(EventCreatureDeathEvent event) + { + if (event.getCreature() instanceof UndeadMage) + { + if (((WitherRaid)event.getCreature().getEvent()).getId() == getRaid().getId()) + { + complete(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/ArcherShooting.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/ArcherShooting.java new file mode 100644 index 000000000..de8ded9ec --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/ArcherShooting.java @@ -0,0 +1,94 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.archer; + +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossAbility; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class ArcherShooting extends BossAbility +{ + private long _lastShoot; + private long _lastRope; + + public ArcherShooting(DecayingArcher creature) + { + super(creature); + + _lastShoot = System.currentTimeMillis(); + _lastRope = System.currentTimeMillis(); + } + + @Override + public void tick() + { + if (getEntity().getTarget() != null) + { + if (UtilTime.elapsed(_lastRope, 10000)) + { + _lastRope = System.currentTimeMillis(); + UtilEnt.LookAt(getEntity(), getEntity().getTarget().getEyeLocation()); + UtilEnt.addFlag(getEntity().launchProjectile(Arrow.class), "ROPED_ARROW"); + return; + } + if (UtilTime.elapsed(_lastShoot, 2000)) + { + _lastShoot = System.currentTimeMillis(); + UtilEnt.LookAt(getEntity(), getEntity().getTarget().getEyeLocation()); + getEntity().launchProjectile(Arrow.class); + } + } + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE) == null) + { + return; + } + LivingEntity ent = event.GetDamagerEntity(event.GetCause() == DamageCause.PROJECTILE); + if (ent.getEntityId() == getEntity().getEntityId()) + { + if (event.GetCause() != DamageCause.PROJECTILE) + { + event.SetCancelled("Archer Only"); + return; + } + if (UtilEnt.hasFlag(event.GetProjectile(), "ROPED_ARROW")) + { + ent.setVelocity(UtilAlg.getTrajectory(ent, event.GetDamageeEntity()).normalize()); + event.AddMod("Roped Arrow", -event.GetDamage()); + return; + } + event.AddMod("Ranged Attack", 2 - event.GetDamage()); + } + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public boolean inProgress() + { + return false; + } + + @Override + public boolean hasFinished() + { + return false; + } + + @Override + public void setFinished() {} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/DecayingArcher.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/DecayingArcher.java new file mode 100644 index 000000000..13e5bfd46 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/archer/DecayingArcher.java @@ -0,0 +1,65 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.archer; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class DecayingArcher extends EventCreature +{ + private RaidChallenge _challenge; + private ArcherShooting _passive; + + public DecayingArcher(RaidChallenge challenge, Location location) + { + super(challenge.getRaid(), location, "Decaying Archer", true, 10, 100, true, Zombie.class); + + _challenge = challenge; + spawnEntity(); + _passive = new ArcherShooting(this); + } + + @Override + protected void spawnCustom() + { + getEntity().getEquipment().setItemInHand(new ItemStack(Material.BOW)); + getEntity().getEquipment().setItemInHandDropChance(0f); + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + HandlerList.unregisterAll(_passive); + _passive = null; + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + _passive.tick(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/CorpsePassive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/CorpsePassive.java new file mode 100644 index 000000000..f08d0ed32 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/CorpsePassive.java @@ -0,0 +1,43 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.corpse; + +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; + +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class CorpsePassive extends BossPassive +{ + public CorpsePassive(ReanimatedCorpse creature) + { + super(creature); + } + + @Override + public int getCooldown() + { + return 0; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() {} + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamagerEntity(false) == null) + { + return; + } + if (event.GetDamagerEntity(false).getEntityId() == getEntity().getEntityId()) + { + event.AddMod("Corpse Attack", 1 - event.GetDamage()); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/ReanimatedCorpse.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/ReanimatedCorpse.java new file mode 100644 index 000000000..debf12fa7 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/corpse/ReanimatedCorpse.java @@ -0,0 +1,67 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.corpse; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class ReanimatedCorpse extends EventCreature +{ + private static final Material[] SWORDS = {Material.WOOD_SWORD, Material.STONE_SWORD, Material.GOLD_SWORD, Material.IRON_SWORD, Material.DIAMOND_SWORD}; + private RaidChallenge _challenge; + private CorpsePassive _passive; + + public ReanimatedCorpse(RaidChallenge challenge, Location location) + { + super(challenge.getRaid(), location, "Reanimated Corpse", true, 15, 100, true, Zombie.class); + + _challenge = challenge; + spawnEntity(); + _passive = new CorpsePassive(this); + } + + @Override + protected void spawnCustom() + { + getEntity().getEquipment().setItemInHand(new ItemStack(UtilMath.randomElement(SWORDS))); + getEntity().getEquipment().setItemInHandDropChance(0f); + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + HandlerList.unregisterAll(_passive); + _passive = null; + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + _passive.tick(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/Goliath.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/Goliath.java new file mode 100644 index 000000000..d5de7b8c2 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/Goliath.java @@ -0,0 +1,59 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.giant; + +import org.bukkit.Location; +import org.bukkit.entity.Giant; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class Goliath extends EventCreature +{ + private RaidChallenge _challenge; + private GoliathPassive _passive; + + public Goliath(RaidChallenge challenge, Location location) + { + super(challenge.getRaid(), location, "Goliath", true, 5000, 500, true, Giant.class); + + _challenge = challenge; + spawnEntity(); + _passive = new GoliathPassive(this); + } + + @Override + protected void spawnCustom() {} + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + HandlerList.unregisterAll(_passive); + _passive = null; + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + _passive.tick(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/GoliathPassive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/GoliathPassive.java new file mode 100644 index 000000000..1551a9fc9 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/giant/GoliathPassive.java @@ -0,0 +1,60 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.giant; + +import org.bukkit.entity.Giant; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class GoliathPassive extends BossPassive +{ + public GoliathPassive(Goliath creature) + { + super(creature); + } + + @Override + public int getCooldown() + { + return 0; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + for (Player player : ((WitherRaid)getBoss().getEvent()).getPlayers()) + { + if (UtilPlayer.isSpectator(player) || player.isDead() || !player.isValid()) + { + continue; + } + if (UtilMath.offset(getEntity(), player) <= 7) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null, DamageCause.ENTITY_ATTACK, 100, false, true, true, getEntity().getName(), "Smash"); + } + } + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity() != null) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + event.SetCancelled("Giant Invulnerability"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/KnightPassive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/KnightPassive.java new file mode 100644 index 000000000..207184797 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/KnightPassive.java @@ -0,0 +1,67 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.mage; + +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityShootBowEvent; + +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class KnightPassive extends BossPassive +{ + private long _lastUsed; + + public KnightPassive(UndeadKnight creature) + { + super(creature); + + _lastUsed = System.currentTimeMillis(); + } + + @Override + public int getCooldown() + { + return 12; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() {} + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamagerEntity(false) == null) + { + return; + } + if (event.GetDamagerEntity(false).getEntityId() == getEntity().getEntityId()) + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + _lastUsed = System.currentTimeMillis(); + event.AddMod("Hilt Smash", 1 - event.GetDamage()); + getBoss().getEvent().getCondition().Factory().Slow("Hilt Smash", event.GetDamageeEntity(), event.GetDamagerEntity(false), 2, 1, false, true, false, true); + } + else + { + event.AddMod("Knight Attack", 1 - event.GetDamage()); + } + } + } + + @EventHandler + public void onShoot(EntityShootBowEvent event) + { + if (event.getEntity().getEntityId() == getEntity().getEntityId()) + { + event.setCancelled(true); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBlink.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBlink.java new file mode 100644 index 000000000..2974f216d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBlink.java @@ -0,0 +1,67 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.mage; + +import java.util.List; +import java.util.stream.Collectors; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; + +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.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; + +public class MageBlink extends BossPassive +{ + private List _spots; + private long _lastUsed; + + public MageBlink(UndeadMage creature, List teleportSpots) + { + super(creature); + + _spots = teleportSpots; + _lastUsed = System.currentTimeMillis(); + } + + @Override + public int getCooldown() + { + return 7; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + _lastUsed = System.currentTimeMillis(); + List tp = null; + if (_spots != null) + { + tp = _spots.stream().filter(spot -> UtilMath.offset(getLocation(), spot) <= 10).collect(Collectors.toList()); + } + else + { + tp = getBoss().getPlayers(UtilPlayer.getInRadius(getLocation(), 10), 10).stream().map(Player::getLocation).collect(Collectors.toList()); + } + if (tp != null && !tp.isEmpty()) + { + Location to = UtilMath.randomElement(tp); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getEntity().getLocation(), null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, to, null, 0, 2, ViewDist.MAX); + getEntity().teleport(to); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBolt.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBolt.java new file mode 100644 index 000000000..bff678973 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageBolt.java @@ -0,0 +1,86 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.mage; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +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.game.clans.clans.worldevent.api.BossPassive; + +public class MageBolt extends BossPassive +{ + private static final double RANGE = 10; + private long _lastUsed; + + public MageBolt(UndeadMage creature) + { + super(creature); + _lastUsed = System.currentTimeMillis(); + } + + private void shootBolt(Player target) + { + double curRange = 0; + boolean canHit = true; + + while (curRange <= RANGE) + { + Location newTarget = getEntity().getEyeLocation().add(UtilAlg.getTrajectory(getEntity(), target).multiply(curRange)); + + if (!UtilBlock.airFoliage(newTarget.getBlock())) + { + canHit = false; + break; + } + if (UtilMath.offset(newTarget, target.getLocation()) <= 0.9) + { + break; + } + + curRange += 0.2; + + UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, newTarget, 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); + } + + if (canHit) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.CUSTOM, 2.5, true, true, false, getEntity().getName(), "Mystical Energy"); + } + } + + @Override + public int getCooldown() + { + return 3; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + Player target = UtilMath.randomElement(getBoss().getPlayers(UtilPlayer.getInRadius(getLocation(), RANGE), RANGE)); + if (target != null) + { + _lastUsed = System.currentTimeMillis(); + shootBolt(target); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageSummon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageSummon.java new file mode 100644 index 000000000..09bb949e9 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/MageSummon.java @@ -0,0 +1,80 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.mage; + +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.entity.Skeleton; + +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.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class MageSummon extends BossPassive +{ + private final int MAX_KNIGHTS; + private static final int KNIGHTS_PER_USE = 6; + private long _lastUsed; + private List _spawnLocations; + + public MageSummon(UndeadMage creature, List spawnLocations) + { + super(creature); + + _lastUsed = System.currentTimeMillis(); + MAX_KNIGHTS = spawnLocations.size(); + _spawnLocations = spawnLocations; + } + + private void spawnKnight() + { + Location spawn = null; + if (_spawnLocations != null) + { + spawn = UtilMath.randomElement(_spawnLocations); + } + else + { + spawn = getLocation(); + } + getBoss().getEvent().registerCreature(new UndeadKnight(getBoss().getChallenge(), spawn)); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, spawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, spawn, null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, getLocation(), null, 0, 2, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.SMOKE, getLocation(), null, 0, 2, ViewDist.MAX); + } + + @Override + public int getCooldown() + { + return 30; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (!UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + return; + } + long amount = ((WitherRaid)getBoss().getEvent()).getCreatures().stream().filter(UndeadKnight.class::isInstance).count(); + if (amount < MAX_KNIGHTS) + { + _lastUsed = System.currentTimeMillis(); + long spawnAmount = Math.min(MAX_KNIGHTS - amount, KNIGHTS_PER_USE); + for (int i = 0; i < spawnAmount; i++) + { + spawnKnight(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadKnight.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadKnight.java new file mode 100644 index 000000000..62456eda6 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadKnight.java @@ -0,0 +1,71 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.mage; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class UndeadKnight extends EventCreature +{ + private RaidChallenge _challenge; + private KnightPassive _passive; + + public UndeadKnight(RaidChallenge challenge, Location location) + { + super(challenge.getRaid(), location, "Undead Knight", true, 25, 100, true, Skeleton.class); + + _challenge = challenge; + spawnEntity(); + _passive = new KnightPassive(this); + } + + @Override + protected void spawnCustom() + { + getEntity().getEquipment().setItemInHand(new ItemStack(Material.STONE_SWORD)); + getEntity().getEquipment().setItemInHandDropChance(0f); + getEntity().getEquipment().setHelmet(new ItemBuilder(Material.CHAINMAIL_HELMET).setUnbreakable(true).build()); + getEntity().getEquipment().setHelmetDropChance(0f); + getEntity().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 100000000, 0)); + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + HandlerList.unregisterAll(_passive); + _passive = null; + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + _passive.tick(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadMage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadMage.java new file mode 100644 index 000000000..428bfa30f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/mage/UndeadMage.java @@ -0,0 +1,171 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.mage; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.RaidCreature; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class UndeadMage extends RaidCreature +{ + private RaidChallenge _challenge; + private List> _abilities; + private boolean _invuln; + + public UndeadMage(RaidChallenge challenge, Location location, boolean invulnerable, List spawnLocations, List blinkLocations) + { + super(challenge.getRaid(), location, "Undead Mage", true, 200, 5, true, Skeleton.class); + + _challenge = challenge; + _invuln = invulnerable; + spawnEntity(); + _abilities = new ArrayList<>(); + _abilities.add(new MageSummon(this, spawnLocations)); + _abilities.add(new MageBlink(this, blinkLocations)); + _abilities.add(new MageBolt(this)); + } + + @Override + protected void spawnCustom() + { + UtilEnt.vegetate(getEntity()); + getEntity().setSkeletonType(SkeletonType.WITHER); + getEntity().getEquipment().setItemInHand(new ItemStack(Material.RECORD_6)); //Meridian Scepter + getEntity().getEquipment().setItemInHandDropChance(0f); + getEntity().getEquipment().setHelmet(new ItemBuilder(Material.GOLD_HELMET).setUnbreakable(true).build()); + getEntity().getEquipment().setChestplate(new ItemBuilder(Material.GOLD_CHESTPLATE).setUnbreakable(true).build()); + getEntity().getEquipment().setLeggings(new ItemBuilder(Material.GOLD_LEGGINGS).setUnbreakable(true).build()); + getEntity().getEquipment().setBoots(new ItemBuilder(Material.GOLD_BOOTS).setUnbreakable(true).build()); + getEntity().getEquipment().setHelmetDropChance(0f); + getEntity().getEquipment().setChestplateDropChance(0f); + getEntity().getEquipment().setLeggingsDropChance(0f); + getEntity().getEquipment().setBootsDropChance(0f); + } + + public RaidChallenge getChallenge() + { + return _challenge; + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + for (BossPassive ability : _abilities) + { + HandlerList.unregisterAll(ability); + } + _abilities.clear(); + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + _abilities.forEach(BossPassive::tick); + } + + protected List getPlayers(Map map, double maxDist) + { + return getPlayers(map, 0, maxDist); + } + + protected List getPlayers(final Map map, double minDist, double maxDist) + { + List list = new ArrayList<>(); + + for (Player p : map.keySet()) + { + if (!_challenge.getRaid().getPlayers().contains(p)) + { + continue; + } + if (map.get(p) >= minDist && map.get(p) <= maxDist) + { + list.add(p); + } + } + + Collections.sort(list, (o1, o2) -> + { + return Double.compare(map.get(o2), map.get(o1)); + }); + + return list; + } + + @EventHandler + public void onSkeletonDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + event.SetKnockback(false); + if (_invuln) + { + event.SetCancelled("Challenge Invulnerability"); + } + } + } + + @EventHandler + public void noFallDamage(CustomDamageEvent event) + { + if (getEntity() == null) + { + return; + } + + if (event.GetDamageeEntity().getEntityId() != getEntity().getEntityId()) + { + return; + } + + DamageCause cause = event.GetCause(); + + if (cause == DamageCause.FALL) + { + event.SetCancelled("Boss Invulnerability"); + } + } + + @Override + public void handleDeath(Location location) + { + location.getWorld().dropItem(location.clone().add(0, 1, 0), new ItemStack(Material.EMERALD, UtilMath.rRange(10, 20))); + location.getWorld().dropItem(location.clone().add(0, 1, 0), new ItemStack(UtilMath.randomElement(new Material[] {Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, Material.GOLD_LEGGINGS, Material.GOLD_BOOTS}))); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/BlazeMinion.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/BlazeMinion.java new file mode 100644 index 000000000..63783d8de --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/BlazeMinion.java @@ -0,0 +1,45 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import org.bukkit.Location; +import org.bukkit.entity.Blaze; +import org.bukkit.event.EventHandler; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class BlazeMinion extends EventCreature +{ + private RaidChallenge _challenge; + + public BlazeMinion(RaidChallenge challenge, Location spawnLocation) + { + super(challenge.getRaid(), spawnLocation, "Blaze Minion", true, 20, 500, true, Blaze.class); + + _challenge = challenge; + spawnEntity(); + } + + @Override + protected void spawnCustom() {} + + @Override + public void dieCustom() {} + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Cataclysm.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Cataclysm.java new file mode 100644 index 000000000..0ca7625e4 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Cataclysm.java @@ -0,0 +1,58 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; + +public abstract class Cataclysm implements Listener +{ + protected ChallengeSix Challenge; + protected Magmus Magmus; + + public Cataclysm(ChallengeSix challenge, Magmus magmus) + { + Challenge = challenge; + Magmus = magmus; + + challenge.getRaid().getPlayers().forEach(player -> UtilPlayer.message(player, F.main(challenge.getRaid().getName() + " Raid", getAnnouncement()))); + onStart(); + UtilServer.RegisterEvents(this); + } + + protected abstract String getAnnouncement(); + + protected abstract void onStart(); + + protected abstract void onEnd(); + + protected abstract void tick(); + + protected void end() + { + onEnd(); + HandlerList.unregisterAll(this); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK) + { + if (Challenge.isComplete()) + { + end(); + } + else + { + tick(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java new file mode 100644 index 000000000..306b3e17b --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/HeatingUp.java @@ -0,0 +1,74 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import org.bukkit.DyeColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilMath; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; + +public class HeatingUp extends Cataclysm +{ + private Location _center; + private int _ticks; + + public HeatingUp(ChallengeSix challenge, Magmus magmus) + { + super(challenge, magmus); + } + + @Override + protected String getAnnouncement() + { + return "The room is heating up! Quickly, head to a safe location!"; + } + + @SuppressWarnings("deprecation") + @Override + protected void onStart() + { + _center = Challenge.getRaid().getWorldData().getCustomLocs("C_SIX_C1S").get(0); + for (int x = -1; x <= 1; x++) + { + for (int z = -1; z <= 1; z++) + { + _center.getBlock().getRelative(x, -1, z).setTypeIdAndData(Material.STAINED_GLASS.getId(), DyeColor.GREEN.getWoolData(), true); + } + } + } + + @Override + protected void onEnd() + { + for (int x = -1; x <= 1; x++) + { + for (int z = -1; z <= 1; z++) + { + _center.getBlock().getRelative(x, -1, z).setType(Material.STONE); + } + } + } + + @Override + protected void tick() + { + _ticks++; + if (_ticks > (20 * 10)) + { + for (Player player : Challenge.getRaid().getPlayers()) + { + if (UtilMath.offset(player.getLocation(), _center) > 1) + { + player.setFireTicks(1); + Challenge.getRaid().getDamageManager().NewDamageEvent(player, Magmus.getEntity(), null, DamageCause.FIRE, 1, false, true, true, Magmus.getEntity().getName(), "Heat Room"); + } + } + } + if (_ticks > (20 * 30)) + { + end(); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/InfernalMinions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/InfernalMinions.java new file mode 100644 index 000000000..b892e1332 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/InfernalMinions.java @@ -0,0 +1,44 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import org.bukkit.Location; + +import mineplex.core.common.util.UtilMath; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadKnight; + +public class InfernalMinions extends Cataclysm +{ + public InfernalMinions(ChallengeSix challenge, Magmus magmus) + { + super(challenge, magmus); + } + + @Override + protected String getAnnouncement() + { + return "Infernal minions have flocked to Magmus' aid!"; + } + + @Override + protected void onStart() + { + for (Location loc : Challenge.getRaid().getWorldData().getCustomLocs("C_SIX_C2M")) + { + if (UtilMath.r(2) == 1) + { + Challenge.getRaid().registerCreature(new UndeadKnight(Challenge, loc)); + } + else + { + Challenge.getRaid().registerCreature(new BlazeMinion(Challenge, loc)); + } + } + end(); + } + + @Override + protected void onEnd() {} + + @Override + protected void tick() {} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java new file mode 100644 index 000000000..746027618 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/Magmus.java @@ -0,0 +1,70 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import org.bukkit.Location; +import org.bukkit.entity.MagmaCube; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; + +public class Magmus extends EventCreature +{ + private ChallengeSix _challenge; + private MagmusPassive _passive; + + public Magmus(ChallengeSix challenge, Location location) + { + super(challenge.getRaid(), location, "Gatekeeper Magmus", true, 2000, 500, true, MagmaCube.class); + + _challenge = challenge; + spawnEntity(); + _passive = new MagmusPassive(this); + } + + protected ChallengeSix getChallenge() + { + return _challenge; + } + + @Override + protected void spawnCustom() + { + UtilEnt.vegetate(getEntity()); + getEntity().setSize(17); + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + HandlerList.unregisterAll(_passive); + _passive = null; + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + getEntity().teleport(getSpawnLocation()); + + _passive.tick(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusPassive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusPassive.java new file mode 100644 index 000000000..f7fa43922 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/MagmusPassive.java @@ -0,0 +1,56 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.entity.MagmaCube; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; + +public class MagmusPassive extends BossPassive +{ + private long _lastUse; + private List> _cataclysms = new ArrayList<>(); + + public MagmusPassive(Magmus creature) + { + super(creature); + _lastUse = System.currentTimeMillis(); + _cataclysms.add(HeatingUp.class); + _cataclysms.add(InfernalMinions.class); + _cataclysms.add(UndeadAlly.class); + } + + @Override + public int getCooldown() + { + return 30; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (UtilTime.elapsed(_lastUse, getCooldown() * 1000)) + { + _lastUse = System.currentTimeMillis(); + try + { + UtilMath.randomElement(_cataclysms).getConstructor(ChallengeSix.class, Magmus.class).newInstance(getBoss().getChallenge(), getBoss()); + } + catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) + { + e.printStackTrace(); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/UndeadAlly.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/UndeadAlly.java new file mode 100644 index 000000000..06730bf2b --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/magma/UndeadAlly.java @@ -0,0 +1,31 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.magma; + +import mineplex.game.clans.clans.worldevent.raid.wither.challenge.six.ChallengeSix; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadMage; + +public class UndeadAlly extends Cataclysm +{ + public UndeadAlly(ChallengeSix challenge, Magmus magmus) + { + super(challenge, magmus); + } + + @Override + protected String getAnnouncement() + { + return "Magmus has summoned an undead ally!"; + } + + @Override + protected void onStart() + { + Challenge.getRaid().registerCreature(new UndeadMage(Challenge, Challenge.getRaid().getWorldData().getCustomLocs("C_SIX_C3S").get(0), false, null, null)); + end(); + } + + @Override + protected void onEnd() {} + + @Override + protected void tick() {} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/PitSwarmer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/PitSwarmer.java new file mode 100644 index 000000000..17fc0b66a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/PitSwarmer.java @@ -0,0 +1,59 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.silverfish; + +import org.bukkit.Location; +import org.bukkit.entity.Silverfish; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class PitSwarmer extends EventCreature +{ + private RaidChallenge _challenge; + private SwarmerPassive _passive; + + public PitSwarmer(RaidChallenge challenge, Location location) + { + super(challenge.getRaid(), location, "Pit Swarmer", true, 1, 100, true, Silverfish.class); + + _challenge = challenge; + spawnEntity(); + _passive = new SwarmerPassive(this); + } + + @Override + protected void spawnCustom() {} + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + HandlerList.unregisterAll(_passive); + _passive = null; + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + _passive.tick(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/SwarmerPassive.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/SwarmerPassive.java new file mode 100644 index 000000000..58a8f7e99 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/silverfish/SwarmerPassive.java @@ -0,0 +1,49 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.silverfish; + +import org.bukkit.entity.Silverfish; +import org.bukkit.event.EventHandler; + +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class SwarmerPassive extends BossPassive +{ + public SwarmerPassive(PitSwarmer creature) + { + super(creature); + } + + @Override + public int getCooldown() + { + return 0; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() {} + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamagerEntity(false) != null) + { + if (event.GetDamagerEntity(false).getEntityId() == getEntity().getEntityId()) + { + event.AddMod("Swarm Attack", 1 - event.GetDamage()); + } + } + if (event.GetDamageeEntity() != null) + { + if (event.GetDamageeEntity().getEntityId() == getEntity().getEntityId()) + { + event.SetCancelled("Swarm Invulnerability"); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/BlackHole.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/BlackHole.java new file mode 100644 index 000000000..0431a4b15 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/BlackHole.java @@ -0,0 +1,118 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class BlackHole extends BossPassive +{ + private static final double RANGE = 15; + private long _lastUsed; + private int _chargeTicks; + + public BlackHole(CharlesWitherton creature) + { + super(creature); + _lastUsed = -1; + _chargeTicks = -1; + } + + private void pull() + { + for (Player entity : UtilPlayer.getInRadius(getLocation(), RANGE).keySet()) + { + UtilAction.velocity(entity, UtilAlg.getTrajectory(entity, getEntity()), 0.3, false, 0, 0, 1, true); + } + for (int i = 0; i < 6; i++) + { + Vector random = new Vector(Math.random() * 4 - 2, Math.random() * 4 - 2, Math.random() * 4 - 2); + + Location origin = getLocation().add(0, 1.3, 0); + origin.add(getLocation().getDirection().multiply(10)); + origin.add(random); + + Vector vel = UtilAlg.getTrajectory(origin, getLocation().add(0, 1.3, 0)); + vel.multiply(7); + + UtilParticle.PlayParticle(ParticleType.MAGIC_CRIT, + origin, + (float)vel.getX(), + (float)vel.getY(), + (float)vel.getZ(), + 1, 0, ViewDist.LONG, UtilServer.getPlayers()); + } + } + + private void throwUp() + { + Map near = UtilPlayer.getInRadius(getLocation(), RANGE); + for (Entry thr : near.entrySet()) + { + Vector vel = new Vector(0, Math.min(7.5, Math.max(5 / thr.getValue(), 4)), 0); + thr.getKey().setVelocity(vel); + } + } + + @Override + public int getCooldown() + { + return 60; + } + + @Override + public boolean isProgressing() + { + return _chargeTicks != -1; + } + + @Override + public void tick() + { + if (_chargeTicks != -1) + { + _chargeTicks++; + if (_chargeTicks >= (20 * 5)) + { + _lastUsed = System.currentTimeMillis(); + _chargeTicks = -1; + throwUp(); + } + else + { + pull(); + } + return; + } + if (getBoss().getHealthPercent() <= 0.25) + { + if (_lastUsed == -1) + { + _lastUsed = System.currentTimeMillis(); + } + else + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + _chargeTicks = 0; + ((WitherRaid)getBoss().getEvent()).getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getBoss().getEvent().getName() + " Raid", "He's charging up Decay! Run away!"))); + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesSkulls.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesSkulls.java new file mode 100644 index 000000000..eccb7ab13 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesSkulls.java @@ -0,0 +1,189 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.entity.WitherSkull; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossAbility; + +public class CharlesSkulls extends BossAbility +{ + private long _lastUnguided; + private long _lastGuided; + private long _lastBombard; + private Map _guidedSkulls; + + public CharlesSkulls(CharlesWitherton creature) + { + super(creature); + + _lastUnguided = System.currentTimeMillis(); + _lastGuided = System.currentTimeMillis(); + _lastBombard = -1; + } + + @Override + public void tick() + { + if (getBoss().getHealthPercent() <= 0.75) + { + if (_lastBombard == -1) + { + _lastBombard = System.currentTimeMillis(); + } + else + { + if (UtilTime.elapsed(_lastBombard, 25000)) + { + Player target = UtilPlayer.getClosest(getLocation()); + if (target != null) + { + _lastBombard = System.currentTimeMillis(); + UtilEnt.LookAt(getEntity(), target.getEyeLocation()); + for (int i = 0; i < 15; i++) + { + UtilEnt.addFlag(getEntity().launchProjectile(WitherSkull.class), "BOMBARD"); + } + return; + } + } + } + } + if (UtilTime.elapsed(_lastUnguided, 10000)) + { + Player target = UtilPlayer.getClosest(getLocation()); + if (target != null) + { + _lastUnguided = System.currentTimeMillis(); + UtilEnt.LookAt(getEntity(), target.getEyeLocation()); + getEntity().launchProjectile(WitherSkull.class); + return; + } + } + if (UtilTime.elapsed(_lastGuided, 5000)) + { + Player target = UtilPlayer.getClosest(getLocation()); + if (target != null) + { + _lastGuided = System.currentTimeMillis(); + UtilEnt.LookAt(getEntity(), target.getEyeLocation()); + WitherSkull skull = getEntity().launchProjectile(WitherSkull.class); + UtilEnt.addFlag(skull, "GUIDED"); + _guidedSkulls.put(skull, target); + } + } + + Iterator> iterator = _guidedSkulls.entrySet().iterator(); + while (iterator.hasNext()) + { + Entry entry = iterator.next(); + if (!entry.getKey().isValid() || entry.getKey().isDead()) + { + iterator.remove(); + continue; + } + Vector velocity = UtilAlg.getTrajectory(entry.getKey(), entry.getValue()); + entry.getKey().setDirection(velocity); + entry.getKey().setVelocity(velocity.multiply(0.6)); + } + } + + @EventHandler + public void onExplode(EntityExplodeEvent event) + { + if (event.getEntity().getEntityId() == getEntity().getEntityId()) + { + event.blockList().clear(); + return; + } + if (event.getEntity() instanceof WitherSkull) + { + WitherSkull skull = (WitherSkull) event.getEntity(); + if (skull.getShooter() instanceof Wither && ((Wither)skull.getShooter()).getEntityId() == getEntity().getEntityId()) + { + event.blockList().clear(); + return; + } + } + } + + @EventHandler + public void onSkullHit(ProjectileHitEvent event) + { + if (event.getEntity() instanceof WitherSkull) + { + WitherSkull skull = (WitherSkull) event.getEntity(); + if (skull.getShooter() instanceof Wither && ((Wither)skull.getShooter()).getEntityId() == getEntity().getEntityId()) + { + UtilParticle.PlayParticle(ParticleType.EXPLODE, skull.getLocation(), null, 0, 2, ViewDist.MAX, UtilServer.getPlayers()); + skull.getWorld().playSound(skull.getLocation(), Sound.EXPLODE, 10, 0); + if (UtilEnt.hasFlag(skull, "GUIDED")) + { + Player hit = UtilPlayer.getClosest(skull.getLocation(), 0.5); + if (hit != null) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(hit, getEntity(), skull, DamageCause.PROJECTILE, 2, true, true, false, getEntity().getName(), "Guided Skull"); + } + } + else if (UtilEnt.hasFlag(skull, "BOMBARD")) + { + Player hit = UtilPlayer.getClosest(skull.getLocation(), 0.5); + if (hit != null) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(hit, getEntity(), skull, DamageCause.PROJECTILE, 2, true, true, false, getEntity().getName(), "Bombardment"); + } + } + else + { + Player hit = UtilPlayer.getClosest(skull.getLocation(), 0.5); + if (hit != null) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(hit, getEntity(), skull, DamageCause.PROJECTILE, 4, true, true, false, getEntity().getName(), "Wither Skull"); + getBoss().getEvent().getCondition().Factory().Wither("Wither Skull", hit, getEntity(), 3, 0, false, true, false); + } + } + skull.remove(); + } + } + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public boolean inProgress() + { + return false; + } + + @Override + public boolean hasFinished() + { + return false; + } + + @Override + public void setFinished() {} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesWitherton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesWitherton.java new file mode 100644 index 000000000..e86a246fc --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/CharlesWitherton.java @@ -0,0 +1,95 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.entity.Wither; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class CharlesWitherton extends EventCreature +{ + private RaidChallenge _challenge; + private CharlesSkulls _passive; + private List> _abilities = new ArrayList<>(); + + protected boolean Flying = false; + + public CharlesWitherton(RaidChallenge challenge, Location location) + { + super(challenge.getRaid(), location, "Charles Witherton", true, 5000, 15000, true, Wither.class); + + _challenge = challenge; + spawnEntity(); + _passive = new CharlesSkulls(this); + _abilities.add(new LifeSap(this)); + _abilities.add(new Flight(this)); + _abilities.add(new Decay(this)); + _abilities.add(new WitherWave(this)); + _abilities.add(new SummonUndead(this)); + _abilities.add(new SummonCorpse(this)); + _abilities.add(new BlackHole(this)); + _abilities.add(new SummonMinions(this)); + } + + protected RaidChallenge getChallenge() + { + return _challenge; + } + + protected List getCustomLocs(String id) + { + return _challenge.getRaid().getWorldData().getCustomLocs(id); + } + + @Override + protected void spawnCustom() + { + UtilEnt.vegetate(getEntity()); + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + for (BossPassive ability : _abilities) + { + HandlerList.unregisterAll(ability); + } + _abilities.clear(); + _passive.setFinished(); + HandlerList.unregisterAll(_passive); + _passive = null; + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + _passive.tick(); + _abilities.forEach(BossPassive::tick); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/Decay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/Decay.java new file mode 100644 index 000000000..b7271831b --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/Decay.java @@ -0,0 +1,79 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.F; +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.UtilShapes; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class Decay extends BossPassive +{ + private static final double RANGE = 28; + private long _lastUsed; + private int _chargeTicks; + + public Decay(CharlesWitherton creature) + { + super(creature); + _lastUsed = -1; + _chargeTicks = -1; + } + + @Override + public int getCooldown() + { + return 300; + } + + @Override + public boolean isProgressing() + { + return _chargeTicks != -1; + } + + @Override + public void tick() + { + if (_chargeTicks != -1) + { + _chargeTicks++; + if (_chargeTicks >= (20 * 5)) + { + _lastUsed = System.currentTimeMillis(); + _chargeTicks = -1; + for (Player player : UtilPlayer.getInRadius(getLocation(), RANGE).keySet()) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null, DamageCause.WITHER, 1000, false, true, true, getEntity().getName(), "Decay"); + } + } + else + { + getEntity().teleport(getBoss().getCustomLocs("C_SEVEN_RWC").get(0)); + for (Location loc : UtilShapes.getSphereBlocks(getEntity().getEyeLocation(), 2, 2, true)) + { + UtilParticle.playColoredParticleToAll(Color.RED, ParticleType.RED_DUST, loc, 2, ViewDist.MAX); + UtilParticle.playColoredParticleToAll(Color.BLACK, ParticleType.RED_DUST, loc, 2, ViewDist.MAX); + } + } + return; + } + if (getBoss().getHealthPercent() <= 0.5) + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + _chargeTicks = 0; + ((WitherRaid)getBoss().getEvent()).getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getBoss().getEvent().getName() + " Raid", "He's charging up Decay! Run away!"))); + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/Flight.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/Flight.java new file mode 100644 index 000000000..bb1cafc24 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/Flight.java @@ -0,0 +1,62 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import org.bukkit.entity.Wither; + +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; + +public class Flight extends BossPassive +{ + private long _lastUsed; + private int _flyingTicks; + + public Flight(CharlesWitherton creature) + { + super(creature); + _lastUsed = -1; + _flyingTicks = -1; + } + + @Override + public int getCooldown() + { + return 200; + } + + @Override + public boolean isProgressing() + { + return _flyingTicks != -1; + } + + @Override + public void tick() + { + if (_flyingTicks != -1) + { + _flyingTicks++; + if (_flyingTicks >= (20 * 20)) + { + _lastUsed = System.currentTimeMillis(); + _flyingTicks = -1; + getBoss().Flying = false; + } + return; + } + if (getBoss().getHealthPercent() <= 0.75) + { + if (_lastUsed == -1) + { + _lastUsed = System.currentTimeMillis(); + } + else + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + getBoss().Flying = true; + _flyingTicks = 0; + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/LifeSap.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/LifeSap.java new file mode 100644 index 000000000..5afeb2e8d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/LifeSap.java @@ -0,0 +1,116 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +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.UtilShapes; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; + +public class LifeSap extends BossPassive +{ + private static final double RANGE = 20; + private long _lastUsed; + private int _chargeTicks; + + public LifeSap(CharlesWitherton creature) + { + super(creature); + _lastUsed = -1; + _chargeTicks = -1; + } + + private void shootBeam(Player target) + { + double curRange = 0; + boolean canHit = true; + + while (curRange <= RANGE) + { + Location newTarget = getEntity().getEyeLocation().add(UtilAlg.getTrajectory(getEntity(), target).multiply(curRange)); + + if (!UtilBlock.airFoliage(newTarget.getBlock())) + { + canHit = false; + break; + } + if (UtilMath.offset(newTarget, target.getLocation()) <= 0.9) + { + break; + } + + curRange += 0.2; + + UtilParticle.playColoredParticleToAll(Color.RED, ParticleType.RED_DUST, newTarget, 5, ViewDist.MAX); + } + + if (canHit) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.CUSTOM, 2.5, true, true, false, getEntity().getName(), "Mystical Energy"); + getBoss().setHealth(getBoss().getHealth() + 200); + } + } + + @Override + public int getCooldown() + { + return 60; + } + + @Override + public boolean isProgressing() + { + return _chargeTicks != -1; + } + + @Override + public void tick() + { + if (_chargeTicks != -1) + { + _chargeTicks++; + if (_chargeTicks >= (20 * 4)) + { + _lastUsed = System.currentTimeMillis(); + _chargeTicks = -1; + Player target = UtilPlayer.getClosest(getLocation(), RANGE); + if (target != null) + { + shootBeam(target); + } + } + else + { + for (Location loc : UtilShapes.getCircle(getEntity().getEyeLocation(), true, 1.5)) + { + UtilParticle.playColoredParticleToAll(Color.RED, ParticleType.RED_DUST, loc, 2, ViewDist.MAX); + } + } + return; + } + if (getBoss().getHealthPercent() <= 0.75) + { + if (_lastUsed == -1) + { + _lastUsed = System.currentTimeMillis(); + } + else + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + _chargeTicks = 0; + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharles.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharles.java new file mode 100644 index 000000000..5f4d86651 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharles.java @@ -0,0 +1,73 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import org.bukkit.Location; +import org.bukkit.entity.Wither; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.worldevent.api.EventCreature; +import mineplex.game.clans.clans.worldevent.raid.RaidChallenge; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class MiniCharles extends EventCreature +{ + private RaidChallenge _challenge; + private MiniCharlesSkulls _passive; + private int _liveTicks; + + protected boolean Flying = false; + + public MiniCharles(RaidChallenge challenge, Location location) + { + super(challenge.getRaid(), location, "Charles' Minion", true, 50, 15000, true, Wither.class); + + _challenge = challenge; + spawnEntity(); + _passive = new MiniCharlesSkulls(this); + } + + @Override + protected void spawnCustom() + { + UtilEnt.vegetate(getEntity()); + } + + @Override + public void dieCustom() + { + endAbility(); + } + + private void endAbility() + { + _passive.setFinished(); + HandlerList.unregisterAll(_passive); + _passive = null; + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_challenge.isComplete()) + { + remove(); + return; + } + + _passive.tick(); + + _liveTicks++; + if (_liveTicks > (20 * 15)) + { + remove(); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharlesSkulls.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharlesSkulls.java new file mode 100644 index 000000000..135decf8a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/MiniCharlesSkulls.java @@ -0,0 +1,117 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.entity.WitherSkull; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.ProjectileHitEvent; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossAbility; + +public class MiniCharlesSkulls extends BossAbility +{ + private long _lastUnguided; + private List _shot = new ArrayList<>(); + + public MiniCharlesSkulls(MiniCharles creature) + { + super(creature); + + _lastUnguided = System.currentTimeMillis(); + } + + @Override + public void tick() + { + if (UtilTime.elapsed(_lastUnguided, 10000)) + { + Player target = UtilPlayer.getClosest(getLocation()); + if (target != null) + { + _lastUnguided = System.currentTimeMillis(); + UtilEnt.LookAt(getEntity(), target.getEyeLocation()); + _shot.add(getEntity().launchProjectile(WitherSkull.class)); + return; + } + } + } + + @EventHandler + public void onExplode(EntityExplodeEvent event) + { + if (event.getEntity().getEntityId() == getEntity().getEntityId()) + { + event.blockList().clear(); + return; + } + if (event.getEntity() instanceof WitherSkull) + { + WitherSkull skull = (WitherSkull) event.getEntity(); + if (skull.getShooter() instanceof Wither && ((Wither)skull.getShooter()).getEntityId() == getEntity().getEntityId()) + { + event.blockList().clear(); + return; + } + } + } + + @EventHandler + public void onSkullHit(ProjectileHitEvent event) + { + if (event.getEntity() instanceof WitherSkull) + { + WitherSkull skull = (WitherSkull) event.getEntity(); + if (skull.getShooter() instanceof Wither && ((Wither)skull.getShooter()).getEntityId() == getEntity().getEntityId()) + { + _shot.remove(skull); + UtilParticle.PlayParticle(ParticleType.EXPLODE, skull.getLocation(), null, 0, 2, ViewDist.MAX, UtilServer.getPlayers()); + skull.getWorld().playSound(skull.getLocation(), Sound.EXPLODE, 10, 0); + Player hit = UtilPlayer.getClosest(skull.getLocation(), 0.5); + if (hit != null) + { + getBoss().getEvent().getDamageManager().NewDamageEvent(hit, getEntity(), skull, DamageCause.PROJECTILE, 4, true, true, false, getEntity().getName(), "Wither Skull"); + getBoss().getEvent().getCondition().Factory().Wither("Wither Skull", hit, getEntity(), 3, 0, false, true, false); + } + skull.remove(); + } + } + } + + @Override + public boolean canMove() + { + return true; + } + + @Override + public boolean inProgress() + { + return false; + } + + @Override + public boolean hasFinished() + { + return false; + } + + @Override + public void setFinished() + { + _shot.forEach(WitherSkull::remove); + _shot.clear(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonCorpse.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonCorpse.java new file mode 100644 index 000000000..0471b69e2 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonCorpse.java @@ -0,0 +1,52 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import org.bukkit.entity.Wither; + +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.corpse.ReanimatedCorpse; + +public class SummonCorpse extends BossPassive +{ + private long _lastUsed; + + public SummonCorpse(CharlesWitherton creature) + { + super(creature); + _lastUsed = -1; + } + + @Override + public int getCooldown() + { + return 30; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (getBoss().getHealthPercent() <= 0.50) + { + if (_lastUsed == -1) + { + _lastUsed = System.currentTimeMillis(); + } + else + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + for (int i = 0; i < 6; i++) + { + getBoss().getEvent().registerCreature(new ReanimatedCorpse(getBoss().getChallenge(), getLocation())); + } + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonMinions.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonMinions.java new file mode 100644 index 000000000..b40618cfd --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonMinions.java @@ -0,0 +1,51 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import org.bukkit.entity.Wither; + +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; + +public class SummonMinions extends BossPassive +{ + private long _lastUsed; + + public SummonMinions(CharlesWitherton creature) + { + super(creature); + _lastUsed = -1; + } + + @Override + public int getCooldown() + { + return 60; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (getBoss().getHealthPercent() <= 0.25) + { + if (_lastUsed == -1) + { + _lastUsed = System.currentTimeMillis(); + } + else + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + for (int i = 0; i < 2; i++) + { + getBoss().getEvent().registerCreature(new MiniCharles(getBoss().getChallenge(), getLocation())); + } + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonUndead.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonUndead.java new file mode 100644 index 000000000..dd855ea63 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/SummonUndead.java @@ -0,0 +1,52 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import org.bukkit.entity.Wither; + +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.wither.creature.mage.UndeadKnight; + +public class SummonUndead extends BossPassive +{ + private long _lastUsed; + + public SummonUndead(CharlesWitherton creature) + { + super(creature); + _lastUsed = -1; + } + + @Override + public int getCooldown() + { + return 60; + } + + @Override + public boolean isProgressing() + { + return false; + } + + @Override + public void tick() + { + if (getBoss().getHealthPercent() <= 0.50) + { + if (_lastUsed == -1) + { + _lastUsed = System.currentTimeMillis(); + } + else + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + for (int i = 0; i < 6; i++) + { + getBoss().getEvent().registerCreature(new UndeadKnight(getBoss().getChallenge(), getLocation())); + } + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/WitherWave.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/WitherWave.java new file mode 100644 index 000000000..ae7fea54c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/raid/wither/creature/wither/WitherWave.java @@ -0,0 +1,91 @@ +package mineplex.game.clans.clans.worldevent.raid.wither.creature.wither; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; + +import mineplex.core.common.util.F; +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.UtilShapes; +import mineplex.core.common.util.UtilTime; +import mineplex.game.clans.clans.worldevent.api.BossPassive; +import mineplex.game.clans.clans.worldevent.raid.wither.WitherRaid; + +public class WitherWave extends BossPassive +{ + private static final double RANGE = 10; + private long _lastUsed; + private int _chargeTicks; + + public WitherWave(CharlesWitherton creature) + { + super(creature); + _lastUsed = -1; + _chargeTicks = -1; + } + + @Override + public int getCooldown() + { + return 60; + } + + @Override + public boolean isProgressing() + { + return _chargeTicks != -1; + } + + @Override + public void tick() + { + if (_chargeTicks != -1) + { + _chargeTicks++; + if (_chargeTicks >= (20 * 5)) + { + for (Location loc : UtilShapes.getSphereBlocks(getLocation(), RANGE / 2, RANGE / 2, false)) + { + UtilParticle.playColoredParticleToAll(Color.GRAY, ParticleType.RED_DUST, loc, 2, ViewDist.MAX); + } + for (Player player : UtilPlayer.getInRadius(getLocation(), RANGE).keySet()) + { + getBoss().getEvent().getCondition().Factory().Wither("Wither Wave", player, getEntity(), 5, 1, false, true, false); + } + if (_chargeTicks >= (20 * 10)) + { + _lastUsed = System.currentTimeMillis(); + _chargeTicks = -1; + } + } + else + { + getEntity().teleport(getLocation()); + for (Location loc : UtilShapes.getSphereBlocks(getEntity().getEyeLocation(), 2, 2, true)) + { + UtilParticle.playColoredParticleToAll(Color.GRAY, ParticleType.RED_DUST, loc, 2, ViewDist.MAX); + } + } + return; + } + if (getBoss().getHealthPercent() <= 0.5) + { + if (_lastUsed == -1) + { + _lastUsed = System.currentTimeMillis(); + } + else + { + if (UtilTime.elapsed(_lastUsed, getCooldown() * 1000)) + { + _chargeTicks = 0; + ((WitherRaid)getBoss().getEvent()).getPlayers().forEach(player -> UtilPlayer.message(player, F.main(getBoss().getEvent().getName() + " Raid", "He's charging up Decay! Run away!"))); + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java index 44efed198..481abf910 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java @@ -24,6 +24,7 @@ import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ban.ClansBanManager; +import mineplex.game.clans.clans.worldevent.raid.RaidManager; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.gameplay.safelog.npc.NPCManager; import mineplex.game.clans.restart.RestartManager; @@ -75,6 +76,11 @@ public class SafeLog extends MiniPlugin isSafeLog = true; } + if (Managers.get(RaidManager.class).isInRaid(player.getLocation())) + { + isSafeLog = true; + } + if (!isSafeLog) { if (!_clansManager.getIncognitoManager().Get(player).Status) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java index 70837d017..33e26bbb0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/rares/RunedPickaxe.java @@ -1,11 +1,8 @@ package mineplex.game.clans.items.rares; -import java.util.HashSet; - import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.block.Block; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -39,9 +36,8 @@ public class RunedPickaxe extends RareItem static { - UtilServer.RegisterEvents(new Listener() { - - @SuppressWarnings("deprecation") + UtilServer.RegisterEvents(new Listener() + { @EventHandler public void update(UpdateEvent event) { @@ -105,6 +101,9 @@ public class RunedPickaxe extends RareItem if (ClansManager.getInstance().getNetherManager().getNetherWorld().equals(event.getBlock().getWorld())) return; + if (ClansManager.getInstance().getWorldEvent().getRaidManager().isInRaid(event.getBlock().getLocation())) + return; + if (ClansManager.getInstance().getBlockRestore().contains(event.getBlock())) return; @@ -119,7 +118,7 @@ public class RunedPickaxe extends RareItem } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void blockDamage(BlockBreakEvent event) + public void blockBreak(BlockBreakEvent event) { PlayerGear gear = ClansManager.getInstance().getGearManager().getPlayerGear(event.getPlayer()); @@ -136,6 +135,9 @@ public class RunedPickaxe extends RareItem if (ClansManager.getInstance().getBlockRestore().contains(event.getBlock())) return; + if (ClansManager.getInstance().getWorldEvent().getRaidManager().isInRaid(event.getBlock().getLocation())) + return; + if (!pick._enabled) { event.setCancelled(true); @@ -168,6 +170,5 @@ public class RunedPickaxe extends RareItem } super.onInteract(event); - } - -} + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java index 52571a49a..572534b0d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/restart/RestartManager.java @@ -11,7 +11,6 @@ import org.bukkit.event.player.PlayerLoginEvent.Result; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.Managers; import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -94,6 +93,10 @@ public class RestartManager extends MiniPlugin { return false; } + if (ClansManager.getInstance().getWorldEvent().getRaidManager().getActiveRaids() > 0) + { + return false; + } return true; }