Finalize raid system and implement Charles Witherton Raid

This commit is contained in:
AlexTheCoder 2017-06-01 02:15:43 -04:00
parent fdd48b51d4
commit e94201409b
61 changed files with 4580 additions and 125 deletions

View File

@ -300,4 +300,36 @@ public class UtilMath
{ {
return n - ((int) ((int) n)); 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;
}
} }

View File

@ -595,8 +595,13 @@ public class UtilPlayer
return nearbyMap; return nearbyMap;
} }
public static Player getClosest(Location loc, Collection<Player> ignore) public static Player getClosest(Location loc, Collection<Player> ignore)
{
return getClosest(loc, -1, ignore);
}
public static Player getClosest(Location loc, double maxDist, Collection<Player> ignore)
{ {
Player best = null; Player best = null;
double bestDist = 0; double bestDist = 0;
@ -613,6 +618,11 @@ public class UtilPlayer
continue; continue;
double dist = UtilMath.offset(cur.getLocation(), loc); double dist = UtilMath.offset(cur.getLocation(), loc);
if (maxDist > 0 && dist > maxDist)
{
continue;
}
if (best == null || dist < bestDist) if (best == null || dist < bestDist)
{ {
@ -623,8 +633,13 @@ public class UtilPlayer
return best; return best;
} }
public static Player getClosest(Location loc, Entity... ignore) 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; Player best = null;
double bestDist = 0; double bestDist = 0;
@ -655,6 +670,11 @@ public class UtilPlayer
} }
double dist = UtilMath.offset(cur.getLocation(), loc); double dist = UtilMath.offset(cur.getLocation(), loc);
if (maxDist > 0 && dist > maxDist)
{
continue;
}
if (best == null || dist < bestDist) if (best == null || dist < bestDist)
{ {

View File

@ -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.api.WorldEvent;
import mineplex.game.clans.clans.worldevent.boss.BossArenaLocationFinder; import mineplex.game.clans.clans.worldevent.boss.BossArenaLocationFinder;
import mineplex.game.clans.clans.worldevent.command.WorldEventCommand; 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.SkillFactory;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.damage.DamageManager;
@ -49,6 +50,8 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
private long _nextEventStart; private long _nextEventStart;
private RaidManager _raidManager;
public WorldEventManager(JavaPlugin plugin, ClansManager clansManager, DamageManager damageManager, LootManager lootManager, BlockRestore blockRestore, ClansRegions clansRegions, SkillFactory skillFactory) public WorldEventManager(JavaPlugin plugin, ClansManager clansManager, DamageManager damageManager, LootManager lootManager, BlockRestore blockRestore, ClansRegions clansRegions, SkillFactory skillFactory)
{ {
super("World Event", plugin); super("World Event", plugin);
@ -64,6 +67,8 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
_skillFactory = skillFactory; _skillFactory = skillFactory;
_raidManager = new RaidManager(plugin);
updateNextEventTime(); updateNextEventTime();
} }
@ -80,6 +85,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
event.stop(true); event.stop(true);
} }
_runningEvents.clear(); _runningEvents.clear();
_raidManager.onDisable();
} }
public boolean isInEvent(Location location) public boolean isInEvent(Location location)
@ -185,6 +191,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
return null; return null;
} }
public WorldEvent startEventFromType(WorldEventType eventType) public WorldEvent startEventFromType(WorldEventType eventType)
{ {
if (eventType != null) if (eventType != null)
@ -239,6 +246,11 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
return _bossFinder; return _bossFinder;
} }
public RaidManager getRaidManager()
{
return _raidManager;
}
private void updateNextEventTime() private void updateNextEventTime()
{ {
// 45 Minutes + (0 - 15 Minutes) // 45 Minutes + (0 - 15 Minutes)

View File

@ -237,14 +237,14 @@ public abstract class WorldEvent implements Listener, ScoreboardElement
protected abstract void customTick(); protected abstract void customTick();
public final void cleanup() public final void cleanup(boolean onDisable)
{ {
clearCreatures(); clearCreatures();
restoreBlocks(); restoreBlocks();
customCleanup(); customCleanup(onDisable);
} }
public abstract void customCleanup(); public abstract void customCleanup(boolean onDisable);
public final void stop() public final void stop()
{ {
@ -253,7 +253,7 @@ public abstract class WorldEvent implements Listener, ScoreboardElement
public final void stop(boolean onDisable) public final void stop(boolean onDisable)
{ {
cleanup(); cleanup(onDisable);
if (onDisable) if (onDisable)
{ {
setState(EventState.REMOVED); setState(EventState.REMOVED);

View File

@ -3,6 +3,7 @@ package mineplex.game.clans.clans.worldevent.boss;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -89,6 +90,7 @@ public abstract class BossWorldEvent<T extends EventCreature<?>> extends WorldEv
Location drop = event.getCreature().getLastKnownLocation(); Location drop = event.getCreature().getLastKnownLocation();
UtilServer.CallEvent(new BossDeathEvent(this, drop)); UtilServer.CallEvent(new BossDeathEvent(this, drop));
ClansManager.getInstance().runSyncLater(() -> ClansManager.getInstance().getLootManager().dropRare(drop), DELAY_TILL_DROP_REWARD); ClansManager.getInstance().runSyncLater(() -> ClansManager.getInstance().getLootManager().dropRare(drop), DELAY_TILL_DROP_REWARD);
Bukkit.broadcastMessage(getDeathMessage());
} }
} }
} }

View File

@ -40,7 +40,7 @@ public class GolemBoss extends BossWorldEvent<GolemCreature>
protected void customTick() {} protected void customTick() {}
@Override @Override
public void customCleanup() {} public void customCleanup(boolean onDisable) {}
@Override @Override
protected void customStop() {} protected void customStop() {}

View File

@ -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<ItemStack> _requiredItems;
public RaidAltar(Block altarBlock, RaidType type, List<ItemStack> requiredItems)
{
_altarBlock = altarBlock;
_type = type;
_requiredItems = requiredItems;
}
@SuppressWarnings("deprecation")
private boolean has(Player player, Material type, String itemName, List<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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;
}
}

View File

@ -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<T extends RaidWorldEvent> 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;
}
}

