Merge remote-tracking branch 'remotes/origin/master' into virizion_speed_builder

This commit is contained in:
Virizion 2015-12-03 19:31:24 -05:00
commit c3a564faa7
18 changed files with 335 additions and 187 deletions

View File

@ -33,6 +33,7 @@ import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@ -803,6 +804,20 @@ public class UtilEnt
return null;
}
public static void setAI(LivingEntity entity, boolean ai)
{
if(entity instanceof ArmorStand)
{
((ArmorStand)entity).setGravity(ai);
return;
}
CraftEntity e = (CraftEntity)entity;
if(e.getHandle() instanceof EntityInsentient)
{
((EntityInsentient)e.getHandle()).k(!ai);
}
}
public static boolean inWater(LivingEntity ent)
{

View File

@ -43,6 +43,14 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
if (slot == 26)
slot = 28;
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()
{
public void onClick(Player player, ClickType clickType)
{
getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player));
}
});
}
protected void addMount(Mount<?> mount, int slot)
@ -76,12 +84,5 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
setItem(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), (mount.GetCost(CurrencyType.Coins) < 0 ? "" : "Purchase ") + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()
{
public void onClick(Player player, ClickType clickType)
{
getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player));
}
});
}
}

View File

@ -1,7 +1,7 @@
package mineplex.core.mount;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -13,12 +13,14 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class DragonData
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
public class DragonData extends MountData
{
DragonMount Host;
public EnderDragon Dragon;
public Player Rider;
public Entity TargetEntity = null;
@ -31,9 +33,8 @@ public class DragonData
public DragonData(DragonMount dragonMount, Player rider)
{
Host = dragonMount;
Rider = rider;
super(rider);
Host = dragonMount;
Velocity = rider.getLocation().getDirection().setY(0).normalize();
Pitch = UtilAlg.GetPitch(rider.getLocation().getDirection());
@ -51,25 +52,34 @@ public class DragonData
Chicken = rider.getWorld().spawn(rider.getLocation(), Chicken.class);
Dragon.setPassenger(Chicken);
Chicken.setPassenger(Rider);
Chicken.setPassenger(getOwner());
Bukkit.getServer().getScheduler().runTaskLater(Host.Manager.getPlugin(), new Runnable()
{
public void run()
{
Chicken.setPassenger(Rider);
Chicken.setPassenger(getOwner());
}
}, 10L);
}
public void Move()
{
Rider.eject();
getOwner().eject();
((CraftEnderDragon)Dragon).getHandle().setTargetBlock(GetTarget().getBlockX(), GetTarget().getBlockY(), GetTarget().getBlockZ());
}
public Location GetTarget()
{
return Rider.getLocation().add(Rider.getLocation().getDirection().multiply(40));
return getOwner().getLocation().add(getOwner().getLocation().getDirection().multiply(40));
}
@Override
public List<Entity> getEntityParts()
{
List<Entity> list = new ArrayList<Entity>();
list.add(Dragon);
list.add(Chicken);
return list;
}
}

View File

@ -5,7 +5,6 @@ import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseChicken;
public class DragonMount extends Mount<DragonData>
{

View File

@ -22,7 +22,7 @@ import org.bukkit.entity.Horse.Style;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
public class HorseMount extends Mount<Horse>
public class HorseMount extends Mount<SingleEntityMountData<Horse>>
{
protected Color _color;
protected Style _style;
@ -53,7 +53,7 @@ public class HorseMount extends Mount<Horse>
while (activeIterator.hasNext())
{
Player player = activeIterator.next();
Horse horse = _active.get(player);
Horse horse = _active.get(player).getEntity();
//Invalid (dead)
if (!horse.isValid())
@ -113,15 +113,16 @@ public class HorseMount extends Mount<Horse>
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
//Store
_active.put(player, horse);
SingleEntityMountData<Horse> mount = new SingleEntityMountData<Horse>(player, horse);
_active.put(player, mount);
}
public void Disable(Player player)
{
Horse horse = _active.remove(player);
if (horse != null)
SingleEntityMountData<Horse> mount = _active.remove(player);
if (mount != null)
{
horse.remove();
mount.remove();
//Inform
UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(GetName()) + "."));

View File

@ -5,6 +5,7 @@ import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -18,7 +19,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.shop.item.SalesPackageBase;
public abstract class Mount<T> extends SalesPackageBase implements Listener
public abstract class Mount<T extends MountData> extends SalesPackageBase implements Listener
{
protected HashSet<Player> _owners = new HashSet<Player>();
protected HashMap<Player, T> _active = new HashMap<Player, T>();
@ -51,8 +52,8 @@ public abstract class Mount<T> extends SalesPackageBase implements Listener
return;
}
Manager.setActive(player, this);
EnableCustom(player);
Manager.setActive(player, this);
}
public abstract void EnableCustom(Player player);
@ -97,4 +98,13 @@ public abstract class Mount<T> extends SalesPackageBase implements Listener
{
return _owners.contains(player);
}
public T getMountData(Entity ent)
{
for(T data : GetActive().values())
{
if(data.isPartOfMount(ent)) return data;
}
return null;
}
}

