Adds mount spider and fixes a BH bug.
This commit is contained in:
parent
8fb82507e1
commit
e864e0867a
@ -3,17 +3,6 @@ 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.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;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
@ -23,7 +12,23 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.mount.types.*;
|
||||
import mineplex.core.mount.types.MountCart;
|
||||
import mineplex.core.mount.types.MountDragon;
|
||||
import mineplex.core.mount.types.MountFrost;
|
||||
import mineplex.core.mount.types.MountMule;
|
||||
import mineplex.core.mount.types.MountSlime;
|
||||
import mineplex.core.mount.types.MountSpider;
|
||||
import mineplex.core.mount.types.MountUndead;
|
||||
|
||||
import org.bukkit.Material;
|
||||
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
|
||||
{
|
||||
@ -57,6 +62,7 @@ public class MountManager extends MiniPlugin
|
||||
_types.add(new MountDragon(this));
|
||||
_types.add(new MountSlime(this));
|
||||
_types.add(new MountCart(this));
|
||||
_types.add(new MountSpider(this));
|
||||
//_types.add(new MountSheep(this));
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,226 @@
|
||||
package mineplex.core.mount.types;
|
||||
|
||||
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.DisguiseBase;
|
||||
import mineplex.core.disguise.disguises.DisguiseBat;
|
||||
import mineplex.core.disguise.disguises.DisguiseChicken;
|
||||
import mineplex.core.disguise.disguises.DisguiseEnderman;
|
||||
import mineplex.core.disguise.disguises.DisguiseSpider;
|
||||
import mineplex.core.disguise.disguises.DisguiseWither;
|
||||
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_7_R4.EntityLiving;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Horse.Color;
|
||||
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.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class MountSpider extends HorseMount
|
||||
{
|
||||
/**
|
||||
* @author Mysticate
|
||||
*/
|
||||
|
||||
public MountSpider(MountManager manager)
|
||||
{
|
||||
super(manager, "Spider Mount", new String[]
|
||||
{
|
||||
C.cWhite + "Why ride a horse when you can",
|
||||
C.cWhite + "ride a cute and cuddly spider!",
|
||||
C.cBlack,
|
||||
C.cYellow + "Look Up" + C.cGray + " to use " + C.cGreen + "Wall Climb",
|
||||
C.cYellow + "Jump" + C.cGray + " to use " + C.cGreen + "Jump",
|
||||
C.cYellow + "Double Jump" + C.cGray + " to use " + C.cGreen + "Leap",
|
||||
C.cBlack,
|
||||
C.cPurple + "Only buyable during " + C.Line + "Halloween 2015",
|
||||
C.cPurple + "Purchase at " + C.Line + "www.mineplex.com/shop"
|
||||
}, Material.WEB, (byte) 0, -1, Color.BLACK, Style.NONE, Variant.HORSE, 2.0, Material.AIR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void EnableCustom(Player player)
|
||||
{
|
||||
player.leaveVehicle();
|
||||
player.eject();
|
||||
|
||||
//Remove other mounts
|
||||
Manager.DeregisterAll(player);
|
||||
|
||||
Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class);
|
||||
horse.setAdult();
|
||||
horse.setAgeLock(true);
|
||||
horse.setColor(_color);
|
||||
horse.setStyle(_style);
|
||||
horse.setVariant(_variant);
|
||||
horse.setOwner(player);
|
||||
horse.setMaxDomestication(1);
|
||||
horse.setJumpStrength(_jump);
|
||||
horse.getInventory().setSaddle(new ItemStack(Material.SADDLE));
|
||||
|
||||
if (horse.getVariant() == Variant.MULE)
|
||||
horse.setCarryingChest(true);
|
||||
|
||||
if (_armor != null)
|
||||
horse.getInventory().setArmor(new ItemStack(_armor));
|
||||
|
||||
horse.setCustomName(player.getName() + "'s " + GetName());
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
|
||||
|
||||
//Store
|
||||
_active.put(player, horse);
|
||||
|
||||
DisguiseSpider spider = new DisguiseSpider(horse);
|
||||
spider.setName(player.getName() + "'s Spider Mount");
|
||||
Manager.getDisguiseManager().disguise(spider);
|
||||
|
||||
UtilEnt.silence(horse, true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void sounds(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTEST)
|
||||
return;
|
||||
|
||||
ArrayList<Horse> used = new ArrayList<Horse>();
|
||||
for (Player player : GetActive().keySet())
|
||||
{
|
||||
Horse horse = GetActive().get(player);
|
||||
|
||||
used.add(horse);
|
||||
|
||||
if (!Recharge.Instance.use(player, "Spider Mount Sounds", (1000 * UtilMath.r(3)) + 500, false, false))
|
||||
continue;
|
||||
|
||||
//Moving
|
||||
if (horse.getVelocity().length() != 0 && UtilEnt.isGrounded(horse))
|
||||
{
|
||||
horse.getWorld().playSound(horse.getLocation(), Sound.SPIDER_WALK, .4F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void wallClimb(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
for (Entry<Player, Horse> horse : GetActive().entrySet())
|
||||
{
|
||||
//If player is looking up
|
||||
if (horse.getKey().getEyeLocation().getPitch() > -45)
|
||||
continue;
|
||||
|
||||
for (Block block : UtilBlock.getSurrounding(horse.getValue().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()));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void doubleJump(PlayerToggleFlightEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
return;
|
||||
|
||||
if (!GetActive().containsKey(player))
|
||||
return;
|
||||
|
||||
if (GetActive().get(player).getPassenger() != event.getPlayer())
|
||||
return;
|
||||
|
||||
//Chicken Cancel
|
||||
DisguiseBase disguise = Manager.getDisguiseManager().getDisguise(player);
|
||||
if (disguise != null && ((disguise instanceof DisguiseChicken && !((DisguiseChicken)disguise).isBaby()) || disguise instanceof DisguiseBat || disguise instanceof DisguiseEnderman || disguise instanceof DisguiseWither))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
player.setFlying(false);
|
||||
|
||||
//Disable Flight
|
||||
player.setAllowFlight(false);
|
||||
|
||||
Vector direction = event.getPlayer().getLocation().getDirection().clone();
|
||||
direction.normalize().setY(0); //Make level
|
||||
direction.multiply(1.4).setY(.6);
|
||||
|
||||
//Velocity
|
||||
UtilAction.velocity(GetActive().get(event.getPlayer()), direction);
|
||||
|
||||
//Sound
|
||||
player.playSound(player.getLocation(), Sound.SPIDER_IDLE, .4F, 1.0F);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void jump(UpdateEvent event)
|
||||
{
|
||||
for (Player player : GetActive().keySet())
|
||||
{
|
||||
Horse horse = GetActive().get(player);
|
||||
|
||||
if (!UtilEnt.isGrounded(horse))
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
Field jump = EntityLiving.class.getField("bc");
|
||||
final boolean accessable = jump.isAccessible();
|
||||
|
||||
jump.setAccessible(true);
|
||||
boolean isJumping = jump.getBoolean(player);
|
||||
|
||||
jump.setAccessible(accessable);
|
||||
|
||||
if (!isJumping)
|
||||
continue;
|
||||
|
||||
if (!Recharge.Instance.use(player, "Spider Mount Jump", 100, false, false))
|
||||
continue;
|
||||
|
||||
//Not jumping anymore
|
||||
((CraftPlayer) player).getHandle().f(false);
|
||||
|
||||
UtilAction.velocity(horse, new Vector(horse.getVelocity().getX(), 0.3, horse.getVelocity().getZ()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -84,7 +84,8 @@ public class BlockForm extends Form
|
||||
// Player > Chicken
|
||||
DisguiseChicken disguise = new DisguiseChicken(Player);
|
||||
disguise.setBaby();
|
||||
disguise.setInvisible(true);
|
||||
|
||||
// disguise.setInvisible(true);
|
||||
disguise.setSoundDisguise(new DisguiseCat(Player));
|
||||
Host.Manager.GetDisguise().disguise(disguise);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user