View File

@ -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<T extends LivingEntity> extends EventCreature<T>
{
public RaidCreature(RaidWorldEvent event, Location spawnLocation, String name, boolean useName, double health, double walkRange, boolean healthRegen, Class<T> entityClass)
{
super(event, spawnLocation, name, useName, health, walkRange, healthRegen, entityClass);
}
public abstract void handleDeath(Location location);
}

View File

@ -1,13 +1,159 @@
package mineplex.game.clans.clans.worldevent.raid; 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.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import mineplex.core.MiniPlugin; 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 public class RaidManager extends MiniPlugin
{ {
private static final int MAX_PARTICIPANTS = 10;
private Set<RaidWorldEvent> _raids = new HashSet<>();
private List<RaidAltar> _altars = new ArrayList<>();
public RaidManager(JavaPlugin plugin) public RaidManager(JavaPlugin plugin)
{ {
super("Raid Manager", 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<Player> 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<RaidWorldEvent> 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;
}
}
} }
} }

View File

@ -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<? extends RaidWorldEvent> _clazz;
private RaidType(String raidName, Class<? extends RaidWorldEvent> clazz)
{
_raidName = raidName;
_clazz = clazz;
}
public String getRaidName()
{
return _raidName;
}
public Class<? extends RaidWorldEvent> getClazz()
{
return _clazz;
}
}

View File

@ -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<Player> 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<Player> 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<Location> 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();
}
}

View File