View File

@ -0,0 +1,43 @@
package mineplex.core.mount;
import java.util.List;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public abstract class MountData
{
protected Player _owner;
public MountData(Player player)
{
_owner = player;
}
public boolean isPartOfMount(Entity ent)
{
return getEntityParts().contains(ent);
}
public abstract List<Entity> getEntityParts();
public boolean ownsMount(Player p)
{
return _owner.equals(p);
}
public Player getOwner()
{
return _owner;
}
public void remove()
{
for(Entity e : getEntityParts())
{
e.remove();
}
}
}

View File

@ -3,6 +3,17 @@ package mineplex.core.mount;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.blockrestore.BlockRestore;
@ -22,17 +33,6 @@ import mineplex.core.mount.types.MountTitan;
import mineplex.core.mount.types.MountUndead;
import mineplex.core.mount.types.MountZombie;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class MountManager extends MiniPlugin
{
private CoreClientManager _clientManager;
@ -84,32 +84,30 @@ public class MountManager extends MiniPlugin
}
@EventHandler
public void HorseInteract(PlayerInteractEntityEvent event)
public void mountInteract(PlayerInteractAtEntityEvent event)
{
MountData mount = getMountData(event.getRightClicked());
if(mount == null) return;
if(mount.ownsMount(event.getPlayer())) return;
event.setCancelled(true);
}
@EventHandler
public void mountInteract(PlayerInteractEntityEvent event)
{
if (!(event.getRightClicked() instanceof Horse))
return;
MountData mount = getMountData(event.getRightClicked());
boolean found = false;
for (Mount mount : _playerActiveMountMap.values())
{
if (mount.GetActive().containsValue(event.getRightClicked()))
{
found = true;
break;
}
}
if(mount == null) return;
if (!found)
return;
Player player = event.getPlayer();
Horse horse = (Horse)event.getRightClicked();
if(mount.ownsMount(event.getPlayer())) return;
UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!"));
event.setCancelled(true);
if (horse.getOwner() == null || !horse.getOwner().equals(player))
{
UtilPlayer.message(player, F.main("Mount", "This is not your Mount!"));
event.setCancelled(true);
}
}
@EventHandler
@ -178,16 +176,28 @@ public class MountManager extends MiniPlugin
{
return _disguiseManager;
}
public boolean isMount(Entity ent)
public MountData getMountData(Entity ent)
{
for (Mount<?> mount : _playerActiveMountMap.values())
{
if (mount.GetActive().values().contains(ent))
{
return true;
}
MountData data = mount.getMountData(ent);
if(data != null) return data;
}
return false;
return null;
}
public Mount<?> getMount(Entity ent)
{
for (Mount<?> mount : _playerActiveMountMap.values())
{
if(mount.getMountData(ent) != null) return mount;
}
return null;
}
public boolean isMount(Entity ent)
{
return getMount(ent) != null;
}
}

View File

@ -0,0 +1,35 @@
package mineplex.core.mount;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class SingleEntityMountData<T extends Entity> extends MountData
{
protected T Entity;
public SingleEntityMountData(Player player, T ent)
{
super(player);
Entity = ent;
}
@Override
public List<Entity> getEntityParts()
{
List<Entity> list = new ArrayList<Entity>();
list.add(Entity);
return list;
}
public T getEntity()
{
return Entity;
}
}

View File

