Merge remote-tracking branch 'origin/clans-beta' into clans-beta
This commit is contained in:
commit
14027b9780
@ -222,27 +222,31 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
|
||||
for (WatchableObject watchable : (List<WatchableObject>)spawnPacket.l.c())
|
||||
{
|
||||
if ((watchable.a() == 11 || watchable.a() == 3) && watchable.b() instanceof Byte && ((Byte)watchable.b()) == 1)
|
||||
if ((watchable.a() == 11 || watchable.a() == 3) && watchable.b() instanceof Byte
|
||||
&& ((Byte) watchable.b()) == 1)
|
||||
{
|
||||
final String entityName = spawnPacket.l.getString(10);
|
||||
|
||||
if (entityName.isEmpty())
|
||||
{
|
||||
_entityNameMap.get(owner.getName()).remove(spawnPacket.a);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a))
|
||||
{
|
||||
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner.getName()).get(spawnPacket.a)));
|
||||
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner.getName()).get(
|
||||
spawnPacket.a)));
|
||||
|
||||
_entityNameMap.get(owner.getName()).remove(spawnPacket.a);
|
||||
_entityMap.get(owner.getName()).remove(spawnPacket.a);
|
||||
}
|
||||
|
||||
|
||||
final String entityName = spawnPacket.l.getString(10);
|
||||
|
||||
if (entityName.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int newId = UtilEnt.getNewEntityId();
|
||||
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier, true);
|
||||
|
||||
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
|
||||
_entityMap.get(owner.getName()).put(spawnPacket.a, newId);
|
||||
|
||||
|
||||
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -253,45 +257,62 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
|
||||
if (metaPacket.a != 777777 && !_ignoreSkulls.contains(metaPacket.a))
|
||||
{
|
||||
String entityName = "";
|
||||
boolean nameShowing = _entityMap.get(owner.getName()).containsKey(metaPacket.a);
|
||||
|
||||
for (WatchableObject watchable : (List<WatchableObject>)metaPacket.b)
|
||||
boolean isDisplaying = _entityMap.get(owner.getName()).containsKey(metaPacket.a);
|
||||
String currentName = _entityNameMap.get(owner.getName()).get(metaPacket.a);
|
||||
|
||||
if (currentName == null)
|
||||
{
|
||||
if ((watchable.a() == 11 || watchable.a() == 3) && watchable.b() instanceof Byte && ((Byte)watchable.b()) == 1)
|
||||
currentName = "";
|
||||
}
|
||||
|
||||
String newName = currentName;
|
||||
boolean newDisplay = isDisplaying;
|
||||
|
||||
for (WatchableObject watchable : (List<WatchableObject>) metaPacket.b)
|
||||
{
|
||||
if ((watchable.a() == 11 || watchable.a() == 3) && watchable.b() instanceof Byte)
|
||||
{
|
||||
nameShowing = true;
|
||||
newDisplay = ((Byte) watchable.b()) == 1;
|
||||
}
|
||||
|
||||
if ((watchable.a() == 10 || watchable.a() == 2) && watchable.b() instanceof String)
|
||||
{
|
||||
entityName = (String)watchable.b();
|
||||
newName = (String) watchable.b();
|
||||
}
|
||||
}
|
||||
|
||||
if (!_entityMap.get(owner.getName()).containsKey(metaPacket.a)
|
||||
|| !_entityMap.get(owner.getName()).get(metaPacket.a).equals(entityName))
|
||||
// If the name has changed and the name should be showing, or the name display status has changed.
|
||||
if ((!newName.equals(currentName) && newDisplay) || newDisplay != isDisplaying)
|
||||
{
|
||||
if (nameShowing && !entityName.isEmpty())
|
||||
// If name is still being displayed
|
||||
if (newDisplay)
|
||||
{
|
||||
int newId;
|
||||
|
||||
if (_entityMap.get(owner.getName()).containsKey(metaPacket.a))
|
||||
if (isDisplaying) // Sending metadata
|
||||
{
|
||||
newId = _entityMap.get(owner.getName()).get(metaPacket.a);
|
||||
}
|
||||
else
|
||||
else // Spawning new entity
|
||||
{
|
||||
newId = UtilEnt.getNewEntityId();
|
||||
_entityMap.get(owner.getName()).put(metaPacket.a, newId);
|
||||
}
|
||||
|
||||
sendProtocolPackets(owner, metaPacket.a, newId, entityName, verifier,
|
||||
!_entityMap.get(owner.getName()).containsKey(metaPacket.a));
|
||||
sendProtocolPackets(owner, metaPacket.a, newId, newName, verifier, !isDisplaying);
|
||||
|
||||
_entityNameMap.get(owner.getName()).put(metaPacket.a, entityName);
|
||||
_entityMap.get(owner.getName()).put(metaPacket.a, newId);
|
||||
_entityNameMap.get(owner.getName()).put(metaPacket.a, newName);
|
||||
}
|
||||
else if (!entityName.isEmpty())
|
||||
{
|
||||
else
|
||||
{ // Lets delete it
|
||||
int id = _entityMap.get(owner.getName()).get(metaPacket.a);
|
||||
|
||||
verifier.bypassProcess(new PacketPlayOutEntityDestroy(new int[]
|
||||
{
|
||||
id
|
||||
}));
|
||||
|
||||
_entityMap.get(owner.getName()).remove(metaPacket.a);
|
||||
_entityNameMap.get(owner.getName()).remove(metaPacket.a);
|
||||
}
|
||||
}
|
||||
|
@ -628,6 +628,22 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
{
|
||||
entry.getKey().setEntity(entity);
|
||||
|
||||
boolean cancel = entry.getValue().length == 0;
|
||||
|
||||
for (Player player : entry.getValue())
|
||||
{
|
||||
if (player == owner)
|
||||
{
|
||||
cancel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cancel)
|
||||
{
|
||||
packetInfo.setCancelled(true);
|
||||
}
|
||||
|
||||
disguise(entry.getKey(), false, entry.getValue());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class DisguiseCaveSpider extends DisguiseMonster
|
||||
{
|
||||
|
||||
public DisguiseCaveSpider(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(EntityType.CAVE_SPIDER, entity);
|
||||
|
||||
DataWatcher.a(16, new Byte((byte) 0));
|
||||
}
|
||||
|
||||
public boolean bT()
|
||||
{
|
||||
return (DataWatcher.getByte(16) & 0x01) != 0;
|
||||
}
|
||||
|
||||
public void a(boolean flag)
|
||||
{
|
||||
byte b0 = DataWatcher.getByte(16);
|
||||
|
||||
if (flag)
|
||||
b0 = (byte) (b0 | 0x1);
|
||||
else
|
||||
b0 = (byte) (b0 & 0xFFFFFFFE);
|
||||
|
||||
DataWatcher.watch(16, Byte.valueOf(b0));
|
||||
}
|
||||
|
||||
protected String getHurtSound()
|
||||
{
|
||||
return "mob.spider.say";
|
||||
}
|
||||
|
||||
}
|
@ -2,8 +2,7 @@ package mineplex.core.packethandler;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.server.v1_7_R4.EnumProtocol;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
@ -21,7 +20,7 @@ import mineplex.core.common.util.NautHashMap;
|
||||
public class PacketHandler extends MiniPlugin
|
||||
{
|
||||
private NautHashMap<Player, PacketVerifier> _playerVerifierMap = new NautHashMap<Player, PacketVerifier>();
|
||||
private HashSet<IPacketHandler> _packetHandlers = new HashSet<IPacketHandler>();
|
||||
private ArrayList<IPacketHandler> _packetHandlers = new ArrayList<IPacketHandler>();
|
||||
|
||||
public PacketHandler(JavaPlugin plugin)
|
||||
{
|
||||
@ -65,21 +64,17 @@ public class PacketHandler extends MiniPlugin
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
_playerVerifierMap.put(event.getPlayer(), new PacketVerifier(event.getPlayer()));
|
||||
_playerVerifierMap.put(event.getPlayer(), new PacketVerifier(event.getPlayer(), _packetHandlers));
|
||||
|
||||
((CraftPlayer) event.getPlayer()).getHandle().playerConnection.PacketVerifier.addPacketVerifier(_playerVerifierMap
|
||||
.get(event.getPlayer()));
|
||||
|
||||
for (IPacketHandler packetHandler : _packetHandlers)
|
||||
{
|
||||
_playerVerifierMap.get(event.getPlayer()).addPacketHandler(packetHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
((CraftPlayer) event.getPlayer()).getHandle().playerConnection.PacketVerifier.clearVerifiers();
|
||||
_playerVerifierMap.remove(event.getPlayer()).clearHandlers();
|
||||
_playerVerifierMap.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
public PacketVerifier getPacketVerifier(Player player)
|
||||
@ -90,14 +85,9 @@ public class PacketHandler extends MiniPlugin
|
||||
public void addPacketHandler(IPacketHandler packetHandler)
|
||||
{
|
||||
_packetHandlers.add(packetHandler);
|
||||
|
||||
for (PacketVerifier verifier : _playerVerifierMap.values())
|
||||
{
|
||||
verifier.addPacketHandler(packetHandler);
|
||||
}
|
||||
}
|
||||
|
||||
public HashSet<IPacketHandler> getPacketHandlers()
|
||||
public ArrayList<IPacketHandler> getPacketHandlers()
|
||||
{
|
||||
return _packetHandlers;
|
||||
}
|
||||
@ -105,10 +95,5 @@ public class PacketHandler extends MiniPlugin
|
||||
public void removePacketHandler(IPacketHandler packetHandler)
|
||||
{
|
||||
_packetHandlers.remove(packetHandler);
|
||||
|
||||
for (PacketVerifier verifier : _playerVerifierMap.values())
|
||||
{
|
||||
verifier.removePacketHandler(packetHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,54 +1,23 @@
|
||||
package mineplex.core.packethandler;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.IPacketVerifier;
|
||||
import net.minecraft.server.v1_7_R4.Packet;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutAnimation;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityEquipment;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityVelocity;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMove;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMoveLook;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutUpdateAttributes;
|
||||
import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PacketVerifier implements IPacketVerifier
|
||||
{
|
||||
private static Field _destroyId;
|
||||
private Player _owner;
|
||||
|
||||
private List<IPacketHandler> _packetHandlers = new ArrayList<IPacketHandler>();
|
||||
private ArrayList<IPacketHandler> _packetHandlers;
|
||||
|
||||
public PacketVerifier(Player owner)
|
||||
public PacketVerifier(Player owner, ArrayList<IPacketHandler> packetHandlers)
|
||||
{
|
||||
_owner = owner;
|
||||
|
||||
if (_destroyId == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
_destroyId = PacketPlayOutEntityDestroy.class.getDeclaredField("a");
|
||||
_destroyId.setAccessible(true);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println("Field exception in CustomTagFix : ");
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
_packetHandlers = packetHandlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -78,19 +47,4 @@ public class PacketVerifier implements IPacketVerifier
|
||||
{
|
||||
((CraftPlayer)_owner).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
public void clearHandlers()
|
||||
{
|
||||
_packetHandlers.clear();
|
||||
}
|
||||
|
||||
public void addPacketHandler(IPacketHandler packetHandler)
|
||||
{
|
||||
_packetHandlers.add(packetHandler);
|
||||
}
|
||||
|
||||
public void removePacketHandler(IPacketHandler packetHandler)
|
||||
{
|
||||
_packetHandlers.remove(packetHandler);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
package mineplex.core.recharge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -40,7 +42,22 @@ public class Recharge extends MiniPlugin
|
||||
@EventHandler
|
||||
public void PlayerDeath(PlayerDeathEvent event)
|
||||
{
|
||||
Get(event.getEntity().getName()).clear();
|
||||
NautHashMap<String, RechargeData> data = Get(event.getEntity().getName());
|
||||
List<RechargeData> rechargeDatas = new ArrayList<RechargeData>(data.values());
|
||||
|
||||
// Remove/clear all cooldowns that are flagged as ClearOnDeath
|
||||
for (RechargeData rechargeData : rechargeDatas)
|
||||
{
|
||||
if (rechargeData.ClearOnDeath)
|
||||
{
|
||||
data.remove(rechargeData.Name);
|
||||
System.out.println("Cleared " + rechargeData.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Didn't clear: " + rechargeData.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public NautHashMap<String, RechargeData> Get(String name)
|
||||
@ -100,15 +117,16 @@ public class Recharge extends MiniPlugin
|
||||
|
||||
public boolean use(Player player, String ability, String abilityFull, long recharge, boolean inform, boolean attachItem)
|
||||
{
|
||||
return use(player, ability, abilityFull, recharge, inform, attachItem, false);
|
||||
return use(player, ability, abilityFull, recharge, inform, attachItem, false, true);
|
||||
}
|
||||
|
||||
public boolean use(Player player, String ability, long recharge, boolean inform, boolean attachItem, boolean attachDurability)
|
||||
{
|
||||
return use(player, ability, ability, recharge, inform, attachItem, attachDurability);
|
||||
return use(player, ability, ability, recharge, inform, attachItem, attachDurability, true);
|
||||
}
|
||||
|
||||
public boolean use(Player player, String ability, String abilityFull, long recharge, boolean inform, boolean attachItem, boolean attachDurability)
|
||||
public boolean use(Player player, String ability, String abilityFull, long recharge, boolean inform,
|
||||
boolean attachItem, boolean attachDurability, boolean clearOnDeath)
|
||||
{
|
||||
if (recharge == 0)
|
||||
return true;
|
||||
@ -133,7 +151,7 @@ public class Recharge extends MiniPlugin
|
||||
}
|
||||
|
||||
//Insert
|
||||
UseRecharge(player, ability, recharge, attachItem, attachDurability);
|
||||
UseRecharge(player, ability, recharge, attachItem, attachDurability, clearOnDeath);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -145,7 +163,7 @@ public class Recharge extends MiniPlugin
|
||||
|
||||
public void useForce(Player player, String ability, long recharge, boolean attachItem)
|
||||
{
|
||||
UseRecharge(player, ability, recharge, attachItem, false);
|
||||
UseRecharge(player, ability, recharge, attachItem, false, true);
|
||||
}
|
||||
|
||||
public boolean usable(Player player, String ability)
|
||||
@ -172,14 +190,14 @@ public class Recharge extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void UseRecharge(Player player, String ability, long recharge, boolean attachItem, boolean attachDurability)
|
||||
public void UseRecharge(Player player, String ability, long recharge, boolean attachItem, boolean attachDurability, boolean clearOnDeath)
|
||||
{
|
||||
//Event
|
||||
RechargeEvent rechargeEvent = new RechargeEvent(player, ability, recharge);
|
||||
UtilServer.getServer().getPluginManager().callEvent(rechargeEvent);
|
||||
|
||||
Get(player).put(ability, new RechargeData(this, player, ability, player.getItemInHand(),
|
||||
rechargeEvent.GetRecharge(), attachItem, attachDurability));
|
||||
rechargeEvent.GetRecharge(), attachItem, attachDurability, clearOnDeath));
|
||||
}
|
||||
|
||||
public void recharge(Player player, String ability)
|
||||
|
@ -33,8 +33,10 @@ public class RechargeData
|
||||
public boolean Countdown = false; //This will make the output a countdown, instead of a recharge.
|
||||
public boolean AttachItem;
|
||||
public boolean AttachDurability;
|
||||
public boolean ClearOnDeath; // Determines whether the cooldon is cleared when a player dies
|
||||
|
||||
public RechargeData(Recharge host, Player player, String name, ItemStack stack, long rechargeTime, boolean attachitem, boolean attachDurability)
|
||||
public RechargeData(Recharge host, Player player, String name, ItemStack stack, long rechargeTime,
|
||||
boolean attachitem, boolean attachDurability, boolean clearOnDeath)
|
||||
{
|
||||
Host = host;
|
||||
|
||||
@ -46,6 +48,12 @@ public class RechargeData
|
||||
|
||||
AttachItem = attachitem;
|
||||
AttachDurability = attachDurability;
|
||||
ClearOnDeath = clearOnDeath;
|
||||
}
|
||||
|
||||
public RechargeData(Recharge host, Player player, String name, ItemStack stack, long rechargeTime, boolean attachitem, boolean attachDurability)
|
||||
{
|
||||
this(host, player, name, stack, rechargeTime, attachitem, attachDurability, true);
|
||||
}
|
||||
|
||||
public boolean Update()
|
||||
|
@ -18,6 +18,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
@ -143,6 +144,20 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryDrag(InventoryDragEvent event)
|
||||
{
|
||||
if (isPlayerInShop(event.getWhoClicked()))
|
||||
{
|
||||
ShopPageBase<?,?> page = getOpeningPageForPlayer(event.getWhoClicked());
|
||||
|
||||
if (page.matchesInventory(event.getInventory()))
|
||||
{
|
||||
event.setCancelled(true); // Prevent players from dragging items into NPC shop inventories
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent event)
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
|
||||
{
|
||||
playDenySound(_player);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean matchesInventory(Inventory newInventory)
|
||||
|
@ -145,7 +145,7 @@ public class ClanInfo
|
||||
if (ssAdmin())
|
||||
return 1000;
|
||||
|
||||
return 2 + getMembers().size();
|
||||
return Math.min(8, 2 + getMembers().size());
|
||||
}
|
||||
|
||||
public int getAllies()
|
||||
@ -239,6 +239,9 @@ public class ClanInfo
|
||||
|
||||
// Land
|
||||
stringList.add(F.value("Territory", getClaims() + "/" + getClaimsMax()));
|
||||
|
||||
// Member count
|
||||
stringList.add(F.value("Members", getSize() + "/" + getMaxSize()));
|
||||
|
||||
// Energy
|
||||
int energy = getEnergy();
|
||||
@ -566,6 +569,14 @@ public class ClanInfo
|
||||
{
|
||||
return _memberMap.size();
|
||||
}
|
||||
|
||||
public int getMaxSize()
|
||||
{
|
||||
if (ssAdmin())
|
||||
return 1000;
|
||||
|
||||
return 20;
|
||||
}
|
||||
|
||||
public int getEnergyMax()
|
||||
{
|
||||
|
@ -80,15 +80,14 @@ public class ClansGame extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void openClanShop(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (UtilEvent.isAction(event, ActionType.R_BLOCK))
|
||||
boolean hasItem = event.getPlayer().getItemInHand().getType() != Material.AIR;
|
||||
|
||||
if (UtilEvent.isAction(event, ActionType.R_BLOCK) && event.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE)
|
||||
{
|
||||
if (event.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE && !event.getPlayer().isSneaking())
|
||||
if (!event.getPlayer().isSneaking() || !hasItem)
|
||||
{
|
||||
Clans.getClanShop().attemptShopOpen(event.getPlayer());
|
||||
event.setCancelled(true);
|
||||
|
@ -437,6 +437,12 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
UtilPlayer.message(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clan.getName()) + "."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (clan.getSize() >= clan.getMaxSize())
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "The clan " + F.elem("Clan " + clan.getName()) + " is full and cannot be joined!"));
|
||||
return;
|
||||
}
|
||||
|
||||
//Task
|
||||
Plugin.getClanDataAccess().join(clan, caller, ClanRole.RECRUIT, new Callback<Boolean>()
|
||||
@ -1175,7 +1181,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
}
|
||||
*/
|
||||
|
||||
if (!Recharge.Instance.use(caller, "Clans Teleport", 300000, true, false))
|
||||
if (!Recharge.Instance.use(caller, "Clans Teleport", "Clans Teleport", 300000, true, false, false, false))
|
||||
return;
|
||||
|
||||
//Do
|
||||
|
@ -261,6 +261,6 @@ public class ClansRegions extends MiniPlugin
|
||||
|
||||
private boolean isInsideBorders(Location location)
|
||||
{
|
||||
return location.getBlockX() < BORDER_RADIUS && location.getBlockZ() < BORDER_RADIUS;
|
||||
return Math.abs(location.getBlockX()) < BORDER_RADIUS && Math.abs(location.getBlockZ()) < BORDER_RADIUS;
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,8 @@ public class KingHill extends WorldEvent
|
||||
|
||||
public KingHill(WorldEventManager eventManager, Location centerLocation)
|
||||
{
|
||||
super(eventManager.getDamage(), eventManager.getBlockRestore(), eventManager.getClans().getCondition(), "King of the Hill", centerLocation);
|
||||
super(eventManager.getClans().getDisguiseManager(), eventManager.getClans().getProjectile(), eventManager.getDamage(),
|
||||
eventManager.getBlockRestore(), eventManager.getClans().getCondition(), "King of the Hill", centerLocation);
|
||||
_clansManager = eventManager.getClans();
|
||||
_scoreMap = new HashMap<ClanInfo, CaptureData>();
|
||||
_hill = LOADED_HILLS.get(0);
|
||||
|
@ -44,7 +44,8 @@ public class UndeadCamp extends WorldEvent
|
||||
|
||||
public UndeadCamp(WorldEventManager eventManager, Location centerLocation)
|
||||
{
|
||||
super(eventManager.getDamage(), eventManager.getBlockRestore(), eventManager.getClans().getCondition(), "Undead Camp", centerLocation);
|
||||
super(eventManager.getClans().getDisguiseManager(), eventManager.getClans().getProjectile(), eventManager.getDamage(),
|
||||
eventManager.getBlockRestore(), eventManager.getClans().getCondition(), "Undead Camp", centerLocation);
|
||||
|
||||
_eventManager = eventManager;
|
||||
_campSize = CampSize.getCampSize(UtilServer.getPlayers().length);
|
||||
|
@ -14,7 +14,7 @@ import org.bukkit.inventory.Recipe;
|
||||
public class CustomRecipes implements Listener
|
||||
{
|
||||
|
||||
private static final Material[] DISABLED_RECIPES = { Material.EXPLOSIVE_MINECART, Material.JUKEBOX };
|
||||
private static final Material[] DISABLED_RECIPES = { Material.EXPLOSIVE_MINECART, Material.JUKEBOX, Material.FISHING_ROD };
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerCraftItem(CraftItemEvent event)
|
||||
|
@ -369,12 +369,12 @@ public class Gameplay extends MiniPlugin
|
||||
@EventHandler
|
||||
public void AnvilDisable(PlayerInteractEvent event)
|
||||
{
|
||||
if (!UtilEvent.isAction(event, ActionType.R_BLOCK))
|
||||
return;
|
||||
|
||||
if (event.getClickedBlock().getType() != Material.ANVIL)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) return;
|
||||
else if (event.getClickedBlock().getType() != Material.ANVIL) return;
|
||||
else if (player.isSneaking() && player.getItemInHand().getType() != Material.AIR) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -533,7 +533,7 @@ public class Gameplay extends MiniPlugin
|
||||
|| event.getClickedBlock().getType() != Material.ANVIL
|
||||
|| !UtilEvent.isAction(event, ActionType.R_BLOCK)
|
||||
|| player.isSneaking()
|
||||
|| player.getItemInHand() == null)
|
||||
|| player.getItemInHand().getType() == Material.AIR)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ public class BlockToss extends SkillCharge implements IThrown
|
||||
{
|
||||
if (event.getEntity() instanceof FallingBlock)
|
||||
{
|
||||
if (event.getBlock().getType() == Material.AIR) // Falling block is landing and turning block from air to type
|
||||
if (!event.getBlock().getType().isSolid()) // Falling block is landing and turning block from air to type
|
||||
{
|
||||
BlockTossLandEvent landEvent = new BlockTossLandEvent(event.getBlock());
|
||||
Bukkit.getServer().getPluginManager().callEvent(landEvent);
|
||||
|
@ -47,7 +47,7 @@ public abstract class BossAbility<T extends EventCreature, Y extends Entity> imp
|
||||
|
||||
public int getCooldown()
|
||||
{
|
||||
return 60;
|
||||
return 3;
|
||||
}
|
||||
|
||||
public Y getEntity()
|
||||
|
@ -4,8 +4,11 @@ import java.util.UUID;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.disguise.disguises.DisguiseBase;
|
||||
import mineplex.core.disguise.disguises.DisguiseInsentient;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.Location;
|
||||
@ -28,6 +31,7 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
|
||||
|
||||
// Creature Data
|
||||
private String _name;
|
||||
private String _displayName;
|
||||
private boolean _useName;
|
||||
private double _health;
|
||||
private double _maxHealth;
|
||||
@ -45,6 +49,7 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
|
||||
_spawnLocation = spawnLocation;
|
||||
|
||||
_name = name;
|
||||
_displayName = name;
|
||||
_useName = useName;
|
||||
_health = health;
|
||||
_maxHealth = health;
|
||||
@ -63,9 +68,9 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
|
||||
|
||||
setEntity(entity);
|
||||
updateEntityHealth();
|
||||
updateName();
|
||||
entity.setRemoveWhenFarAway(false);
|
||||
spawnCustom();
|
||||
updateName();
|
||||
}
|
||||
|
||||
protected abstract void spawnCustom();
|
||||
@ -78,7 +83,7 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
|
||||
|
||||
protected void updateName()
|
||||
{
|
||||
String name = _name;
|
||||
String name = _displayName;
|
||||
|
||||
if (_showHealthName)
|
||||
{
|
||||
@ -91,9 +96,16 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
|
||||
name += " " + C.cWhite + "(" + healthString + C.cWhite + ")";
|
||||
}
|
||||
|
||||
_entity.setCustomName( name);
|
||||
DisguiseBase disguise = getEvent().getDisguiseManager().getDisguise(getEntity());
|
||||
|
||||
if (disguise != null && disguise instanceof DisguiseInsentient)
|
||||
{
|
||||
((DisguiseInsentient) disguise).setName(name);
|
||||
((DisguiseInsentient) disguise).setCustomNameVisible(_useName);
|
||||
}
|
||||
|
||||
_entity.setCustomName(name);
|
||||
_entity.setCustomNameVisible(_useName);
|
||||
System.out.print(name);
|
||||
}
|
||||
|
||||
public void remove()
|
||||
@ -104,7 +116,18 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
|
||||
public void remove(boolean removeFromEvent)
|
||||
{
|
||||
if (_entity != null)
|
||||
_entity.remove();
|
||||
{
|
||||
if (getHealth() > 0)
|
||||
{
|
||||
_entity.remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
_entity.setHealth(0);
|
||||
_entity.setCustomName("");
|
||||
_entity.setCustomNameVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (removeFromEvent)
|
||||
_event.removeCreature(this);
|
||||
@ -165,6 +188,11 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
|
||||
_spawnLocation = spawnLocation;
|
||||
}
|
||||
|
||||
public String getDisplayName()
|
||||
{
|
||||
return _displayName;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
@ -172,7 +200,7 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
_name = name;
|
||||
_displayName = name == null ? _name : name;
|
||||
updateName();
|
||||
}
|
||||
|
||||
@ -274,7 +302,11 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
|
||||
return;
|
||||
|
||||
DamageCause cause = event.GetCause();
|
||||
if (cause == DamageCause.DROWNING || cause == DamageCause.FALL || cause == DamageCause.SUFFOCATION)
|
||||
|
||||
if (cause == DamageCause.FALL && !getEvent().getCondition().HasCondition(_entity, ConditionType.FALLING, null))
|
||||
event.SetCancelled("Cancel");
|
||||
|
||||
if (cause == DamageCause.DROWNING || cause == DamageCause.SUFFOCATION)
|
||||
event.SetCancelled("Cancel");
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,8 @@ import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
@ -39,6 +41,8 @@ public abstract class WorldEvent implements Listener
|
||||
|
||||
private DamageManager _damageManager;
|
||||
private ConditionManager _conditionManager;
|
||||
private DisguiseManager _disguiseManager;
|
||||
private ProjectileManager _projectileManager;
|
||||
|
||||
private String _name;
|
||||
private EventState _state;
|
||||
@ -56,15 +60,18 @@ public abstract class WorldEvent implements Listener
|
||||
private boolean _isArcade;
|
||||
private double _difficulty = 1;
|
||||
|
||||
public WorldEvent(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name,
|
||||
Location cornerLocation)
|
||||
public WorldEvent(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager,
|
||||
BlockRestore blockRestore, ConditionManager conditionManager, String name, Location cornerLocation)
|
||||
{
|
||||
this(damageManager, blockRestore, conditionManager, name, cornerLocation, null);
|
||||
this(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, name, cornerLocation, null);
|
||||
}
|
||||
|
||||
public WorldEvent(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name,
|
||||
Location cornerLocation, String schematicName)
|
||||
public WorldEvent(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager,
|
||||
BlockRestore blockRestore, ConditionManager conditionManager, String name, Location cornerLocation,
|
||||
String schematicName)
|
||||
{
|
||||
_disguiseManager = disguiseManager;
|
||||
_projectileManager = projectileManager;
|
||||
_damageManager = damageManager;
|
||||
_conditionManager = conditionManager;
|
||||
|
||||
@ -94,11 +101,21 @@ public abstract class WorldEvent implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
public DisguiseManager getDisguiseManager()
|
||||
{
|
||||
return _disguiseManager;
|
||||
}
|
||||
|
||||
public ProjectileManager getProjectileManager()
|
||||
{
|
||||
return _projectileManager;
|
||||
}
|
||||
|
||||
public void setDifficulty(double difficulty)
|
||||
{
|
||||
_difficulty = difficulty;
|
||||
}
|
||||
|
||||
|
||||
public void setArcadeGame(boolean isArcade)
|
||||
{
|
||||
_isArcade = isArcade;
|
||||
@ -223,7 +240,7 @@ public abstract class WorldEvent implements Listener
|
||||
return _map == null ? _cornerLocation : _map.getCenterLocation();
|
||||
}
|
||||
|
||||
protected List<EventCreature> getCreatures()
|
||||
public List<EventCreature> getCreatures()
|
||||
{
|
||||
return _creatures;
|
||||
}
|
||||
@ -283,13 +300,13 @@ public abstract class WorldEvent implements Listener
|
||||
{
|
||||
return _map;
|
||||
}
|
||||
|
||||
|
||||
public void setMap(EventMap map, final Runnable onComplete)
|
||||
{
|
||||
_map = map;
|
||||
|
||||
SchematicRunnable task = new SchematicRunnable(_damageManager.getPlugin(), map.getSchematic(), _cornerLocation.getBlock(),
|
||||
new Callback<List<BlockData>>()
|
||||
SchematicRunnable task = new SchematicRunnable(_damageManager.getPlugin(), map.getSchematic(),
|
||||
_cornerLocation.getBlock(), new Callback<List<BlockData>>()
|
||||
{
|
||||
@Override
|
||||
public void run(List<BlockData> data)
|
||||
|
@ -1,6 +1,8 @@
|
||||
package mineplex.minecraft.game.core.boss.ironwizard;
|
||||
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.boss.EventState;
|
||||
import mineplex.minecraft.game.core.boss.WorldEvent;
|
||||
@ -13,9 +15,10 @@ import org.bukkit.Location;
|
||||
public class GolemBoss extends WorldEvent
|
||||
{
|
||||
|
||||
public GolemBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, Location corner)
|
||||
public GolemBoss(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager,
|
||||
BlockRestore blockRestore, ConditionManager conditionManager, Location cornerLocation)
|
||||
{
|
||||
super(damageManager, blockRestore, conditionManager, "Iron Wizard", corner, "schematic/Golem.schematic");
|
||||
super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Iron Wizard", cornerLocation, "schematic/Golem.schematic");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import java.io.IOException;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.common.block.schematic.Schematic;
|
||||
import mineplex.core.common.block.schematic.UtilSchematic;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.boss.EventMap;
|
||||
@ -23,19 +24,11 @@ public class SlimeBoss extends WorldEvent
|
||||
{
|
||||
private static final int MAX_SIZE = 16;
|
||||
private static final int MIN_SIZE = 2;
|
||||
private ProjectileManager _projectileManager;
|
||||
|
||||
public SlimeBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager,
|
||||
ProjectileManager projectileManager, Location corner)
|
||||
public SlimeBoss(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager,
|
||||
BlockRestore blockRestore, ConditionManager conditionManager, Location cornerLocation)
|
||||
{
|
||||
super(damageManager, blockRestore, conditionManager, "Slime King", corner, "schematic/ClansSlime.schematic");
|
||||
|
||||
_projectileManager = projectileManager;
|
||||
}
|
||||
|
||||
public ProjectileManager getProjectileManager()
|
||||
{
|
||||
return _projectileManager;
|
||||
super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Slime King", cornerLocation, "schematic/ClansSlime.schematic");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,8 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.boss.EventState;
|
||||
import mineplex.minecraft.game.core.boss.WorldEvent;
|
||||
@ -13,10 +15,11 @@ import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
public class SnakeBoss extends WorldEvent
|
||||
{
|
||||
|
||||
public SnakeBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager,
|
||||
Location cornerLocation)
|
||||
public SnakeBoss(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager,
|
||||
BlockRestore blockRestore, ConditionManager conditionManager, Location cornerLocation)
|
||||
{
|
||||
super(damageManager, blockRestore, conditionManager, "Snaaaake", cornerLocation, "schematic/Golem.schematic");
|
||||
super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Snaaaake", cornerLocation,
|
||||
"schematic/Golem.schematic");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,7 +67,7 @@ public class SnakeCreature extends EventCreature<Silverfish>
|
||||
for (int i = 0; i < getHealth() / 50; i++)
|
||||
{
|
||||
SnakeSegment tail = new SnakeSegment(getSpawnLocation().toVector().subtract(dir.clone().multiply(-i)),
|
||||
new ItemStack(i == 0 ? Material.CHEST : Material.DROPPER));
|
||||
new ItemStack(i == 0 ? Material.DROPPER : Material.BEDROCK));
|
||||
|
||||
_segments.add(tail);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class SnakeSegment
|
||||
_prevDir = vec;
|
||||
|
||||
DataWatcher watcher = new DataWatcher(null);
|
||||
watcher.a(0, (byte) 0);
|
||||
watcher.a(0, (byte) 32);
|
||||
watcher.a(1, 0);
|
||||
watcher.a(10, (byte) 0);
|
||||
|
||||
@ -129,7 +129,6 @@ public class SnakeSegment
|
||||
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
|
||||
|
||||
DataWatcher watcher = new DataWatcher(null);
|
||||
watcher.a(0, (byte) 0);
|
||||
watcher.a(1, 0);
|
||||
|
||||
packet.a = getId();
|
||||
@ -140,6 +139,7 @@ public class SnakeSegment
|
||||
|
||||
if (_item != null)
|
||||
{
|
||||
watcher.a(0, (byte) 32);
|
||||
watcher.a(10, (byte) 0);
|
||||
|
||||
for (int i = 11; i < 17; i++)
|
||||
@ -162,6 +162,7 @@ public class SnakeSegment
|
||||
}
|
||||
else
|
||||
{
|
||||
watcher.a(0, (byte) 0);
|
||||
packet.b = EntityType.MAGMA_CUBE.getTypeId();
|
||||
|
||||
return new Packet[]
|
||||
|
@ -1,9 +1,23 @@
|
||||
package mineplex.minecraft.game.core.boss.spider;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.boss.EventState;
|
||||
import mineplex.minecraft.game.core.boss.WorldEvent;
|
||||
@ -13,11 +27,113 @@ import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
|
||||
public class SpiderBoss extends WorldEvent
|
||||
{
|
||||
private HashMap<Block, Double> _webDurability = new HashMap<Block, Double>();
|
||||
|
||||
public SpiderBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager,
|
||||
Location cornerLocation)
|
||||
public SpiderBoss(DisguiseManager disguiseManager, ProjectileManager projectileManager, DamageManager damageManager,
|
||||
BlockRestore blockRestore, ConditionManager conditionManager, Location cornerLocation)
|
||||
{
|
||||
super(damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation, "schematic/Golem.schematic");
|
||||
super(disguiseManager, projectileManager, damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation,
|
||||
"schematic/Golem.schematic");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWebDura(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : getCenterLocation().getWorld().getPlayers())
|
||||
{
|
||||
if (!getEventMap().isInMap(player.getLocation()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
loop: for (double x = -0.3; x <= 0.3; x += 0.6)
|
||||
{
|
||||
for (double z = -0.3; z <= 0.3; z += 0.6)
|
||||
{
|
||||
for (double y = -0.9; y <= 0.9; y += 1.8)
|
||||
{
|
||||
Block block = player.getLocation().add(x, 0.9 + y, z).getBlock();
|
||||
|
||||
if (block.getType() != Material.WEB)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!_webDurability.containsKey(block))
|
||||
{
|
||||
_webDurability.put(block, 0D);
|
||||
}
|
||||
|
||||
_webDurability.put(block, _webDurability.get(block) + 0.1);
|
||||
|
||||
if (_webDurability.get(block) > 1)
|
||||
{
|
||||
_webDurability.remove(block);
|
||||
|
||||
block.setType(Material.AIR);
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.WEB);
|
||||
}
|
||||
|
||||
break loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<Block> itel = _webDurability.keySet().iterator();
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
Block block = itel.next();
|
||||
|
||||
_webDurability.put(block, _webDurability.get(block) - 0.01);
|
||||
|
||||
if (_webDurability.get(block) < 0)
|
||||
{
|
||||
itel.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBreak(BlockBreakEvent event)
|
||||
{
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (!getEventMap().isInMap(block.getLocation()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.getType() != Material.WEB)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_webDurability.remove(block);
|
||||
|
||||
event.setCancelled(false);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onString(ItemSpawnEvent event)
|
||||
{
|
||||
if (!getEventMap().isInMap(event.getLocation()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getEntity().getItemStack().getType() != Material.STRING)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,7 +170,7 @@ public class SpiderBoss extends WorldEvent
|
||||
|
||||
public SpiderMinionCreature spawnMinion(Location location)
|
||||
{
|
||||
SpiderMinionCreature slimeCreature = new SpiderMinionCreature(this, location, 2500);
|
||||
SpiderMinionCreature slimeCreature = new SpiderMinionCreature(this, location, 5);
|
||||
registerCreature(slimeCreature);
|
||||
return slimeCreature;
|
||||
}
|
||||
|
@ -9,11 +9,16 @@ import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Spider;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
@ -22,14 +27,22 @@ import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.disguise.disguises.DisguiseSpider;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||
import mineplex.minecraft.game.core.boss.spider.attacks.SpiderCeilingCling;
|
||||
import mineplex.minecraft.game.core.boss.spider.attacks.SpiderEggScatter;
|
||||
import mineplex.minecraft.game.core.boss.spider.attacks.SpiderEggplosm;
|
||||
import mineplex.minecraft.game.core.boss.spider.attacks.SpiderPoisonBarrage;
|
||||
import mineplex.minecraft.game.core.boss.spider.attacks.SpiderWebBarrage;
|
||||
import mineplex.minecraft.game.core.boss.spider.attacks.SpiderWebStomp;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class SpiderCreature extends EventCreature<Spider>
|
||||
public class SpiderCreature extends EventCreature<Pig>
|
||||
{
|
||||
private ArrayList<BossAbility> _currentAbilities = new ArrayList<BossAbility>();
|
||||
private int _lastAbility;
|
||||
@ -37,10 +50,27 @@ public class SpiderCreature extends EventCreature<Spider>
|
||||
private long _reverseWalk;
|
||||
private Location _standing;
|
||||
private Vector _afkWalk = new Vector();
|
||||
private HashMap<Class, Long> _cooldowns = new HashMap<Class, Long>();
|
||||
private long _lastAttack;
|
||||
|
||||
public SpiderCreature(SpiderBoss boss, Location location, double maxHealth)
|
||||
{
|
||||
super(boss, location, "Brood Mother", true, maxHealth, Spider.class);
|
||||
super(boss, location, "Brood Mother", true, maxHealth, Pig.class);
|
||||
|
||||
spawnEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntity(Pig entity)
|
||||
{
|
||||
super.setEntity(entity);
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
DisguiseSpider disguise = new DisguiseSpider(getEntity());
|
||||
|
||||
((SpiderBoss) getEvent()).getDisguiseManager().disguise(disguise);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,11 +106,14 @@ public class SpiderCreature extends EventCreature<Spider>
|
||||
_lastAbility = 20;// _currentAbility.getCooldown();
|
||||
|
||||
HandlerList.unregisterAll(ability);
|
||||
System.out.print("Unregistered golem ability " + ability.getClass().getSimpleName());
|
||||
System.out.print("Unregistered spider ability " + ability.getClass().getSimpleName());
|
||||
|
||||
_cooldowns.put(ability.getClass(), System.currentTimeMillis() + (ability.getCooldown() * 1000));
|
||||
}
|
||||
else if (!ability.inProgress())
|
||||
else if (ability.inProgress())
|
||||
{
|
||||
canDoNew = false;
|
||||
_lastAbility = 20;// _currentAbility.getCooldown();
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,21 +132,64 @@ public class SpiderCreature extends EventCreature<Spider>
|
||||
|
||||
if (!dist.isEmpty())
|
||||
{
|
||||
{// Egg explosion
|
||||
{// Eggsplosm
|
||||
ArrayList<Player> players = getPlayers(dist, 30);
|
||||
|
||||
if (!players.isEmpty())
|
||||
if (getEvent().getCreatures().size() < 5 && !players.isEmpty())
|
||||
{
|
||||
weight.put(SpiderEggplosm.class, 4);
|
||||
}
|
||||
}
|
||||
|
||||
{ // Ceiling Cling
|
||||
if (getEvent().getCreatures().size() < 5)
|
||||
{
|
||||
weight.put(SpiderCeilingCling.class, 2);
|
||||
}
|
||||
}
|
||||
|
||||
{ // Poison barrage
|
||||
if (!getPlayers(dist, 10, 30).isEmpty())
|
||||
{
|
||||
weight.put(SpiderPoisonBarrage.class, 4);
|
||||
}
|
||||
}
|
||||
|
||||
{// Spider egg scatter
|
||||
if (getEvent().getCreatures().size() < 5 && !getPlayers(dist, 20, 40).isEmpty())
|
||||
{
|
||||
weight.put(SpiderEggScatter.class, 4);
|
||||
}
|
||||
}
|
||||
|
||||
{ // Spider web barrage
|
||||
if (!getPlayers(dist, 30).isEmpty())
|
||||
{
|
||||
weight.put(SpiderWebBarrage.class, 4);
|
||||
}
|
||||
}
|
||||
|
||||
{ // Spider web stomp
|
||||
if (!getPlayers(dist, 20).isEmpty())
|
||||
{
|
||||
weight.put(SpiderWebStomp.class, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (BossAbility ability : _currentAbilities)
|
||||
{
|
||||
weight.remove(ability.getClass());
|
||||
}
|
||||
|
||||
for (Class c : _cooldowns.keySet())
|
||||
{
|
||||
if (_cooldowns.get(c) > System.currentTimeMillis())
|
||||
{
|
||||
weight.remove(c);
|
||||
}
|
||||
}
|
||||
|
||||
BossAbility ability = null;
|
||||
|
||||
if (!weight.isEmpty())
|
||||
@ -125,7 +201,7 @@ public class SpiderCreature extends EventCreature<Spider>
|
||||
i += entry;
|
||||
}
|
||||
|
||||
for (int a = 0; a < 10; a++)
|
||||
loop: for (int a = 0; a < 10; a++)
|
||||
{
|
||||
int luckyNumber = UtilMath.r(i);
|
||||
|
||||
@ -139,13 +215,13 @@ public class SpiderCreature extends EventCreature<Spider>
|
||||
{
|
||||
ability = (BossAbility) entry.getKey().getConstructor(SpiderCreature.class).newInstance(this);
|
||||
|
||||
if (ability.getTarget() == null)
|
||||
if (ability.getTarget() == null || ability.hasFinished())
|
||||
{
|
||||
ability = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
break loop;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -184,95 +260,140 @@ public class SpiderCreature extends EventCreature<Spider>
|
||||
}
|
||||
}
|
||||
|
||||
if (canMove)
|
||||
if (canMove && System.currentTimeMillis() % 20000 > 2000)
|
||||
{
|
||||
Player target = null;
|
||||
double dist = 0;
|
||||
|
||||
for (Player player : UtilPlayer.getNearby(getEntity().getLocation(), 50, true))
|
||||
for (double x = -.5; x <= .5; x += 1)
|
||||
{
|
||||
if (!player.hasLineOfSight(getEntity()))
|
||||
for (double y = 0; y <= 1; y += 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
double d = player.getLocation().distance(getEntity().getLocation());
|
||||
|
||||
if (d > 1.5 && (d < 7 || d > 15) && (target == null || (d < 50 && dist > d)))
|
||||
{
|
||||
target = player;
|
||||
dist = d;
|
||||
}
|
||||
}
|
||||
|
||||
Vector vec = null;
|
||||
boolean superWalk = false;
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
vec = target.getLocation().subtract(getEntity().getLocation()).toVector();
|
||||
vec.setY(getEntity().getLocation().getY());
|
||||
|
||||
double len = vec.length();
|
||||
|
||||
vec.setX(vec.getX() * (UtilMath.random.nextDouble() / 3D));
|
||||
vec.setZ(vec.getZ() * (UtilMath.random.nextDouble() / 3D));
|
||||
|
||||
vec.multiply(len);
|
||||
|
||||
if (target != null && dist < 8)
|
||||
{
|
||||
vec.multiply(-1);
|
||||
superWalk = true;
|
||||
}
|
||||
|
||||
if (!UtilAlg.HasSight(getEntity().getLocation(),
|
||||
getEntity().getLocation().add(vec.clone().normalize().multiply(2))))
|
||||
{
|
||||
_reverseWalk = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if (!UtilTime.elapsed(_reverseWalk, 4000))
|
||||
{
|
||||
vec.multiply(-1);
|
||||
}
|
||||
|
||||
}
|
||||
else if (!UtilTime.elapsed(_lastWalked, 7000))
|
||||
{
|
||||
vec = _afkWalk;
|
||||
}
|
||||
else if (UtilTime.elapsed(_lastWalked, 12000))
|
||||
{
|
||||
_afkWalk = new Vector();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Vector vector = new Vector(UtilMath.r(20) - 10, 0, UtilMath.r(20) - 10);
|
||||
|
||||
if (UtilAlg.HasSight(getEntity().getLocation(),
|
||||
getEntity().getLocation().add(vector.clone().normalize().multiply(2))))
|
||||
for (double z = -.5; z <= .5; z += 1)
|
||||
{
|
||||
vec = _afkWalk = vector;
|
||||
break;
|
||||
Block block = getEntity().getLocation().add(x, y, z).getBlock();
|
||||
|
||||
if (block.getType() == Material.WEB)
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (UtilBlock.solid(getEntity().getLocation().getBlock().getRelative(BlockFace.DOWN))
|
||||
|| getEntity().getVelocity().length() > 0.1)
|
||||
{
|
||||
|
||||
Player target = null;
|
||||
double dist = 0;
|
||||
boolean canAttack = UtilTime.elapsed(_lastAttack, 1300);
|
||||
|
||||
for (Player player : UtilPlayer.getNearby(getEntity().getLocation(), 50, true))
|
||||
{
|
||||
if (!player.hasLineOfSight(getEntity()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
double d = player.getLocation().distance(getEntity().getLocation());
|
||||
|
||||
if ((canAttack || d > 1.5) && (d < 7 || d > 15) && (target == null || (d < 50 && dist > d)))
|
||||
{
|
||||
target = player;
|
||||
dist = d;
|
||||
}
|
||||
}
|
||||
|
||||
_lastWalked = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if (vec != null)
|
||||
{
|
||||
// if (vec.length() > 1)
|
||||
if (target != null && dist < 1.5 && canAttack)
|
||||
{
|
||||
UtilEnt.CreatureMoveFast(getEntity(), getEntity().getLocation().add(vec),
|
||||
(target != null ? 1.8F : 1.1F) + (superWalk ? 0.4F : 0));
|
||||
// UtilEnt.CreatureMoveFast(getEntity(), target.getLocation(), 1F);
|
||||
|
||||
_lastAttack = System.currentTimeMillis();
|
||||
Vector vec = UtilAlg.getTrajectory2d(getEntity(), target);
|
||||
|
||||
vec.multiply(0.5).setY(0.4);
|
||||
|
||||
getEntity().setVelocity(vec);
|
||||
|
||||
getEvent().getCondition().Factory()
|
||||
.Confuse("Brood Mother Bite", target, getEntity(), 4, 0, false, true, true);
|
||||
getEvent().getCondition().Factory()
|
||||
.Blind("Brood Mother Bite", target, getEntity(), 1.5, 0, false, true, true);
|
||||
getEvent().getCondition().Factory()
|
||||
.Slow("Brood Mother Bite", target, getEntity(), 4, 0, false, true, true, true);
|
||||
|
||||
getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.ENTITY_ATTACK,
|
||||
2 * getDifficulty(), true, false, false, "Brood Mother Attack", "Brood Mother Attack");
|
||||
return;
|
||||
}
|
||||
|
||||
Vector vec = null;
|
||||
boolean superWalk = false;
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
vec = target.getLocation().subtract(getEntity().getLocation()).toVector();
|
||||
vec.setY(getEntity().getLocation().getY());
|
||||
|
||||
double len = vec.length();
|
||||
|
||||
vec.setX(vec.getX() * (UtilMath.random.nextDouble() / 3D));
|
||||
vec.setZ(vec.getZ() * (UtilMath.random.nextDouble() / 3D));
|
||||
|
||||
vec.multiply(len);
|
||||
|
||||
if (target != null && dist < 8)
|
||||
{
|
||||
vec.multiply(-1);
|
||||
superWalk = true;
|
||||
}
|
||||
|
||||
if (!UtilAlg.HasSight(getEntity().getLocation(),
|
||||
getEntity().getLocation().add(vec.clone().normalize().multiply(2))))
|
||||
{
|
||||
_reverseWalk = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if (!UtilTime.elapsed(_reverseWalk, 4000))
|
||||
{
|
||||
vec.multiply(-1);
|
||||
}
|
||||
|
||||
}
|
||||
else if (!UtilTime.elapsed(_lastWalked, 7000))
|
||||
{
|
||||
vec = _afkWalk;
|
||||
}
|
||||
else if (UtilTime.elapsed(_lastWalked, 12000))
|
||||
{
|
||||
_afkWalk = new Vector();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Vector vector = new Vector(UtilMath.r(20) - 10, 0, UtilMath.r(20) - 10);
|
||||
|
||||
if (UtilAlg.HasSight(getEntity().getLocation(),
|
||||
getEntity().getLocation().add(vector.clone().normalize().multiply(2))))
|
||||
{
|
||||
vec = _afkWalk = vector;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_lastWalked = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if (vec != null)
|
||||
{
|
||||
// if (vec.length() > 1)
|
||||
{
|
||||
UtilEnt.CreatureMoveFast(getEntity(), getEntity().getLocation().add(vec), (target != null ? 1.8F : 1.1F)
|
||||
+ (superWalk ? 0.4F : 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_standing = getEntity().getLocation();
|
||||
}
|
||||
else
|
||||
else if (_standing != null)
|
||||
{
|
||||
Location l = getEntity().getLocation();
|
||||
|
||||
@ -284,13 +405,18 @@ public class SpiderCreature extends EventCreature<Spider>
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<Player> getPlayers(final HashMap<Player, Double> map, double maxDist)
|
||||
private ArrayList<Player> getPlayers(HashMap<Player, Double> map, double maxDist)
|
||||
{
|
||||
return getPlayers(map, 0, maxDist);
|
||||
}
|
||||
|
||||
private ArrayList<Player> getPlayers(final HashMap<Player, Double> map, double minDist, double maxDist)
|
||||
{
|
||||
ArrayList<Player> list = new ArrayList<Player>();
|
||||
|
||||
for (Player p : map.keySet())
|
||||
{
|
||||
if (map.get(p) <= maxDist)
|
||||
if (map.get(p) >= minDist && map.get(p) <= maxDist)
|
||||
{
|
||||
list.add(p);
|
||||
}
|
||||
@ -308,4 +434,20 @@ public class SpiderCreature extends EventCreature<Spider>
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void noFallDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (getEntity() == null)
|
||||
return;
|
||||
|
||||
if (!event.GetDamageeEntity().equals(getEntity()))
|
||||
return;
|
||||
|
||||
DamageCause cause = event.GetCause();
|
||||
|
||||
if (cause == DamageCause.FALL)
|
||||
event.SetCancelled("Cancel");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
package mineplex.minecraft.game.core.boss.spider;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.CaveSpider;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Silverfish;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -12,21 +16,49 @@ import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.disguise.disguises.DisguiseCaveSpider;
|
||||
import mineplex.core.disguise.disguises.DisguiseSpider;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class SpiderMinionCreature extends EventCreature<CaveSpider>
|
||||
public class SpiderMinionCreature extends EventCreature<Pig>
|
||||
{
|
||||
private long _lastAttack;
|
||||
private Location _moveTo;
|
||||
|
||||
public SpiderMinionCreature(SpiderBoss boss, Location location, double maxHealth)
|
||||
{
|
||||
super(boss, location, "Spider Minion", false, maxHealth, CaveSpider.class);
|
||||
super(boss, location, "Spider Minion", true, maxHealth, Pig.class);
|
||||
|
||||
spawnEntity();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@Override
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
if (getEntity() == null || getEntity().isDead() || !getEntity().isValid())
|
||||
{
|
||||
remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void spawnCustom()
|
||||
{
|
||||
UtilEnt.Vegetate(getEntity());
|
||||
UtilEnt.Vegetate(getEntity(), true);
|
||||
|
||||
getEntity().setVelocity(new Vector(UtilMath.rr(0.5, true), 0.4, UtilMath.rr(0.4, true)));
|
||||
|
||||
DisguiseCaveSpider disguise = new DisguiseCaveSpider(getEntity());
|
||||
|
||||
getEvent().getDisguiseManager().disguise(disguise);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -42,25 +74,72 @@ public class SpiderMinionCreature extends EventCreature<CaveSpider>
|
||||
return;
|
||||
}
|
||||
|
||||
Player target = UtilPlayer.getClosest(getEntity().getLocation());
|
||||
|
||||
UtilEnt.CreatureMoveFast(getEntity(), target.getLocation(), 1.4F);
|
||||
|
||||
if (UtilMath.r(50) == 0)
|
||||
if (UtilMath.r(150) == 0)
|
||||
{
|
||||
getEntity().getWorld().playSound(getEntity().getLocation(), Sound.SPIDER_IDLE, 2.5F, 1);
|
||||
}
|
||||
|
||||
if (target.getLocation().distance(getEntity().getLocation()) < 2)
|
||||
Location loc = getEntity().getLocation();
|
||||
|
||||
Player target = null;
|
||||
|
||||
HashMap<Player, Double> players = UtilPlayer.getInRadius(loc, 30);
|
||||
|
||||
for (Player player : players.keySet())
|
||||
{
|
||||
if (player.hasLineOfSight(getEntity()) && !UtilPlayer.isSpectator(player)
|
||||
&& player.getGameMode() != GameMode.CREATIVE && (target == null || players.get(player) < players.get(target)))
|
||||
{
|
||||
target = player;
|
||||
}
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
if (UtilTime.elapsed(_lastAttack, 6000))
|
||||
{
|
||||
_lastAttack = System.currentTimeMillis();
|
||||
_moveTo = loc.clone().add(UtilMath.rr(3, true), 0, UtilMath.rr(3, true));
|
||||
}
|
||||
|
||||
if (_moveTo != null && _moveTo.distance(loc) > 0.2)
|
||||
{
|
||||
_moveTo.setY(loc.getY());
|
||||
UtilEnt.CreatureMoveFast(getEntity(), _moveTo, 1.2F);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
UtilEnt.CreatureMoveFast(getEntity(), target.getLocation(), 1.6F);
|
||||
|
||||
if (UtilTime.elapsed(_lastAttack, 3000) && target.getLocation().distance(loc) < 2)
|
||||
{
|
||||
_lastAttack = System.currentTimeMillis();
|
||||
Vector vec = UtilAlg.getTrajectory2d(getEntity(), target);
|
||||
vec.multiply(0.4).setY(0.3);
|
||||
|
||||
getEntity().setVelocity(vec);
|
||||
|
||||
getEvent().getCondition().Factory().Blind("Spider Minion Bite", target, getEntity(), 1.5, 0, false, true, true);
|
||||
getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.ENTITY_ATTACK,
|
||||
6 * getDifficulty(), true, false, false, "Spider Minion Attack", "Spider Minion Attack");
|
||||
2 * getDifficulty(), true, false, false, "Spider Minion Attack", "Spider Minion Attack");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void noFallDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (getEntity() == null)
|
||||
return;
|
||||
|
||||
if (!event.GetDamageeEntity().equals(getEntity()))
|
||||
return;
|
||||
|
||||
DamageCause cause = event.GetCause();
|
||||
|
||||
if (cause == DamageCause.FALL)
|
||||
event.SetCancelled("Cancel");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,218 @@
|
||||
package mineplex.minecraft.game.core.boss.spider.attacks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
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.minecraft.game.core.boss.spider.SpiderCreature;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class SpiderCeilingCling extends SpiderEggAbility
|
||||
{
|
||||
private double _startedHealth;
|
||||
private boolean _isClinging;
|
||||
private int _tick;
|
||||
private Location _clingTo;
|
||||
private double _lastY;
|
||||
private int _eggsToLay = UtilMath.r(10) + 10;
|
||||
private boolean _upsideDown;
|
||||
|
||||
public SpiderCeilingCling(SpiderCreature creature)
|
||||
{
|
||||
super(creature);
|
||||
|
||||
_startedHealth = creature.getHealth();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Location loc = getLocation().add(UtilMath.rr(10, true), 12, UtilMath.rr(10, true));
|
||||
|
||||
if (UtilAlg.HasSight(getLocation(), loc))
|
||||
{
|
||||
while (loc.getBlock().getRelative(BlockFace.UP).getType() == Material.AIR)
|
||||
{
|
||||
loc.add(0, 1, 0);
|
||||
}
|
||||
|
||||
if (UtilAlg.HasSight(getLocation(), loc))
|
||||
{
|
||||
_clingTo = loc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMove()
|
||||
{
|
||||
return !_isClinging;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldown()
|
||||
{
|
||||
return 90;
|
||||
}
|
||||
|
||||
public Player getTarget()
|
||||
{
|
||||
List<Player> targets = UtilPlayer.getNearby(getLocation(), 35, true);
|
||||
|
||||
Collections.shuffle(targets);
|
||||
|
||||
for (Player player : targets)
|
||||
{
|
||||
if (UtilAlg.HasSight(getLocation(), player))
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFinished()
|
||||
{
|
||||
return _clingTo == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onKnockback(CustomDamageEvent event)
|
||||
{
|
||||
if (!event.GetDamageeEntity().equals(getEntity()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_isClinging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.SetKnockback(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinished()
|
||||
{
|
||||
if (_upsideDown)
|
||||
{
|
||||
getBoss().setUseName(true);
|
||||
getBoss().setShowHealthName(true);
|
||||
getBoss().setName(null);
|
||||
}
|
||||
|
||||
setEggsFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (!_isClinging && _upsideDown)
|
||||
{
|
||||
if (Math.abs(getLocation().getY() - _lastY) < 0.05)
|
||||
{
|
||||
_isClinging = true;
|
||||
}
|
||||
|
||||
_lastY = getLocation().getY();
|
||||
}
|
||||
|
||||
if (_isClinging && _upsideDown)
|
||||
{
|
||||
getEntity().setVelocity(new Vector(0, 1, 0));
|
||||
|
||||
if (getBoss().getEvent().getCreatures().size() <= 3
|
||||
&& (_tick > 30 * 20 || _startedHealth - getBoss().getHealth() > 150 || getEggs() == 0))
|
||||
{
|
||||
_isClinging = false;
|
||||
_clingTo = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_isClinging && _clingTo != null)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (Location loc : UtilShapes.getLinesDistancedPoints(getLocation(), _clingTo, 0.3))
|
||||
{
|
||||
if (i++ % 3 == _tick % 3)
|
||||
{
|
||||
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, loc, 0F, 0F, 0F, 0, 1, ViewDist.NORMAL,
|
||||
UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
|
||||
if (_eggsToLay > 0)
|
||||
{
|
||||
if (_tick % 3 == 0)
|
||||
{
|
||||
Vector vec = new Vector(UtilMath.rr(1, true), UtilMath.rr(0.5, false), UtilMath.rr(1, true)).normalize()
|
||||
.multiply(0.7).setY(0.4 + (UtilMath.rr(0.4, false)));
|
||||
|
||||
UtilEnt.CreatureLook(getEntity(), getLocation().add(vec));
|
||||
|
||||
shootEgg(vec);
|
||||
|
||||
_eggsToLay--;
|
||||
}
|
||||
}
|
||||
|
||||
if (_eggsToLay < 3)
|
||||
{
|
||||
if (!_upsideDown)
|
||||
{
|
||||
_upsideDown = true;
|
||||
|
||||
getBoss().setUseName(false);
|
||||
getBoss().setShowHealthName(false);
|
||||
getBoss().setName("Dinnerbone");
|
||||
}
|
||||
|
||||
getEntity().setVelocity(UtilAlg.getTrajectory(getLocation(), _clingTo).multiply(0.4));
|
||||
}
|
||||
}
|
||||
|
||||
_tick++;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (!event.GetDamageeEntity().equals(getEntity()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.GetCause() != DamageCause.FALL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.SetCancelled("Cancelled");
|
||||
}
|
||||
}
|
@ -0,0 +1,228 @@
|
||||
package mineplex.minecraft.game.core.boss.spider.attacks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderBoss;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderCreature;
|
||||
import net.minecraft.server.v1_7_R4.MathHelper;
|
||||
import net.minecraft.server.v1_7_R4.MovingObjectPosition;
|
||||
import net.minecraft.server.v1_7_R4.Vec3D;
|
||||
|
||||
public abstract class SpiderEggAbility extends BossAbility<SpiderCreature, Pig>
|
||||
{
|
||||
private HashMap<Block, Long> _eggs = new HashMap<Block, Long>();
|
||||
private ArrayList<FallingBlock> _fallingBlocks = new ArrayList<FallingBlock>();
|
||||
|
||||
public SpiderEggAbility(SpiderCreature creature)
|
||||
{
|
||||
super(creature);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (UtilPlayer.isSpectator(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
|
||||
return;
|
||||
|
||||
Block block = event.getTo().getBlock().getRelative(BlockFace.DOWN);
|
||||
|
||||
if (!_eggs.containsKey(block))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_eggs.remove(block);
|
||||
|
||||
block.setType(Material.AIR);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.DIG_SNOW, 2.5F, 0F);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.BURP, 2.5F, 1.5F);
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.SNOW_BLOCK, 0),
|
||||
block.getLocation().add(0.5, 0.4, 0.5), 0.4F, 0.4F, 0.4F, 0, 40, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.DRAGON_EGG, 0),
|
||||
block.getLocation().add(0.5, 0.6, 0.5), 0.6F, 0.5F, 0.6F, 0, 80, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
|
||||
}
|
||||
|
||||
public boolean hasEggsFinished()
|
||||
{
|
||||
return getEggs() == 0;
|
||||
}
|
||||
|
||||
public void setEggsFinished()
|
||||
{
|
||||
for (FallingBlock block : _fallingBlocks)
|
||||
{
|
||||
block.remove();
|
||||
}
|
||||
|
||||
for (Block b : _eggs.keySet())
|
||||
{
|
||||
b.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
protected void shootEgg(Vector vector)
|
||||
{
|
||||
FallingBlock block = getLocation().getWorld().spawnFallingBlock(getLocation(), Material.DRAGON_EGG, (byte) 0);
|
||||
block.setDropItem(false);
|
||||
block.setVelocity(vector);
|
||||
|
||||
_fallingBlocks.add(block);
|
||||
|
||||
getLocation().getWorld().playSound(getLocation(), Sound.SHEEP_SHEAR, 2.5F, 0F);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEggTeleport(BlockFromToEvent event)
|
||||
{
|
||||
if (!_eggs.containsKey(event.getBlock()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEggyUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<Entry<Block, Long>> itel = _eggs.entrySet().iterator();
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
Entry<Block, Long> entry = itel.next();
|
||||
|
||||
if (entry.getValue() < System.currentTimeMillis())
|
||||
{
|
||||
itel.remove();
|
||||
entry.getKey().setType(Material.AIR);
|
||||
|
||||
entry.getKey().getWorld()
|
||||
.playEffect(entry.getKey().getLocation(), Effect.STEP_SOUND, Material.DRAGON_EGG.getId());
|
||||
|
||||
((SpiderBoss) getBoss().getEvent()).spawnMinion(entry.getKey().getLocation().add(0.5, 0.5, 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<FallingBlock> fallingIterator = _fallingBlocks.iterator();
|
||||
|
||||
while (fallingIterator.hasNext())
|
||||
{
|
||||
FallingBlock cur = fallingIterator.next();
|
||||
|
||||
if (cur.isDead() || !cur.isValid() || cur.getVelocity().length() < 0.05 || cur.getTicksLived() > 400
|
||||
|| !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
fallingIterator.remove();
|
||||
|
||||
Block block = cur.getLocation().getBlock();
|
||||
|
||||
if ((UtilBlock.airFoliage(block) || block.getType() == Material.DRAGON_EGG)
|
||||
&& block.getRelative(BlockFace.DOWN).getType() != Material.DRAGON_EGG)
|
||||
{
|
||||
block.setType(Material.DRAGON_EGG);
|
||||
_eggs.put(block, System.currentTimeMillis() + 10000 + UtilMath.r(10000));
|
||||
}
|
||||
|
||||
// Expire
|
||||
if (cur.getTicksLived() > 400
|
||||
|| !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
cur.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
cur.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle();
|
||||
Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
|
||||
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ
|
||||
+ nmsEntity.motZ);
|
||||
|
||||
MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false);
|
||||
vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
|
||||
vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ);
|
||||
|
||||
if (finalObjectPosition != null)
|
||||
{
|
||||
vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c);
|
||||
}
|
||||
|
||||
if (finalObjectPosition != null)
|
||||
{
|
||||
Block block = cur.getWorld().getBlockAt(finalObjectPosition.b, finalObjectPosition.c, finalObjectPosition.d);
|
||||
|
||||
if (!UtilBlock.airFoliage(block) && !block.isLiquid())
|
||||
{
|
||||
nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX));
|
||||
nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY));
|
||||
nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ));
|
||||
float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ
|
||||
* nmsEntity.motZ);
|
||||
nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D;
|
||||
nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D;
|
||||
nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D;
|
||||
|
||||
if ((UtilBlock.airFoliage(block) || block.getType() == Material.DRAGON_EGG)
|
||||
&& block.getRelative(BlockFace.DOWN).getType() != Material.DRAGON_EGG)
|
||||
{
|
||||
block.setType(Material.DRAGON_EGG);
|
||||
_eggs.put(block, System.currentTimeMillis() + 10000 + UtilMath.r(10000));
|
||||
}
|
||||
|
||||
fallingIterator.remove();
|
||||
cur.remove();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), cur.getLocation()
|
||||
.add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getEggs()
|
||||
{
|
||||
return _fallingBlocks.size() + _eggs.size();
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package mineplex.minecraft.game.core.boss.spider.attacks;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderCreature;
|
||||
|
||||
public class SpiderEggScatter extends SpiderEggAbility
|
||||
{
|
||||
private int _eggsToSpray = 25;
|
||||
private float _yaw;
|
||||
private float _addYaw;
|
||||
private int _tick;
|
||||
|
||||
public SpiderEggScatter(SpiderCreature creature)
|
||||
{
|
||||
super(creature);
|
||||
|
||||
_eggsToSpray = 6 + UtilMath.r(5);
|
||||
|
||||
_addYaw = (360F / _eggsToSpray) / 4;
|
||||
}
|
||||
|
||||
public int getCooldown()
|
||||
{
|
||||
return 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMove()
|
||||
{
|
||||
return _eggsToSpray <= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress()
|
||||
{
|
||||
return _eggsToSpray > 0 || !hasEggsFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFinished()
|
||||
{
|
||||
return _eggsToSpray <= 0 && hasEggsFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinished()
|
||||
{
|
||||
setEggsFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (_eggsToSpray <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UtilEnt.CreatureLook(getEntity(), 0, _yaw);
|
||||
|
||||
_yaw += _addYaw;
|
||||
|
||||
if (_tick % 4 == 0 && _eggsToSpray > 0)
|
||||
{
|
||||
_eggsToSpray--;
|
||||
|
||||
Vector vec = getEntity().getLocation().getDirection();
|
||||
|
||||
vec.setY(0).normalize().multiply(0.7 + UtilMath.rr(0.16, false)).setY(0.4 + (UtilMath.rr(0.4, false)));
|
||||
|
||||
shootEgg(vec);
|
||||
}
|
||||
|
||||
_tick++;
|
||||
}
|
||||
|
||||
}
|
@ -1,47 +1,14 @@
|
||||
package mineplex.minecraft.game.core.boss.spider.attacks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Spider;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderBoss;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderCreature;
|
||||
import net.minecraft.server.v1_7_R4.MathHelper;
|
||||
import net.minecraft.server.v1_7_R4.MovingObjectPosition;
|
||||
import net.minecraft.server.v1_7_R4.Vec3D;
|
||||
|
||||
public class SpiderEggplosm extends BossAbility<SpiderCreature, Spider>
|
||||
public class SpiderEggplosm extends SpiderEggAbility
|
||||
{
|
||||
private int _eggsToSpray = 30;
|
||||
private HashMap<Block, Long> _eggs = new HashMap<Block, Long>();
|
||||
private ArrayList<FallingBlock> _fallingBlocks = new ArrayList<FallingBlock>();
|
||||
private int _tick;
|
||||
private int _eggsToSpray = 25;
|
||||
private float _yaw;
|
||||
private float _addYaw;
|
||||
|
||||
@ -49,70 +16,44 @@ public class SpiderEggplosm extends BossAbility<SpiderCreature, Spider>
|
||||
{
|
||||
super(creature);
|
||||
|
||||
_eggsToSpray = 20 + (int) Math.ceil(15 * (1 - creature.getHealthPercent()));
|
||||
|
||||
_addYaw = 360F / _eggsToSpray;
|
||||
}
|
||||
|
||||
public int getCooldown()
|
||||
{
|
||||
return 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMove()
|
||||
{
|
||||
return inProgress();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (UtilPlayer.isSpectator(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
|
||||
return;
|
||||
|
||||
Block block = event.getTo().getBlock().getRelative(BlockFace.DOWN);
|
||||
|
||||
if (!_eggs.containsKey(block))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_eggs.remove(block);
|
||||
|
||||
block.setType(Material.AIR);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.FALL_BIG, 2.5F, 0F);
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.DRAGON_EGG, 0),
|
||||
block.getLocation().add(0.5, 0.6, 0.5), 0.6F, 0.5F, 0.6F, 0, 100, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
|
||||
return _eggsToSpray <= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress()
|
||||
{
|
||||
return _eggsToSpray > 0;
|
||||
return _eggsToSpray > 0 || !hasEggsFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFinished()
|
||||
{
|
||||
return _eggsToSpray <= 0 && _fallingBlocks.isEmpty() && _eggs.isEmpty();
|
||||
return _eggsToSpray <= 0 && hasEggsFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinished()
|
||||
{
|
||||
for (FallingBlock block : _fallingBlocks)
|
||||
{
|
||||
block.remove();
|
||||
}
|
||||
|
||||
for (Block b : _eggs.keySet())
|
||||
{
|
||||
b.setType(Material.AIR);
|
||||
}
|
||||
setEggsFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (_eggsToSpray > 0 && _tick % 10 == 0)
|
||||
if (_eggsToSpray > 0)
|
||||
{
|
||||
_eggsToSpray--;
|
||||
|
||||
@ -122,111 +63,10 @@ public class SpiderEggplosm extends BossAbility<SpiderCreature, Spider>
|
||||
|
||||
Vector vec = getEntity().getLocation().getDirection();
|
||||
|
||||
vec.setY(0).normalize().setY(0.4 + (UtilMath.rr(0.4, false)));
|
||||
vec.setY(0).normalize().multiply(0.7).setY(0.4 + (UtilMath.rr(0.4, false)));
|
||||
|
||||
FallingBlock block = getLocation().getWorld().spawnFallingBlock(vec.toLocation(getLocation().getWorld()),
|
||||
Material.WEB, (byte) 0);
|
||||
block.setDropItem(false);
|
||||
|
||||
_fallingBlocks.add(block);
|
||||
}
|
||||
else
|
||||
{
|
||||
Iterator<Entry<Block, Long>> itel = _eggs.entrySet().iterator();
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
Entry<Block, Long> entry = itel.next();
|
||||
|
||||
if (entry.getValue() < System.currentTimeMillis())
|
||||
{
|
||||
itel.remove();
|
||||
entry.getKey().setType(Material.AIR);
|
||||
entry.getKey().getWorld().playEffect(entry.getKey().getLocation(), Effect.STEP_SOUND,
|
||||
Material.DRAGON_EGG.getId());
|
||||
((SpiderBoss) getBoss().getEvent()).spawnMinion(entry.getKey().getLocation().add(0.5, 0.1, 0.5));
|
||||
}
|
||||
}
|
||||
shootEgg(vec);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<FallingBlock> fallingIterator = _fallingBlocks.iterator();
|
||||
|
||||
while (fallingIterator.hasNext())
|
||||
{
|
||||
FallingBlock cur = fallingIterator.next();
|
||||
|
||||
if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400
|
||||
|| !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
fallingIterator.remove();
|
||||
|
||||
Block block = cur.getLocation().getBlock();
|
||||
block.setType(Material.DRAGON_EGG);
|
||||
_eggs.put(block, System.currentTimeMillis() + 10000 + UtilMath.r(10000));
|
||||
|
||||
// Expire
|
||||
if (cur.getTicksLived() > 400
|
||||
|| !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
cur.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
cur.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle();
|
||||
Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
|
||||
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY,
|
||||
nmsEntity.locZ + nmsEntity.motZ);
|
||||
|
||||
MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false);
|
||||
vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
|
||||
vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ);
|
||||
|
||||
if (finalObjectPosition != null)
|
||||
{
|
||||
vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c);
|
||||
}
|
||||
|
||||
if (finalObjectPosition != null)
|
||||
{
|
||||
Block block = cur.getWorld().getBlockAt(finalObjectPosition.b, finalObjectPosition.c, finalObjectPosition.d);
|
||||
|
||||
if (!UtilBlock.airFoliage(block) && !block.isLiquid())
|
||||
{
|
||||
nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX));
|
||||
nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY));
|
||||
nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ));
|
||||
float f2 = MathHelper.sqrt(
|
||||
nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ);
|
||||
nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D;
|
||||
nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D;
|
||||
nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D;
|
||||
|
||||
block.setType(Material.DRAGON_EGG);
|
||||
_eggs.put(block, System.currentTimeMillis() + 10000 + UtilMath.r(10000));
|
||||
|
||||
fallingIterator.remove();
|
||||
cur.remove();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0),
|
||||
cur.getLocation().add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL,
|
||||
UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,68 @@
|
||||
package mineplex.minecraft.game.core.boss.spider.attacks;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.disguise.disguises.DisguiseSlime;
|
||||
import mineplex.core.projectile.IThrown;
|
||||
import mineplex.core.projectile.ProjectileUser;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
|
||||
public class SpiderPoison implements IThrown
|
||||
{
|
||||
private EventCreature _boss;
|
||||
|
||||
public SpiderPoison(EventCreature boss, Entity item)
|
||||
{
|
||||
_boss = boss;
|
||||
|
||||
boss.getEvent().getProjectileManager().AddThrow(item, boss.getEntity(), this, -1, true, true, true, false, 2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Collide(LivingEntity target, Block block, ProjectileUser data)
|
||||
{
|
||||
if (target instanceof Player)
|
||||
{
|
||||
_boss.getEvent().getCondition().Factory()
|
||||
.Poison("Brood Mother Poison", target, _boss.getEntity(), 2, 1, false, true, false);
|
||||
|
||||
_boss.getEvent()
|
||||
.getDamageManager()
|
||||
.NewDamageEvent(target, _boss.getEntity(), null, DamageCause.PROJECTILE, 2, true, false, false,
|
||||
"Brood Mother Poison", "Brood Mother Poison");
|
||||
}
|
||||
|
||||
burst(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Idle(ProjectileUser data)
|
||||
{
|
||||
burst(data);
|
||||
}
|
||||
|
||||
private void burst(ProjectileUser data)
|
||||
{
|
||||
data.GetThrown().remove();
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.ICON_CRACK.getParticle(Material.SLIME_BALL, 0), data.GetThrown().getLocation(),
|
||||
0.3F, 0.3F, 0.3F, 0, 30, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Expire(ProjectileUser data)
|
||||
{
|
||||
burst(data);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
package mineplex.minecraft.game.core.boss.spider.attacks;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderCreature;
|
||||
|
||||
public class SpiderPoisonBarrage extends BossAbility<SpiderCreature, Pig>
|
||||
{
|
||||
private int _poisonAmount = UtilMath.r(20) + 30;
|
||||
private int _tick;
|
||||
private float _yawToFace;
|
||||
|
||||
public SpiderPoisonBarrage(SpiderCreature creature)
|
||||
{
|
||||
super(creature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMove()
|
||||
{
|
||||
return _poisonAmount <= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress()
|
||||
{
|
||||
return _poisonAmount > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFinished()
|
||||
{
|
||||
return _poisonAmount <= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinished()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldown()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public Player getTarget()
|
||||
{
|
||||
return getTarget(1, 30);
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (_tick == 0)
|
||||
{
|
||||
Player target = getTarget();
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
UtilEnt.CreatureLook(getEntity(), target);
|
||||
|
||||
Vector vec = UtilAlg.getTrajectory(getEntity(), target);
|
||||
|
||||
_yawToFace = UtilAlg.GetYaw(vec);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
Location loc = getEntity().getEyeLocation().add(getLocation().getDirection().setY(0).normalize().multiply(0.4));
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.ICON_CRACK.getParticle(Material.SLIME_BALL, 0), loc, 0.3F, 0.3F, 0.3F, 0, 30,
|
||||
ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
}
|
||||
|
||||
if (_tick > 30)
|
||||
{
|
||||
Player target = getTarget();
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
Vector vec = UtilAlg.getTrajectory(getEntity(), target);
|
||||
|
||||
_yawToFace = UtilAlg.GetYaw(vec);
|
||||
}
|
||||
|
||||
float currentYaw = getLocation().getYaw();
|
||||
|
||||
if ((int) currentYaw != (int) _yawToFace)
|
||||
{
|
||||
// How much should the yaw change if we go either direction, would it be faster if we subtracted or added?
|
||||
float added = ((_yawToFace + 720) - currentYaw) % 360;
|
||||
float subtracted = /*-*/((currentYaw + 720) - _yawToFace) % 360;
|
||||
|
||||
float diff = Math.max(-10, Math.min(10, added > subtracted ? -subtracted : added));
|
||||
|
||||
float newYaw = (currentYaw + diff + 720) % 360;
|
||||
|
||||
UtilEnt.CreatureLook(getEntity(), 0, newYaw);
|
||||
|
||||
System.out.print("Current yaw: " + currentYaw + ", Yaw to face: " + _yawToFace + ", New Yaw: " + newYaw
|
||||
+ ", Add: " + added + ", Subtracted: " + subtracted);
|
||||
}
|
||||
|
||||
if (_tick % 2 == 0)
|
||||
{
|
||||
Vector vec = getLocation().getDirection();
|
||||
|
||||
vec.setX(vec.getX() + UtilMath.rr(0.09, true));
|
||||
vec.setZ(vec.getZ() + UtilMath.rr(0.09, true));
|
||||
|
||||
vec.setY(0).normalize().multiply(1 + UtilMath.rr(0.2, true));
|
||||
vec.setY(0.35 + UtilMath.rr(0.3, false));
|
||||
|
||||
Item item = getLocation().getWorld()
|
||||
.dropItem(getLocation().add(0, 0.5, 0), new ItemStack(Material.EMERALD_BLOCK));
|
||||
|
||||
item.setVelocity(vec);
|
||||
|
||||
new SpiderPoison(getBoss(), item);
|
||||
|
||||
getLocation().getWorld().playSound(getLocation(), Sound.CREEPER_HISS, 2, 0F);
|
||||
|
||||
_poisonAmount--;
|
||||
}
|
||||
}
|
||||
|
||||
_tick++;
|
||||
}
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
package mineplex.minecraft.game.core.boss.spider.attacks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderCreature;
|
||||
|
||||
public class SpiderWebBarrage extends BossAbility
|
||||
{
|
||||
private int _canShoot;
|
||||
private ArrayList<FallingBlock> _fallingBlocks = new ArrayList<FallingBlock>();
|
||||
private int _tick;
|
||||
|
||||
public SpiderWebBarrage(SpiderCreature creature)
|
||||
{
|
||||
super(creature);
|
||||
|
||||
_canShoot = (int) (40 + ((1 - creature.getHealthPercent()) * 50));
|
||||
|
||||
Player target = getTarget();
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
UtilEnt.CreatureLook(getEntity(), target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMove()
|
||||
{
|
||||
return _canShoot <= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldown()
|
||||
{
|
||||
return 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress()
|
||||
{
|
||||
return _canShoot > 0 || !_fallingBlocks.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFinished()
|
||||
{
|
||||
return _canShoot <= 0 && _fallingBlocks.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinished()
|
||||
{
|
||||
for (FallingBlock block : _fallingBlocks)
|
||||
{
|
||||
block.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public Player getTarget()
|
||||
{
|
||||
return getTarget(10, 30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (_canShoot > 0 && _tick % 2 == 0)
|
||||
{
|
||||
_canShoot--;
|
||||
|
||||
Vector vec = getLocation().getDirection().setY(0).normalize();
|
||||
|
||||
vec.add(new Vector(UtilMath.rr(0.45, true), 0, UtilMath.rr(0.45, true))).normalize();
|
||||
|
||||
vec.setY(0.8).multiply(0.75 + UtilMath.rr(0.3, true));
|
||||
|
||||
FallingBlock block = getLocation().getWorld().spawnFallingBlock(getLocation(), Material.WEB, (byte) 0);
|
||||
block.setDropItem(false);
|
||||
|
||||
_fallingBlocks.add(block);
|
||||
|
||||
block.setVelocity(vec);
|
||||
|
||||
getLocation().getWorld().playSound(getLocation(), Sound.FIZZ, 3, 2F);
|
||||
}
|
||||
|
||||
_tick++;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<FallingBlock> fallingIterator = _fallingBlocks.iterator();
|
||||
|
||||
while (fallingIterator.hasNext())
|
||||
{
|
||||
FallingBlock cur = fallingIterator.next();
|
||||
|
||||
if (cur.isDead() || !cur.isValid() || cur.getVelocity().length() < 0.05 || cur.getTicksLived() > 400
|
||||
|| !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
fallingIterator.remove();
|
||||
|
||||
Block block = cur.getLocation().getBlock();
|
||||
|
||||
if (UtilBlock.airFoliage(block) || block.getType() == Material.WEB)
|
||||
{
|
||||
block.setType(Material.WEB);
|
||||
}
|
||||
|
||||
// Expire
|
||||
if (cur.getTicksLived() > 400
|
||||
|| !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
cur.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
cur.remove();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package mineplex.minecraft.game.core.boss.spider.attacks;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderCreature;
|
||||
|
||||
/**
|
||||
* A attack where webs appear all around the spider in a kinda maze formation, making it hard to approach it.
|
||||
*/
|
||||
public class SpiderWebStomp extends BossAbility
|
||||
{
|
||||
private int _tick;
|
||||
|
||||
public SpiderWebStomp(SpiderCreature creature)
|
||||
{
|
||||
super(creature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldown()
|
||||
{
|
||||
return 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMove()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFinished()
|
||||
{
|
||||
return _tick > 40;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinished()
|
||||
{
|
||||
}
|
||||
|
||||
public Player getTarget()
|
||||
{
|
||||
if (!UtilEnt.isGrounded(getEntity()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return super.getTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (_tick++ == 0)
|
||||
{
|
||||
int amount = UtilMath.r(60) + 60;
|
||||
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
Block block = getLocation().getBlock().getRelative((int) UtilMath.rr(UtilMath.r(16) + 4, true), 0,
|
||||
(int) UtilMath.rr(UtilMath.r(16) + 4, true));
|
||||
|
||||
if (block.getType() != Material.AIR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
block.setType(Material.WEB);
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.WEB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -18,12 +18,15 @@ public class StartCommand extends CommandBase<ArcadeManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (Plugin.GetGame() == null)
|
||||
if (Plugin.GetGame() == null || Plugin.GetGame().GetState() == GameState.Loading)
|
||||
{
|
||||
caller.sendMessage(C.cRed + C.Bold + "Game is loading...");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (Plugin.GetGame().GetState() != GameState.Recruit)
|
||||
{
|
||||
caller.sendMessage("Game is already in progress...");
|
||||
caller.sendMessage(C.cRed + C.Bold + "Game is already in progress...");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.EventState;
|
||||
import mineplex.minecraft.game.core.boss.WorldEvent;
|
||||
import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderBoss;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
@ -38,12 +39,12 @@ import nautilus.game.arcade.kit.Kit;
|
||||
public class BossBattles extends TeamGame
|
||||
{
|
||||
private WorldEvent _currentBoss;
|
||||
private BattleBoss _chosenBoss = BattleBoss.values()[UtilMath
|
||||
.r(BattleBoss.values().length)];
|
||||
private BattleBoss _chosenBoss = BattleBoss.values()[UtilMath.r(BattleBoss
|
||||
.values().length)];
|
||||
private ArrayList<BossDisplay> _displays = new ArrayList<BossDisplay>();
|
||||
|
||||
public BossBattles(ArcadeManager manager)
|
||||
{
|
||||
{
|
||||
super(manager, GameType.BossBattles, new Kit[]
|
||||
{
|
||||
new KitBrute(manager), new KitRanger(manager),
|
||||
@ -51,7 +52,7 @@ public class BossBattles extends TeamGame
|
||||
new KitAssassin(manager),
|
||||
}, new String[]
|
||||
{
|
||||
"Fight some bosses"
|
||||
"Fight some bosses"
|
||||
});
|
||||
|
||||
HungerSet = 20;
|
||||
@ -242,8 +243,8 @@ public class BossBattles extends TeamGame
|
||||
{
|
||||
Location loc = locations.get(i).clone();
|
||||
|
||||
loc.setDirection(UtilAlg.getTrajectory(loc,
|
||||
Manager.GetLobby().GetSpawn()));
|
||||
loc.setDirection(UtilAlg.getTrajectory(loc, Manager.GetLobby()
|
||||
.GetSpawn()));
|
||||
|
||||
Constructor<? extends BossDisplay> constructor = boss
|
||||
.getBossDisplay().getConstructor(BossBattles.class,
|
||||
@ -260,8 +261,8 @@ public class BossBattles extends TeamGame
|
||||
|
||||
_displays.add(bossDisplay);
|
||||
|
||||
System.out.print(
|
||||
"Registered " + bossDisplay.getClass().getSimpleName());
|
||||
System.out.print("Registered "
|
||||
+ bossDisplay.getClass().getSimpleName());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -305,21 +306,13 @@ public class BossBattles extends TeamGame
|
||||
{
|
||||
for (Constructor<?> con : clazz.getConstructors())
|
||||
{
|
||||
if (clazz != SlimeBoss.class)
|
||||
{
|
||||
worldEvent = (WorldEvent) con.newInstance(
|
||||
getArcadeManager().GetDamage(),
|
||||
getArcadeManager().GetBlockRestore(),
|
||||
getArcadeManager().GetCondition(), centerLocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
worldEvent = (WorldEvent) con.newInstance(
|
||||
getArcadeManager().GetDamage(),
|
||||
getArcadeManager().GetBlockRestore(),
|
||||
getArcadeManager().GetCondition(),
|
||||
getArcadeManager().GetProjectile(), centerLocation);
|
||||
}
|
||||
|
||||
worldEvent = (WorldEvent) con.newInstance(getArcadeManager()
|
||||
.GetDisguise(), getArcadeManager().GetProjectile(),
|
||||
getArcadeManager().GetDamage(), getArcadeManager()
|
||||
.GetBlockRestore(), getArcadeManager()
|
||||
.GetCondition(), centerLocation);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -332,8 +325,8 @@ public class BossBattles extends TeamGame
|
||||
|
||||
private void setNewBoss(BattleBoss boss)
|
||||
{
|
||||
_currentBoss = createInstance(boss.getBoss(),
|
||||
new Location(WorldData.World, 0, 6, 0));
|
||||
_currentBoss = createInstance(boss.getBoss(), new Location(
|
||||
WorldData.World, 0, 6, 0));
|
||||
|
||||
_currentBoss.setArcadeGame(true);
|
||||
_currentBoss.setDifficulty(0.6);
|
||||
|
Loading…
Reference in New Issue
Block a user