@ -8,7 +8,6 @@ import java.io.FileInputStream;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -17,11 +16,8 @@ import org.bukkit.Difficulty;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator; 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.timing.TimingManager;
import mineplex.core.common.util.FileUtil; import mineplex.core.common.util.FileUtil;
import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.MapUtil;
@ -37,6 +33,10 @@ public class WorldData
public String RaidName; public String RaidName;
public boolean Loaded = false;
protected BukkitTask LoadChecker = null;
public String File = null; public String File = null;
public String Folder = null; public String Folder = null;
@ -56,27 +56,82 @@ public class WorldData
public WorldData(String raidName) public WorldData(String raidName)
{ {
Initialize(); initialize();
Id = getNewId(); Id = getNewId();
RaidName = raidName;
} }
public void Initialize() private List<String> 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<String> 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(() -> UtilServer.runAsync(() ->
{ {
WorldData.this.UnzipWorld(); WorldData.this.unzipWorld();
UtilServer.runSync(() -> UtilServer.runSync(() ->
{ {
TimingManager.start("WorldData loading world."); TimingManager.start("WorldData loading world.");
WorldCreator creator = new WorldCreator(GetFolder()); WorldCreator creator = new WorldCreator(getFolder());
creator.generator(new WorldGenCleanRoom()); creator.generator(new WorldGenCleanRoom());
World = WorldUtil.LoadWorld(creator); World = WorldUtil.LoadWorld(creator);
TimingManager.stop("WorldData loading world."); TimingManager.stop("WorldData loading world.");
World.setDifficulty(Difficulty.HARD); World.setDifficulty(Difficulty.HARD);
@ -84,99 +139,63 @@ public class WorldData
TimingManager.start("WorldData loading WorldConfig."); TimingManager.start("WorldData loading WorldConfig.");
//Load World Data //Load World Data
WorldData.this.LoadWorldConfig(); WorldData.this.loadWorldConfig();
TimingManager.stop("WorldData loading WorldConfig."); TimingManager.stop("WorldData loading WorldConfig.");
}); });
}); });
} }
protected String GetFile() protected String getFile()
{ {
if (File == null) 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; int map;
try try
{ {
map = UtilMath.r(Host.GetFiles().get(game).size()); map = UtilMath.r(loadFiles().size());
} catch (IllegalArgumentException e) }
catch (IllegalArgumentException e)
{ {
System.out.println("No maps found!"); System.out.println("No maps found!");
return null; return null;
} }
File = Host.GetFiles().get(game).get(map); File = loadFiles().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);
}
}
} }
Host.Manager.GetGameCreationManager().SetLastMap(File);
return File; return File;
} }
public String GetFolder() public String getFolder()
{ {
if (Folder == null) if (Folder == null)
{ {
Folder = RaidName + Id + "_" + GetGame().GetName() + "_" + GetFile(); Folder = RaidName + Id + "_" + getFile();
} }
return Folder; return Folder;
} }
protected void UnzipWorld() protected void unzipWorld()
{ {
TimingManager.start("UnzipWorld creating folders"); TimingManager.start("UnzipWorld creating folders");
String folder = GetFolder(); String folder = getFolder();
new File(folder).mkdir(); new File(folder).mkdir();
new File(folder + java.io.File.separator + "region").mkdir(); new File(folder + java.io.File.separator + "region").mkdir();
new File(folder + java.io.File.separator + "data").mkdir(); new File(folder + java.io.File.separator + "data").mkdir();
TimingManager.stop("UnzipWorld creating folders"); TimingManager.stop("UnzipWorld creating folders");
TimingManager.start("UnzipWorld UnzipToDirectory"); 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"); TimingManager.stop("UnzipWorld UnzipToDirectory");
} }
public void LoadWorldConfig() public void loadWorldConfig()
{ {
//Load Track Data //Load Track Data
String line = null; String line = null;
try 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); DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in)); BufferedReader br = new BufferedReader(new InputStreamReader(in));
@ -195,20 +214,10 @@ public class WorldData
if (tokens[0].length() == 0) if (tokens[0].length() == 0)
continue; continue;
//Name & Author
if (tokens[0].equalsIgnoreCase("MAP_NAME"))
{
MapName = tokens[1];
}
else if (tokens[0].equalsIgnoreCase("MAP_AUTHOR"))
{
MapAuthor = tokens[1];
}
//Spawn Locations //Spawn Locations
else if (tokens[0].equalsIgnoreCase("TEAM_NAME")) if (tokens[0].equalsIgnoreCase("TEAM_NAME"))
{ {
SpawnLocs.put(tokens[1], new ArrayList<Location>()); SpawnLocs.put(tokens[1], new ArrayList<>());
currentTeam = SpawnLocs.get(tokens[1]); currentTeam = SpawnLocs.get(tokens[1]);
currentDirection = 0; currentDirection = 0;
} }
@ -218,9 +227,9 @@ public class WorldData
} }
else if (tokens[0].equalsIgnoreCase("TEAM_SPAWNS")) else if (tokens[0].equalsIgnoreCase("TEAM_SPAWNS"))
{ {
for (int i=1 ; i<tokens.length ; i++) for (int i=1; i < tokens.length; i++)
{ {
Location loc = StrToLoc(tokens[i]); Location loc = strToLoc(tokens[i]);
if (loc == null) continue; if (loc == null) continue;
loc.setYaw(currentDirection); loc.setYaw(currentDirection);
@ -232,14 +241,14 @@ public class WorldData
//Data Locations //Data Locations
else if (tokens[0].equalsIgnoreCase("DATA_NAME")) else if (tokens[0].equalsIgnoreCase("DATA_NAME"))
{ {
DataLocs.put(tokens[1], new ArrayList<Location>()); DataLocs.put(tokens[1], new ArrayList<>());
currentData = DataLocs.get(tokens[1]); currentData = DataLocs.get(tokens[1]);
} }
else if (tokens[0].equalsIgnoreCase("DATA_LOCS")) else if (tokens[0].equalsIgnoreCase("DATA_LOCS"))
{ {
for (int i=1 ; i<tokens.length ; i++) for (int i=1; i < tokens.length; i++)
{ {
Location loc = StrToLoc(tokens[i]); Location loc = strToLoc(tokens[i]);
if (loc == null) continue; if (loc == null) continue;
currentData.add(loc); currentData.add(loc);
@ -249,14 +258,14 @@ public class WorldData
//Custom Locations //Custom Locations
else if (tokens[0].equalsIgnoreCase("CUSTOM_NAME")) else if (tokens[0].equalsIgnoreCase("CUSTOM_NAME"))
{ {
CustomLocs.put(tokens[1], new ArrayList<Location>()); CustomLocs.put(tokens[1], new ArrayList<>());
currentData = CustomLocs.get(tokens[1]); currentData = CustomLocs.get(tokens[1]);
} }
else if (tokens[0].equalsIgnoreCase("CUSTOM_LOCS")) else if (tokens[0].equalsIgnoreCase("CUSTOM_LOCS"))
{ {
for (int i=1 ; i<tokens.length ; i++) for (int i=1; i < tokens.length; i++)
{ {
Location loc = StrToLoc(tokens[i]); Location loc = strToLoc(tokens[i]);
if (loc == null) continue; if (loc == null) continue;
currentData.add(loc); currentData.add(loc);
@ -339,7 +348,7 @@ public class WorldData
in.close(); in.close();
Host.Manager.GetGameWorldManager().RegisterWorld(this); Loaded = true;
} }
catch (Exception e) catch (Exception e)
{ {
@ -364,7 +373,7 @@ public class WorldData
return null; return null;
} }
public void Uninitialize() public void uninitialize()
{ {
if (World == null) if (World == null)
{ {
@ -378,30 +387,6 @@ public class WorldData
World = null; World = null;
} }
public void chunkLoad(ChunkPreLoadEvent event)
{
if (World == null)
{
return;
}
if (!event.getWorld().equals(World))
{
return;
}
int x = event.getX();
int z = event.getZ();
if (x >= MinX >> 4 && x <= MaxX >> 4 && z >= MinZ >> 4 && z <= MaxZ >> 4)
{
return;
}
event.setCancelled(true);
}
public int getNewId() public int getNewId()
{ {
@ -461,7 +446,7 @@ public class WorldData
{ {
if (!DataLocs.containsKey(data)) if (!DataLocs.containsKey(data))
{ {
return new ArrayList<Location>(); return new ArrayList<>();
} }
return DataLocs.get(data); return DataLocs.get(data);

View File

@ -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<RaidManager>
{
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 <RaidType>"));
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());
}
}
}
}

View File

@ -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<Class<? extends RaidChallenge<WitherRaid>>> _challenges = new LinkedList<>();
private RaidChallenge<WitherRaid> _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<? extends RaidChallenge<WitherRaid>> 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);
}
}
}

View File

@ -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<WitherRaid>
{
private Location _altar;
private boolean _teleported = false;
private LinkedList<IronGate> _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<EventCreature<?>> 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);
}
}
}

View File

@ -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<Location> _corners;
private List<EventCreature<?>> _guardians;
public IronGate(ChallengeFive challenge, List<Location> corners, List<EventCreature<?>> 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;
}
}

View File

@ -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<WitherRaid>
{
private Location _altar;
private boolean _teleported = false;
private List<FakeBlock> _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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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<WitherRaid>
{
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;
}
}
}
}
}

View File

@ -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<WitherRaid>
{
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<Location> 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));
}
}
}
}
}
}
}