@ -1,5 +1,6 @@
package mineplex.core.mount.types;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -18,23 +19,12 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.mount.Mount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftMinecart;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.vehicle.VehicleDamageEvent;
public class MountCart extends Mount<Minecart>
public class MountCart extends Mount<SingleEntityMountData<Minecart>>
{
public MountCart(MountManager manager)
{
@ -56,7 +46,7 @@ public class MountCart extends Mount<Minecart>
//Remove other mounts
Manager.DeregisterAll(player);
Minecart mount = player.getWorld().spawn(player.getLocation().add(0, 2, 0), Minecart.class);
SingleEntityMountData<Minecart> mount = new SingleEntityMountData<Minecart>(player, player.getWorld().spawn(player.getLocation().add(0, 2, 0), Minecart.class));
//Inform
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
@ -67,7 +57,7 @@ public class MountCart extends Mount<Minecart>
public void Disable(Player player)
{
Minecart mount = _active.remove(player);
SingleEntityMountData<Minecart> mount = _active.remove(player);
if (mount != null)
{
mount.remove();
@ -85,14 +75,11 @@ public class MountCart extends Mount<Minecart>
if (event.getRightClicked() == null)
return;
if (!GetActive().containsKey(event.getPlayer()))
return;
SingleEntityMountData<Minecart> mount = GetActive().get(event.getPlayer());
if (!GetActive().get(event.getPlayer()).equals(event.getRightClicked()))
{
UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!"));
return;
}
if(mount == null) return;
if(!mount.ownsMount(event.getPlayer())) return;
event.getPlayer().leaveVehicle();
event.getPlayer().eject();
@ -117,8 +104,10 @@ public class MountCart extends Mount<Minecart>
return;
//Bounce
for (Minecart cart : GetActive().values())
for (SingleEntityMountData<Minecart> cartData : GetActive().values())
{
Minecart cart = cartData.getEntity();
if (cart.getPassenger() == null)
continue;
@ -137,8 +126,10 @@ public class MountCart extends Mount<Minecart>
}
//Collide
for (Minecart cart : GetActive().values())
for (SingleEntityMountData<Minecart> cartData : GetActive().values())
{
Minecart cart = cartData.getEntity();
if (cart.getPassenger() == null)
continue;
@ -150,8 +141,9 @@ public class MountCart extends Mount<Minecart>
if (!Recharge.Instance.usable(player, GetName() + " Collide"))
continue;
for (Minecart other : GetActive().values())
for (SingleEntityMountData<Minecart> otherData : GetActive().values())
{
Minecart other = otherData.getEntity();
if (other.equals(cart))
continue;

View File

@ -9,11 +9,11 @@ import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
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.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -38,10 +38,12 @@ public class MountFrost extends HorseMount
public void Trail(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
for (Horse horse : GetActive().values())
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0.1f, 4,
ViewDist.NORMAL, UtilServer.getPlayers());
for (SingleEntityMountData<Horse> horseData : GetActive().values())
{
Horse horse = horseData.getEntity();
UtilParticle.PlayParticleToAll(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0.1f, 4, ViewDist.NORMAL);
}
}
// @EventHandler

View File

@ -5,19 +5,19 @@ import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Player;
import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguisePig;
import mineplex.core.disguise.disguises.DisguiseSheep;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -45,6 +45,7 @@ public class MountSheep extends HorseMount
Manager.DeregisterAll(player);
Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class);
SingleEntityMountData<Horse> mount = new SingleEntityMountData<Horse>(player, horse);
horse.setOwner(player);
horse.setMaxDomestication(1);
@ -59,7 +60,7 @@ public class MountSheep extends HorseMount
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
//Store
_active.put(player, horse);
_active.put(player, mount);
}
@EventHandler
@ -68,8 +69,10 @@ public class MountSheep extends HorseMount
if (event.getType() != UpdateType.TICK)
return;
for (Horse horse : GetActive().values())
for (SingleEntityMountData<Horse> horseData : GetActive().values())
{
Horse horse = horseData.getEntity();
DisguiseBase base = Manager.getDisguiseManager().getDisguise(horse);
if (base == null || !(base instanceof DisguiseSheep))
continue;

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.Slime;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
@ -18,11 +19,12 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.mount.Mount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class MountSlime extends Mount<Slime>
public class MountSlime extends Mount<SingleEntityMountData<Slime>>
{
public MountSlime(MountManager manager)
{
@ -44,10 +46,10 @@ public class MountSlime extends Mount<Slime>
//Remove other mounts
Manager.DeregisterAll(player);
Slime mount = player.getWorld().spawn(player.getLocation(), Slime.class);
mount.setSize(2);
SingleEntityMountData<Slime> mount = new SingleEntityMountData<Slime>(player, player.getWorld().spawn(player.getLocation(), Slime.class));
mount.getEntity().setSize(2);
mount.setCustomName(player.getName() + "'s " + GetName());
mount.getEntity().setCustomName(player.getName() + "'s " + GetName());
//Inform
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
@ -58,7 +60,7 @@ public class MountSlime extends Mount<Slime>
public void Disable(Player player)
{
Slime mount = _active.remove(player);
SingleEntityMountData<Slime> mount = _active.remove(player);
if (mount != null)
{
mount.remove();
@ -79,11 +81,8 @@ public class MountSlime extends Mount<Slime>
if (!GetActive().containsKey(event.getPlayer()))
return;
if (!GetActive().get(event.getPlayer()).equals(event.getRightClicked()))
{
UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!"));
if(!GetActive().get(event.getPlayer()).ownsMount(event.getPlayer()))
return;
}
event.getPlayer().leaveVehicle();
event.getPlayer().eject();
@ -108,10 +107,15 @@ public class MountSlime extends Mount<Slime>
return;
//Bounce
for (Slime slime : GetActive().values())
for (SingleEntityMountData<Slime> slimeData : GetActive().values())
{
Slime slime = slimeData.getEntity();
if (slime.getPassenger() == null)
{
UtilEnt.setFakeHead(slime, false);
continue;
}
if (!UtilEnt.isGrounded(slime))
continue;
@ -124,14 +128,19 @@ public class MountSlime extends Mount<Slime>
if (!Recharge.Instance.use(player, GetName(), 200, false, false))
continue;
UtilAction.velocity(slime, slime.getPassenger().getLocation().getDirection(), 1, true, 0, 0.4, 1, true);
Vector dir = slime.getPassenger().getLocation().getDirection();
UtilAction.velocity(slime, dir, 1, true, 0, 0.4, 1, true);
UtilEnt.CreatureForceLook(slime, 0, UtilAlg.GetYaw(dir));
slime.getWorld().playSound(slime.getLocation(), Sound.SLIME_WALK, 1f, 0.75f);
}
//Collide
for (Slime slime : GetActive().values())
for (SingleEntityMountData<Slime> slimeData : GetActive().values())
{
Slime slime = slimeData.getEntity();
if (slime.getPassenger() == null)
continue;
@ -143,8 +152,10 @@ public class MountSlime extends Mount<Slime>
if (!Recharge.Instance.usable(player, GetName() + " Collide"))
continue;
for (Slime other : GetActive().values())
for (SingleEntityMountData<Slime> otherSlime : GetActive().values())
{
Slime other = otherSlime.getEntity();
if (other.equals(slime))
continue;

View File

@ -4,21 +4,6 @@ import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Map.Entry;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseSpider;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.EntityLiving;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
@ -32,6 +17,22 @@ import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseSpider;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.EntityLiving;
public class MountSpider extends HorseMount
{
/**
@ -87,7 +88,8 @@ public class MountSpider extends HorseMount
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
//Store
_active.put(player, horse);
SingleEntityMountData<Horse> mount = new SingleEntityMountData<Horse>(player, horse);
_active.put(player, mount);
DisguiseSpider spider = new DisguiseSpider(horse);
spider.setName(player.getName() + "'s Spider Mount");
@ -105,7 +107,7 @@ public class MountSpider extends HorseMount
ArrayList<Horse> used = new ArrayList<Horse>();
for (Player player : GetActive().keySet())
{
Horse horse = GetActive().get(player);
Horse horse = GetActive().get(player).getEntity();
used.add(horse);
@ -126,21 +128,24 @@ public class MountSpider extends HorseMount
if (event.getType() != UpdateType.TICK)
return;
for (Entry<Player, Horse> horse : GetActive().entrySet())
for (Entry<Player, SingleEntityMountData<Horse>> entry : GetActive().entrySet())
{
if (horse.getValue().getPassenger() != horse.getKey())
Player player = entry.getKey();
Horse horse = entry.getValue().getEntity();
if (horse.getPassenger() != player)
continue;
//If player is looking up
if (horse.getKey().getEyeLocation().getPitch() > -45)
if (player.getEyeLocation().getPitch() > -45)
continue;
for (Block block : UtilBlock.getSurrounding(horse.getValue().getLocation().getBlock(), true))
for (Block block : UtilBlock.getSurrounding(horse.getLocation().getBlock(), true))
{
if (UtilBlock.airFoliage(block) || block.isLiquid())
continue;
UtilAction.velocity(horse.getValue(), new Vector(horse.getValue().getVelocity().getX(), 0.2, horse.getValue().getVelocity().getZ()));
UtilAction.velocity(horse, new Vector(horse.getVelocity().getX(), 0.2, horse.getVelocity().getZ()));
continue;
}
}
@ -191,7 +196,7 @@ public class MountSpider extends HorseMount
for (Player player : GetActive().keySet())
{
final Horse horse = GetActive().get(player);
final Horse horse = GetActive().get(player).getEntity();
if (horse.getPassenger() != player)
continue;

View File

@ -1,27 +1,19 @@
package mineplex.core.mount.types;
import java.util.HashMap;
import org.bukkit.Material;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.Mount;
import mineplex.core.mount.MountManager;
import mineplex.core.updater.UpdateType;
@ -85,11 +77,20 @@ public class MountTitan extends Mount<MountTitanData>
}
@EventHandler
public void interactMount(PlayerInteractEntityEvent event)
public void interactMount(PlayerInteractAtEntityEvent event)
{
if (event.getRightClicked() == null)
return;
for(MountTitanData mount : GetActive().values())
{
if(mount.isPartOfMount(event.getRightClicked()))
{
event.setCancelled(true);
if(event.getRightClicked().getType() == EntityType.ARMOR_STAND) return;
}
}
if (!GetActive().containsKey(event.getPlayer()))
return;
@ -123,7 +124,7 @@ public class MountTitan extends Mount<MountTitanData>
{
for (MountTitanData data : _active.values())
{
if (data.ownsEntity(event.getEntity()))
if (data.isPartOfMount(event.getEntity()))
event.setCancelled(true);
}
}

View File

@ -3,11 +3,7 @@
package mineplex.core.mount.types;
import java.util.ArrayList;
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 java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
@ -20,9 +16,13 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
public class MountTitanData
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.mount.MountData;
public class MountTitanData extends MountData
{
private String _owner;
private Slime _head;
@ -30,7 +30,7 @@ public class MountTitanData
public MountTitanData(Player player, String name)
{
_owner = player.getName();
super(player);
Location loc = player.getLocation();
loc.setPitch(0);
@ -72,7 +72,11 @@ public class MountTitanData
{
//Head
if (_head.getPassenger() != null)
_head.setVelocity(_head.getPassenger().getLocation().getDirection().multiply(0.8).add(new Vector(0,0.2,0)));
{
Vector dir = _head.getPassenger().getLocation().getDirection().multiply(0.8).add(new Vector(0,0.2,0));
_head.setVelocity(dir);
UtilEnt.CreatureLook(_head, dir);
}
Location infront = _head.getLocation().add(0, -1.5, 0);
@ -133,14 +137,13 @@ public class MountTitanData
for (ArmorStand stand : _nodes)
stand.remove();
}
public boolean ownsMount(Player player)
{
return _owner.equals(player.getName());
}
public boolean ownsEntity(Entity ent)
@Override
public List<Entity> getEntityParts()
{
return (_head.equals(ent) || _nodes.contains(ent));
List<Entity> entities = new ArrayList<Entity>();
entities.addAll(_nodes);
entities.add(_head);
return entities;
}
}

View File

@ -1,15 +1,5 @@
package mineplex.core.mount.types;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Material;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color;
@ -17,6 +7,16 @@ import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class MountUndead extends HorseMount
{
public MountUndead(MountManager manager)
@ -37,16 +37,20 @@ public class MountUndead extends HorseMount
public void Trail(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
for (Horse horse : GetActive().values())
UtilParticle.PlayParticle(ParticleType.FLAME, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0, 2,
ViewDist.NORMAL, UtilServer.getPlayers());
for (SingleEntityMountData<Horse> horseData : GetActive().values())
{
Horse horse = horseData.getEntity();
UtilParticle.PlayParticleToAll(ParticleType.FLAME, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0, 2,ViewDist.NORMAL);
}
if (event.getType() == UpdateType.FAST)
for (Horse horse : GetActive().values())
UtilParticle.PlayParticle(ParticleType.LAVA, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
for (SingleEntityMountData<Horse> horseData : GetActive().values())
{
Horse horse = horseData.getEntity();
UtilParticle.PlayParticleToAll(ParticleType.LAVA, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0, 1, ViewDist.NORMAL);
}
}
}

View File

@ -14,7 +14,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wither;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
@ -24,9 +24,9 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.event.StackerEvent;
import mineplex.core.gadget.gadgets.MorphBlock;
import mineplex.core.gadget.types.GadgetType;
@ -54,7 +54,7 @@ public class StackerManager extends MiniPlugin implements IThrown
}
@EventHandler
public void GrabEntity(PlayerInteractEntityEvent event)
public void GrabEntity(PlayerInteractAtEntityEvent event)
{
if (event.isCancelled())
return;
@ -62,7 +62,10 @@ public class StackerManager extends MiniPlugin implements IThrown
Entity stackee = event.getRightClicked();
if (stackee == null)
return;
if(Manager.GetMount().isMount(stackee))
return;
if (!(stackee instanceof LivingEntity))
return;