View File

@ -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<WitherRaid>
{
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();
}
}
}
}

View File

@ -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<WitherRaid>
{
private Location _altar;
private boolean _teleported = false;
private List<ChallengeTorch> _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));
}
}

View File

@ -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);
}
}
}
}

View File

@ -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<WitherRaid>
{
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();
}
}
}
}

View File

@ -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<DecayingArcher, Zombie>
{
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() {}
}

View File

@ -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<Zombie>
{
private RaidChallenge<WitherRaid> _challenge;
private ArcherShooting _passive;
public DecayingArcher(RaidChallenge<WitherRaid> 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();
}
}

View File

@ -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<ReanimatedCorpse, Zombie>
{
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());
}
}
}

View File

@ -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<Zombie>
{
private static final Material[] SWORDS = {Material.WOOD_SWORD, Material.STONE_SWORD, Material.GOLD_SWORD, Material.IRON_SWORD, Material.DIAMOND_SWORD};
private RaidChallenge<WitherRaid> _challenge;
private CorpsePassive _passive;
public ReanimatedCorpse(RaidChallenge<WitherRaid> 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();
}
}

View File

@ -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<Giant>
{
private RaidChallenge<WitherRaid> _challenge;
private GoliathPassive _passive;
public Goliath(RaidChallenge<WitherRaid> 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();
}
}

View File

@ -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<Goliath, Giant>
{
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");
}
}
}
}

View File

@ -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<UndeadKnight, Skeleton>
{
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);
}
}
}

View File

@ -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<UndeadMage, Skeleton>
{
private List<Location> _spots;
private long _lastUsed;
public MageBlink(UndeadMage creature, List<Location> 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<Location> 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);
}
}
}
}

View File

@ -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<UndeadMage, Skeleton>
{
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);
}
}
}
}

View File

@ -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<UndeadMage, Skeleton>
{
private final int MAX_KNIGHTS;
private static final int KNIGHTS_PER_USE = 6;
private long _lastUsed;
private List<Location> _spawnLocations;
public MageSummon(UndeadMage creature, List<Location> 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();
}
}
}
}

View File

@ -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<Skeleton>
{
private RaidChallenge<WitherRaid> _challenge;
private KnightPassive _passive;
public UndeadKnight(RaidChallenge<WitherRaid> 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();
}
}

View File

@ -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<Skeleton>
{
private RaidChallenge<WitherRaid> _challenge;
private List<BossPassive<UndeadMage, Skeleton>> _abilities;
private boolean _invuln;
public UndeadMage(RaidChallenge<WitherRaid> challenge, Location location, boolean invulnerable, List<Location> spawnLocations, List<Location> 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<WitherRaid> getChallenge()
{
return _challenge;
}
@Override
public void dieCustom()
{
endAbility();
}
private void endAbility()
{
for (BossPassive<UndeadMage, Skeleton> 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<Player> getPlayers(Map<Player, Double> map, double maxDist)
{
return getPlayers(map, 0, maxDist);
}
protected List<Player> getPlayers(final Map<Player, Double> map, double minDist, double maxDist)
{
List<Player> 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})));
}
}

View File

@ -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<Blaze>
{
private RaidChallenge<WitherRaid> _challenge;
public BlazeMinion(RaidChallenge<WitherRaid> 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;
}
}
}

View File

@ -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();
}
}
}
}

View File

@ -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();
}
}
}

View File

@ -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() {}
}

View File

@ -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<MagmaCube>
{
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();
}
}

View File

@ -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<Magmus, MagmaCube>
{
private long _lastUse;
private List<Class<? extends Cataclysm>> _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();
}
}
}
}

View File

@ -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() {}
}

View File

@ -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<Silverfish>
{
private RaidChallenge<WitherRaid> _challenge;
private SwarmerPassive _passive;
public PitSwarmer(RaidChallenge<WitherRaid> 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();
}
}

View File

@ -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<PitSwarmer, Silverfish>
{
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");
}
}
}
}

View File

@ -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<CharlesWitherton, Wither>
{
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<Player, Double> near = UtilPlayer.getInRadius(getLocation(), RANGE);
for (Entry<Player, Double> 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!")));
}
}
}
}
}

View File

@ -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<CharlesWitherton, Wither>
{
private long _lastUnguided;
private long _lastGuided;
private long _lastBombard;
private Map<WitherSkull, Entity> _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<Entry<WitherSkull, Entity>> iterator = _guidedSkulls.entrySet().iterator();
while (iterator.hasNext())
{
Entry<WitherSkull, Entity> 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() {}
}

View File

@ -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<Wither>
{
private RaidChallenge<WitherRaid> _challenge;
private CharlesSkulls _passive;
private List<BossPassive<CharlesWitherton, Wither>> _abilities = new ArrayList<>();
protected boolean Flying = false;
public CharlesWitherton(RaidChallenge<WitherRaid> 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<WitherRaid> getChallenge()
{
return _challenge;
}
protected List<Location> 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<CharlesWitherton, Wither> 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);
}
}

View File

@ -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<CharlesWitherton, Wither>
{
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!")));
}
}
}
}

View File

@ -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<CharlesWitherton, Wither>
{
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;
}
}
}
}
}

View File

@ -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<CharlesWitherton, Wither>
{
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;
}
}
}
}
}

View File

@ -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<Wither>
{
private RaidChallenge<WitherRaid> _challenge;
private MiniCharlesSkulls _passive;
private int _liveTicks;
protected boolean Flying = false;
public MiniCharles(RaidChallenge<WitherRaid> 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();
}
}
}

View File

@ -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<MiniCharles, Wither>
{
private long _lastUnguided;
private List<WitherSkull> _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();
}
}

View File

@ -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<CharlesWitherton, Wither>
{
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()));
}
}
}
}
}
}

View File

@ -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<CharlesWitherton, Wither>
{
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()));
}
}
}
}
}
}

View File

@ -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<CharlesWitherton, Wither>
{
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()));
}
}
}
}
}
}

View File

@ -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<CharlesWitherton, Wither>
{
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!")));
}
}
}
}
}

View File

@ -24,6 +24,7 @@ import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.ban.ClansBanManager; 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.clans.ClansManager;
import mineplex.game.clans.gameplay.safelog.npc.NPCManager; import mineplex.game.clans.gameplay.safelog.npc.NPCManager;
import mineplex.game.clans.restart.RestartManager; import mineplex.game.clans.restart.RestartManager;
@ -75,6 +76,11 @@ public class SafeLog extends MiniPlugin
isSafeLog = true; isSafeLog = true;
} }
if (Managers.get(RaidManager.class).isInRaid(player.getLocation()))
{
isSafeLog = true;
}
if (!isSafeLog) if (!isSafeLog)
{ {
if (!_clansManager.getIncognitoManager().Get(player).Status) if (!_clansManager.getIncognitoManager().Get(player).Status)

View File

@ -1,11 +1,8 @@
package mineplex.game.clans.items.rares; package mineplex.game.clans.items.rares;
import java.util.HashSet;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -39,9 +36,8 @@ public class RunedPickaxe extends RareItem
static static
{ {
UtilServer.RegisterEvents(new Listener() { UtilServer.RegisterEvents(new Listener()
{
@SuppressWarnings("deprecation")
@EventHandler @EventHandler
public void update(UpdateEvent event) public void update(UpdateEvent event)
{ {
@ -105,6 +101,9 @@ public class RunedPickaxe extends RareItem
if (ClansManager.getInstance().getNetherManager().getNetherWorld().equals(event.getBlock().getWorld())) if (ClansManager.getInstance().getNetherManager().getNetherWorld().equals(event.getBlock().getWorld()))
return; return;
if (ClansManager.getInstance().getWorldEvent().getRaidManager().isInRaid(event.getBlock().getLocation()))
return;
if (ClansManager.getInstance().getBlockRestore().contains(event.getBlock())) if (ClansManager.getInstance().getBlockRestore().contains(event.getBlock()))
return; return;
@ -119,7 +118,7 @@ public class RunedPickaxe extends RareItem
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void blockDamage(BlockBreakEvent event) public void blockBreak(BlockBreakEvent event)
{ {
PlayerGear gear = ClansManager.getInstance().getGearManager().getPlayerGear(event.getPlayer()); PlayerGear gear = ClansManager.getInstance().getGearManager().getPlayerGear(event.getPlayer());
@ -136,6 +135,9 @@ public class RunedPickaxe extends RareItem
if (ClansManager.getInstance().getBlockRestore().contains(event.getBlock())) if (ClansManager.getInstance().getBlockRestore().contains(event.getBlock()))
return; return;
if (ClansManager.getInstance().getWorldEvent().getRaidManager().isInRaid(event.getBlock().getLocation()))
return;
if (!pick._enabled) if (!pick._enabled)
{ {
event.setCancelled(true); event.setCancelled(true);
@ -168,6 +170,5 @@ public class RunedPickaxe extends RareItem
} }
super.onInteract(event); super.onInteract(event);
} }
}
}

View File

@ -11,7 +11,6 @@ import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.Managers;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
@ -94,6 +93,10 @@ public class RestartManager extends MiniPlugin
{ {
return false; return false;
} }
if (ClansManager.getInstance().getWorldEvent().getRaidManager().getActiveRaids() > 0)
{
return false;
}
return true; return true;
} }