Internal:

- Removed Win room test command
 - Fixed spelling error in MountSpider
 - Changed MountChicken so it can now jump
 - Still working on the Sleigh morph
 - Added Wind Up Suit for testing
 - Removed unused code from MountSpider

External:
 - Added Sleigh Morph (Still need some work on it)
This commit is contained in:
LCastr0 2016-10-19 18:44:57 -02:00
parent 8ab61b2b06
commit 225f5c6b7c
18 changed files with 957 additions and 179 deletions

View File

@ -5,12 +5,17 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.EntityTypes;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NBTTagInt;
import net.minecraft.server.v1_8_R3.TileEntity;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;
@ -23,12 +28,6 @@ import com.java.sk89q.jnbt.Tag;
import mineplex.core.common.block.DataLocationMap;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.EntityTypes;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.NBTTagInt;
import net.minecraft.server.v1_8_R3.TileEntity;
import net.minecraft.server.v1_8_R3.WorldServer;
public class Schematic
{

View File

@ -4,6 +4,13 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta;
import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
@ -28,12 +35,6 @@ import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.SalesPackageProcessor;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta;
import org.bukkit.inventory.meta.ItemMeta;
public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
@ -145,6 +146,11 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Haunted Chests");
}
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -14)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Power Play Club");
}
//Rank Unlocks
else if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -10)

View File

@ -4,6 +4,10 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
@ -17,9 +21,6 @@ import mineplex.core.mount.Mount;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
@ -99,8 +100,14 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -9)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Halloween Chests");
itemLore.add(C.cBlue + "Found in Haunted Chests");
}
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -14)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Power Play Club");
}
//Rank Unlocks
else if (mount.getCost(GlobalCurrency.TREASURE_SHARD) == -10)
{

View File

@ -4,6 +4,19 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.ChatMessage;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.Items;
import net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow;
import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
@ -24,12 +37,6 @@ import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.AnvilContainer;
import mineplex.core.shop.page.ShopPageBase;
import net.minecraft.server.v1_8_R3.*;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
@ -98,7 +105,12 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -9)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Halloween Chests");
itemLore.add(C.cBlue + "Found in Haunted Chests");
}
else if (pet.getCost(GlobalCurrency.TREASURE_SHARD) == -14)
{
itemLore.add(C.cBlack);
itemLore.add(C.cBlue + "Found in Power Play Club");
}
//Rank Unlocks

View File

@ -37,8 +37,8 @@ import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.commands.AmmoCommand;
import mineplex.core.gadget.commands.LockCosmeticsCommand;
import mineplex.core.gadget.commands.ReindeerTestCommand;
import mineplex.core.gadget.commands.UnlockCosmeticsCommand;
import mineplex.core.gadget.commands.WinRoomTestCommand;
import mineplex.core.gadget.event.GadgetChangeEvent;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.gadget.event.GadgetEnableEvent;
@ -117,10 +117,12 @@ import mineplex.core.gadget.gadgets.morph.MorphEnderman;
import mineplex.core.gadget.gadgets.morph.MorphGrimReaper;
import mineplex.core.gadget.gadgets.morph.MorphPig;
import mineplex.core.gadget.gadgets.morph.MorphPumpkinKing;
import mineplex.core.gadget.gadgets.morph.MorphSleigh;
import mineplex.core.gadget.gadgets.morph.MorphSlime;
import mineplex.core.gadget.gadgets.morph.MorphSnowman;
import mineplex.core.gadget.gadgets.morph.MorphSquid;
import mineplex.core.gadget.gadgets.morph.MorphTitan;
import mineplex.core.gadget.gadgets.morph.MorphTurkey;
import mineplex.core.gadget.gadgets.morph.MorphUncleSam;
import mineplex.core.gadget.gadgets.morph.MorphVillager;
import mineplex.core.gadget.gadgets.morph.MorphWitch;
@ -137,6 +139,10 @@ import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitChestplate;
import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitHelmet;
import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitLeggings;
import mineplex.core.gadget.gadgets.outfit.windupsuit.OutfitWindUpSuitBoosterManager;
import mineplex.core.gadget.gadgets.outfit.windupsuit.OutfitWindUpSuitBoots;
import mineplex.core.gadget.gadgets.outfit.windupsuit.OutfitWindUpSuitChestplate;
import mineplex.core.gadget.gadgets.outfit.windupsuit.OutfitWindUpSuitHelmet;
import mineplex.core.gadget.gadgets.outfit.windupsuit.OutfitWindUpSuitLeggings;
import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes;
import mineplex.core.gadget.gadgets.particle.ParticleFairy;
import mineplex.core.gadget.gadgets.particle.ParticleFireRings;
@ -182,6 +188,7 @@ import mineplex.core.gadget.set.SetVampire;
import mineplex.core.gadget.set.SetWisdom;
import mineplex.core.gadget.set.suits.SetRaveSuit;
import mineplex.core.gadget.set.suits.SetSpaceSuit;
import mineplex.core.gadget.set.suits.SetWindUpSuit;
import mineplex.core.gadget.types.ArrowEffectGadget;
import mineplex.core.gadget.types.DeathEffectGadget;
import mineplex.core.gadget.types.DoubleJumpEffectGadget;
@ -276,7 +283,7 @@ public class GadgetManager extends MiniPlugin
addCommand(new UnlockCosmeticsCommand(this));
addCommand(new LockCosmeticsCommand(this));
addCommand(new AmmoCommand(this));
addCommand(new WinRoomTestCommand(this));
addCommand(new ReindeerTestCommand(this));
}
private void createSets()
@ -289,7 +296,7 @@ public class GadgetManager extends MiniPlugin
//Costumes
addSet(new SetRaveSuit(this));
addSet(new SetSpaceSuit(this));
//addSet(new SetWindUpSuit(this));
addSet(new SetWindUpSuit(this));
addSet(new SetParty(this));
addSet(new SetCupidsLove(this));
addSet(new SetEmerald(this));
@ -335,10 +342,10 @@ public class GadgetManager extends MiniPlugin
addGadget(new OutfitSpaceSuitLeggings(this));
addGadget(new OutfitSpaceSuitBoots(this));
/*addGadget(new OutfitWindUpSuitHelmet(this));
addGadget(new OutfitWindUpSuitHelmet(this));
addGadget(new OutfitWindUpSuitChestplate(this));
addGadget(new OutfitWindUpSuitLeggings(this));
addGadget(new OutfitWindUpSuitBoots(this));*/
addGadget(new OutfitWindUpSuitBoots(this));
addGadget(new OutfitTeam(this, "Team Helmet", -1, ArmorSlot.Helmet, Material.LEATHER_HELMET, (byte)0));
addGadget(new OutfitTeam(this, "Team Shirt", -1, ArmorSlot.Chest, Material.LEATHER_CHESTPLATE, (byte)0));
@ -367,6 +374,8 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphGrimReaper(this));
// Not being added in this update!
//addGadget(new MorphMetalMan(this));
addGadget(new MorphTurkey(this));
addGadget(new MorphSleigh(this));
// Particles
addGadget(new ParticleFoot(this));

View File

@ -0,0 +1,85 @@
package mineplex.core.gadget.commands;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilServer;
import mineplex.core.gadget.GadgetManager;
public class ReindeerTestCommand extends CommandBase<GadgetManager>
{
private GadgetManager _plugin;
private Horse _horse;
private ArmorStand _armorStand;
public ReindeerTestCommand(GadgetManager plugin)
{
super(plugin, Rank.JNR_DEV, "reindeer");
_plugin = plugin;
}
@Override
public void Execute(Player caller, String[] args)
{
if (_horse == null)
{
Location testHorse = new Location(caller.getWorld(), 8.5, 71, 0.5, 0, 0);
testHorse.setYaw(180);
Horse horse = testHorse.getWorld().spawn(testHorse, Horse.class);
horse.setVariant(Horse.Variant.HORSE);
horse.setColor(Horse.Color.BROWN);
horse.setStyle(Horse.Style.NONE);
UtilEnt.Vegetate(horse, true);
UtilEnt.ghost(horse, true, false);
/**
* South
* .4 1 .6
* .2 1 .7
* 0 4 0
* 0 2 0
*
* North
*/
Location hornALoc = horse.getLocation().clone().add(-.3, 1, -.5);
Location hornBLoc = horse.getLocation().clone().add(-.25, 1, -.6);
ArmorStand hornA = hornALoc.getWorld().spawn(hornALoc, ArmorStand.class);
hornA.setVisible(false);
hornA.setGravity(false);
hornA.getEquipment().setItemInHand(new ItemStack(Material.DEAD_BUSH));
hornA.setRightArmPose(new EulerAngle(0, 4, 0));
ArmorStand hornB = hornBLoc.getWorld().spawn(hornBLoc, ArmorStand.class);
hornB.setVisible(false);
hornB.setGravity(false);
hornB.getEquipment().setItemInHand(new ItemStack(Material.DEAD_BUSH));
hornB.setRightArmPose(new EulerAngle(0, 2, 0));
_horse = horse;
Bukkit.getScheduler().scheduleSyncRepeatingTask(UtilServer.getPlugin(), new Runnable()
{
@Override
public void run()
{
Location location = _horse.getLocation();
location.setYaw(180);
_horse.teleport(location);
}
}, 1l, 1l);
}
}
}

View File

@ -1,72 +0,0 @@
package mineplex.core.gadget.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.wineffect.*;
import mineplex.core.gadget.types.WinEffectGadget;
import org.bukkit.entity.Player;
public class WinRoomTestCommand extends CommandBase<GadgetManager>
{
private GadgetManager _manager;
public WinRoomTestCommand(GadgetManager manager)
{
super(manager, Rank.JNR_DEV, "winroomtest");
_manager = manager;
}
@Override
public void Execute(Player player, String[] args)
{
if (args.length < 1 || args.length > 2)
{
UtilPlayer.message(player, F.main("Win Rooms", "Usage: /winroomtest <room name> [play]"));
return;
}
boolean play = false;
if (args.length == 2)
{
if (args[1].equalsIgnoreCase("true"))
{
play = true;
}
}
loadWinRoom(args[0], player, play);
}
private void loadWinRoom(String roomName, Player player, boolean play)
{
List<String> names = Arrays.asList("BabyChicken", "DragonRider", "Fireworks", "Flames", "Halloween", "LavaTrap",
"LightningStrike", "MrPunchMan", "Podium", "RiseOfTheElderGuardian", "SnowTrails");
List<Class> winClasses = Arrays.asList(WinEffectBabyChicken.class, WinEffectDragonRider.class,
WinEffectFireworks.class, WinEffectFlames.class, WinEffectHalloween.class, WinEffectLavaTrap.class,
WinEffectLightningStrike.class, WinEffectMrPunchMan.class, WinEffectPodium.class,
WinEffectRiseOfTheElderGuardian.class, WinEffectSnowTrails.class);
if (names.contains(roomName))
{
int index = names.indexOf(roomName);
WinEffectGadget gadget = (WinEffectGadget) _manager.getGadget(winClasses.get(index));
gadget.setup(player, new ArrayList<>(), new ArrayList<>(), player.getLocation().clone().add(100, 0, 100));
gadget.buildWinnerRoom();
gadget.teleport();
if (play)
{
gadget.runPlay();
}
}
else
{
UtilPlayer.message(player, F.main("Win Rooms", "Wrong room name!"));
}
}
}

View File

@ -37,9 +37,12 @@ public class MorphMetalMan extends MorphGadget
public MorphMetalMan(GadgetManager manager)
{
super(manager, "Metal Man Morph", UtilText.splitLinesToArray(new String[]{C.cGray + "This powerful suit forged of metal makes the wearer strong enough to even battle the gods",
"", C.cWhite + "Left-click to shoot laser beam"}, LineFormat.LORE),
0, Material.IRON_INGOT, (byte) 0);
super(manager, "Metal Man Morph", UtilText.splitLinesToArray(new String[]{
C.cGray + "This powerful suit forged of metal makes the wearer strong enough to even battle the gods",
"",
C.cWhite + "Left-click to shoot laser beam"
}, LineFormat.LORE),
-14, Material.IRON_INGOT, (byte) 0);
}
@Override

View File

@ -0,0 +1,218 @@
package mineplex.core.gadget.gadgets.morph;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import mineplex.core.common.block.schematic.Schematic;
import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.morph.managers.sleigh.Sleigh;
import mineplex.core.gadget.gadgets.morph.managers.sleigh.SleighPosition;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class MorphSleigh extends MorphGadget
{
// TODO JAVADOCS + LIMIT AMOUNT OF SLEIGHS
public enum SleighDirection
{
NORTH("SleighMorphNorth.schematic", 0.5, 4.5),
SOUTH("SleighMorphSouth.schematic", 0.5, 1.5),
EAST("SleighMorphEast.schematic", 1.5, 1.5),
WEST("SleighMorphWest.schematic", 4.5, 1.5);
private String _schematic;
private double _fixedX;
private double _fixedZ;
SleighDirection(String schematic, double fixedX, double fixedZ)
{
_schematic = schematic;
_fixedX = fixedX;
_fixedZ = fixedZ;
}
public String getSchematic()
{
return _schematic;
}
public double getFixedX()
{
return _fixedX;
}
public double getFixedZ()
{
return _fixedZ;
}
}
private Map<Player, Sleigh> _sleighs = new HashMap<>();
private Map<SleighDirection, Schematic> _schematics = new HashMap<>();
private List<SleighPosition> _positions = new ArrayList<>();
private Long _rightClickStart = null;
public MorphSleigh(GadgetManager manager)
{
super(manager, "Sleigh Morph", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE), -14, Material.STAINED_CLAY, (byte) 14);
// Loads sleigh schematics
for (SleighDirection sleighDirection : SleighDirection.values())
{
try
{
Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/" + sleighDirection.getSchematic()));
_schematics.put(sleighDirection, schematic);
} catch (IOException e)
{
e.printStackTrace();
}
}
buildPositions();
}
@Override
public void enableCustom(Player player, boolean message)
{
applyArmor(player, message);
// TODO DISGUISE
}
@Override
public void disableCustom(Player player, boolean message)
{
removeArmor(player);
// TODO UNDISGUISE
if (_sleighs.containsKey(player))
{
_sleighs.get(player).stopEffect();
_sleighs.remove(player);
}
}
@EventHandler
public void activateSleigh(PlayerInteractEvent event)
{
if (!isActive(event.getPlayer()))
return;
if (!UtilEvent.isAction(event, UtilEvent.ActionType.L))
return;
Player player = event.getPlayer();
if (player.getItemInHand().getType() != Material.AIR)
return;
//if (!Recharge.Instance.use(player, getName(), 150000, true, false, "Cosmetics"))
//return;
List<SleighPosition> freePositions = _positions.stream().filter(position -> !position.isUsed()).collect(Collectors.toList());
if (freePositions.size() == 0)
{
UtilPlayer.message(player, F.main("Sleigh Ride", "There are too many sleighs in the sky right now! Please wait a minute and try again!"));
return;
}
int randomPosition = UtilMath.random.nextInt(freePositions.size());
SleighPosition position = freePositions.get(randomPosition);
position.setUsed(true);
SleighDirection direction = position.getDirection();
Schematic schematic = _schematics.get(direction);
if (schematic == null)
{
try
{
schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/SleighMorph.schematic"));
Location fixYaw = player.getLocation().clone();
fixYaw.setYaw(90);
player.teleport(fixYaw);
}
catch (IOException e)
{
e.printStackTrace();
}
}
Sleigh sleigh = new Sleigh(player, schematic, position);
sleigh.startEffect();
_sleighs.put(player, sleigh);
}
@EventHandler
public void onLeaveVehicle(VehicleExitEvent event)
{
if (event.getExited() instanceof Player)
{
Player player = (Player) event.getExited();
if (isActive(player))
{
event.setCancelled(true);
}
}
}
private void buildPositions()
{
_positions.add(new SleighPosition(-11, 143, -30, SleighDirection.SOUTH, -9.5, 145.5, -28.5));
_positions.add(new SleighPosition(57, 109, -150, SleighDirection.SOUTH, 58.5, 111.5, -148.5));
_positions.add(new SleighPosition(141, 101, 80, SleighDirection.NORTH, 142.5, 103.5, 84.5));
_positions.add(new SleighPosition(-12, 88, 85, SleighDirection.NORTH, -10.5, 90.5, 89.5));
_positions.add(new SleighPosition(-95, 90, 70, SleighDirection.NORTH, -93.5, 92.5, 74.5));
_positions.add(new SleighPosition(-105, 115, -80, SleighDirection.EAST, -103.5, 117.5, -78.5));
_positions.add(new SleighPosition(-135, 97, -8, SleighDirection.EAST, -133.5, 99.5, -6.5));
_positions.add(new SleighPosition(-45, 97, 15, SleighDirection.EAST, -43.5, 99.5, 16.5));
_positions.add(new SleighPosition(136, 116, 85, SleighDirection.WEST, 140.5, 118.5, 86.5));
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() == UpdateType.FASTER)
{
_sleighs.values().forEach(Sleigh::playSound);
}
if (event.getType() != UpdateType.TICK)
return;
Iterator<Map.Entry<Player, Sleigh>> iterator = _sleighs.entrySet().iterator();
while (iterator.hasNext())
{
Map.Entry<Player, Sleigh> entry = iterator.next();
Sleigh sleigh = entry.getValue();
if (!sleigh.update())
{
iterator.remove();
}
}
}
}

View File

@ -43,7 +43,7 @@ public class MorphSquid extends MorphGadget implements IThrown
C.cWhite + "Swim to enable Fast Swimming",
C.cWhite + "Sneak to shoot a fish above you"
}, LineFormat.LORE),
0, Material.INK_SACK, (byte) 0);
-14, Material.INK_SACK, (byte) 0);
}
@Override

View File

@ -28,7 +28,10 @@ public class MorphWitch extends MorphGadget
public MorphWitch(GadgetManager manager)
{
super(manager, "Witch Morph", UtilText.splitLinesToArray(new String[]{C.cWhite + "Press sneak to summon your trusty bat and start brewing"}, LineFormat.LORE), 0, Material.SKULL_ITEM, (byte) 3);
super(manager, "Witch Morph", UtilText.splitLinesToArray(new String[]{
C.cWhite + "Press sneak to summon your trusty bat and start brewing"
}, LineFormat.LORE),
-14, Material.SKULL_ITEM, (byte) 3);
}
@Override

View File

@ -0,0 +1,161 @@
package mineplex.core.gadget.gadgets.morph.managers.sleigh;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import mineplex.core.common.block.schematic.Schematic;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.gadget.gadgets.morph.MorphSleigh;
public class Sleigh
{
private Map<Location, Material> _oldBlockMaterials = new HashMap<>();
private Map<Location, Byte> _oldBlockDatas = new HashMap<>();
private Player _player;
private Location _originalLocation;
private Schematic _schematic;
private SleighPosition _sleighPosition;
private Arrow _arrow;
private float _yaw;
private int _moves = 0;
public Sleigh(Player player, Schematic schematic, SleighPosition sleighPosition)
{
_player = player;
_schematic = schematic;
_sleighPosition = sleighPosition;
_yaw = (sleighPosition.getDirection() == MorphSleigh.SleighDirection.SOUTH) ? 0f :
(sleighPosition.getDirection() == MorphSleigh.SleighDirection.NORTH) ? 180f :
(sleighPosition.getDirection() == MorphSleigh.SleighDirection.WEST) ? 90f : -90f;
}
public void startEffect()
{
_originalLocation = _player.getLocation().clone();
Location origin = new Location(_originalLocation.getWorld(), _sleighPosition.getX(),
_sleighPosition.getY(), _sleighPosition.getZ());
try
{
pasteSchematic(origin, 0, 0);
} catch (IOException e)
{
e.printStackTrace();
}
}
public void stopEffect()
{
restoreBlocks();
_arrow.remove();
_player.teleport(_originalLocation.clone().add(0, 5, 0));
_sleighPosition.setUsed(false);
}
private void pasteSchematic(Location origin, int playerX, int playerZ) throws IOException
{
restoreBlocks();
short width = _schematic.getWidth();
short height = _schematic.getHeight();
short length = _schematic.getLength();
for (short x = 0; x < width; x++)
{
for (short y = 0; y < height; y++)
{
for (short z = 0; z < length; z++)
{
Location location = origin.clone().add(x, y, z);
_oldBlockMaterials.put(location, location.getBlock().getType());
_oldBlockDatas.put(location, location.getBlock().getData());
}
}
}
_schematic.paste(origin);
Location playerLoc = new Location(_originalLocation.getWorld(), _sleighPosition.getPlayerX() + playerX,
_sleighPosition.getPlayerY(), _sleighPosition.getPlayerZ() + playerZ);
// Spawns arrow so it looks like player is sitting on the sleigh
if (_arrow != null)
{
_arrow.remove();
}
_arrow = playerLoc.getWorld().spawn(playerLoc, Arrow.class);
UtilEnt.ghost(_arrow, true, true);
playerLoc.setYaw(_yaw);
playerLoc.setPitch(0.0f);
_player.teleport(playerLoc);
_arrow.setPassenger(_player);
}
public boolean update()
{
_moves++;
int x = 0, z = 0;
switch (_sleighPosition.getDirection())
{
case NORTH:
z = -1 * _moves;
break;
case SOUTH:
z = _moves;
break;
case WEST:
x = -1 * _moves;
break;
case EAST:
x = _moves;
}
Location newOrigin = new Location(_originalLocation.getWorld(), _sleighPosition.getX() + x,
_sleighPosition.getY(), _sleighPosition.getZ() + z);
restoreBlocks();
UtilParticle.PlayParticle(UtilParticle.ParticleType.SNOW_SHOVEL, _player.getLocation(), 0f, 0f, 0f, 0.6f, 100,
UtilParticle.ViewDist.LONGER, UtilServer.getPlayers());
try
{
pasteSchematic(newOrigin, x, z);
} catch (IOException e)
{
e.printStackTrace();
}
if (_moves >= 20 * 3)
{
stopEffect();
return false;
}
return true;
}
public void playSound()
{
_player.playSound(_player.getLocation(), Sound.ORB_PICKUP, 1f, 1f);
}
private void restoreBlocks()
{
for (Map.Entry<Location, Material> entry : _oldBlockMaterials.entrySet())
{
Location location = entry.getKey();
Material material = entry.getValue();
byte data = 0;
if (_oldBlockDatas.containsKey(location))
{
data = _oldBlockDatas.get(location);
}
location.getBlock().setType(material);
location.getBlock().setData(data);
}
_oldBlockMaterials.clear();
_oldBlockDatas.clear();
}
}

View File

@ -0,0 +1,53 @@
package mineplex.core.gadget.gadgets.morph.managers.sleigh;
import org.bukkit.Material;
public class SleighBlock
{
private int _x, _y, _z;
private Material _material;
private byte _data;
private boolean _middle;
public SleighBlock(int x, int y, int z, Material material, int data, boolean middle)
{
_x = x;
_y = y;
_z = z;
_material = material;
_data = (byte) data;
_middle = middle;
}
public int getX()
{
return _x;
}
public int getY()
{
return _y;
}
public int getZ()
{
return _z;
}
public Material getMaterial()
{
return _material;
}
public byte getData()
{
return _data;
}
public boolean isMiddle()
{
return _middle;
}
}

View File

@ -0,0 +1,73 @@
package mineplex.core.gadget.gadgets.morph.managers.sleigh;
import mineplex.core.gadget.gadgets.morph.MorphSleigh;
public class SleighPosition
{
private int _x;
private int _y;
private int _z;
private MorphSleigh.SleighDirection _direction;
private double _playerX;
private double _playerY;
private double _playerZ;
private boolean _used;
public SleighPosition(int x, int y, int z, MorphSleigh.SleighDirection direction, double playerX, double playerY, double playerZ)
{
_x = x;
_y = y;
_z = z;
_direction = direction;
_playerX = playerX;
_playerY = playerY;
_playerZ = playerZ;
_used = false;
}
public int getX()
{
return _x;
}
public int getY()
{
return _y;
}
public int getZ()
{
return _z;
}
public MorphSleigh.SleighDirection getDirection()
{
return _direction;
}
public double getPlayerX()
{
return _playerX;
}
public double getPlayerY()
{
return _playerY;
}
public double getPlayerZ()
{
return _playerZ;
}
public void setUsed(boolean used)
{
_used = used;
}
public boolean isUsed()
{
return _used;
}
}

View File

@ -0,0 +1,170 @@
package mineplex.core.gadget.gadgets.morph.managers.sleigh;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Horse;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import mineplex.core.common.util.UtilEnt;
public class SleighReindeer
{
private enum AntlerPosition
{
SOUTH(0.4, 0.2, 0.6, 0.7, 4.0, 2.0),
NORTH(-0.3, -0.25, -0.5, -0.6, 4.0, 2.0);
private double _xA, _xB, _zA, _zB, _angleA, _angleB;
AntlerPosition(double xA, double xB, double zA, double zB, double angleA, double angleB)
{
_xA = xA;
_xB = xB;
_zA = zA;
_zB = zB;
_angleA = angleA;
_angleB = angleB;
}
public double getxA()
{
return _xA;
}
public double getxB()
{
return _xB;
}
public double getzA()
{
return _zA;
}
public double getzB()
{
return _zB;
}
public double getAngleA()
{
return _angleA;
}
public double getAngleB()
{
return _angleB;
}
}
private Location _location;
private int _yaw;
private Horse _horse;
private Arrow _base;
private ArmorStand _hornA;
private ArmorStand _hornB;
public SleighReindeer(Location location, int yaw)
{
_location = location;
_yaw = yaw;
}
public void spawn()
{
_location.setYaw(_yaw);
_base = _location.getWorld().spawn(_location.clone().subtract(0, 1.5, 0), Arrow.class);
UtilEnt.Vegetate(_base, true);
UtilEnt.ghost(_base, true, true);
_horse = _location.getWorld().spawn(_location, Horse.class);
_horse.setStyle(Horse.Style.NONE);
_horse.setColor(Horse.Color.CREAMY);
_horse.setVariant(Horse.Variant.HORSE);
_horse.setCustomName("Rudolph");
_horse.setCustomNameVisible(true);
//_base.setPassenger(_horse);
createAntlers();
}
public void remove()
{
_horse.remove();
_base.remove();
}
public void move(int x, int z)
{
_horse.eject();
_base.remove();
_base = _location.getWorld().spawn(_location.clone().subtract(0, 1.5, 0).add(x, 0, z), Arrow.class);
UtilEnt.Vegetate(_base, true);
UtilEnt.ghost(_base, true, true);
Location horseLocation = _location.clone().subtract(0, 0.5, 0).add(x, 0, z);
horseLocation.setYaw(_yaw);
_horse.teleport(horseLocation);
//_base.setPassenger(_horse);
UtilEnt.Vegetate(_horse, true);
UtilEnt.ghost(_horse, true, false);
_hornA.remove();
_hornB.remove();
createAntlers();
}
private void createAntlers()
{
AntlerPosition antlerPosition = AntlerPosition.SOUTH;
switch (_yaw)
{
case 0:
antlerPosition = AntlerPosition.SOUTH;
break;
case 180:
antlerPosition = AntlerPosition.NORTH;
}
/*Location hornALoc = _horse.getLocation().clone().add(.4, 1, .6);
Location hornBLoc = _horse.getLocation().clone().add(.2, 1, .7);
ArmorStand hornA = hornALoc.getWorld().spawn(hornALoc, ArmorStand.class);
hornA.setVisible(false);
hornA.setGravity(false);
hornA.getEquipment().setItemInHand(new ItemStack(Material.DEAD_BUSH));
hornA.setRightArmPose(new EulerAngle(0, 4, 0));
ArmorStand hornB = hornBLoc.getWorld().spawn(hornBLoc, ArmorStand.class);
hornB.setVisible(false);
hornB.setGravity(false);
hornB.getEquipment().setItemInHand(new ItemStack(Material.DEAD_BUSH));
hornB.setRightArmPose(new EulerAngle(0, 2, 0));
_hornA = hornA;
_hornB = hornB;*/
Location hornALoc = _horse.getLocation().clone().add(antlerPosition.getxA(), 1, antlerPosition.getzA());
Location hornBLoc = _horse.getLocation().clone().add(antlerPosition.getxB(), 1, antlerPosition.getzB());
ArmorStand hornA = hornALoc.getWorld().spawn(hornALoc, ArmorStand.class);
hornA.setVisible(false);
hornA.setGravity(false);
hornA.getEquipment().setItemInHand(new ItemStack(Material.DEAD_BUSH));
hornA.setRightArmPose(new EulerAngle(0, antlerPosition.getAngleA(), 0));
ArmorStand hornB = hornBLoc.getWorld().spawn(hornBLoc, ArmorStand.class);
hornB.setVisible(false);
hornB.setGravity(false);
hornB.getEquipment().setItemInHand(new ItemStack(Material.DEAD_BUSH));
hornB.setRightArmPose(new EulerAngle(0, antlerPosition.getAngleB(), 0));
_hornA = hornA;
_hornB = hornB;
}
}

View File

@ -3,7 +3,6 @@ package mineplex.core.mount;
import java.util.ArrayList;
import java.util.List;
import mineplex.core.mount.types.*;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -24,6 +23,20 @@ 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.MountBabyReindeer;
import mineplex.core.mount.types.MountCart;
import mineplex.core.mount.types.MountChicken;
import mineplex.core.mount.types.MountDragon;
import mineplex.core.mount.types.MountFreedomHorse;
import mineplex.core.mount.types.MountFrost;
import mineplex.core.mount.types.MountMule;
import mineplex.core.mount.types.MountNightmareSteed;
import mineplex.core.mount.types.MountSlime;
import mineplex.core.mount.types.MountSpider;
import mineplex.core.mount.types.MountTitan;
import mineplex.core.mount.types.MountUndead;
import mineplex.core.mount.types.MountValentinesSheep;
import mineplex.core.mount.types.MountZombie;
public class MountManager extends MiniPlugin
{
@ -49,7 +62,7 @@ public class MountManager extends MiniPlugin
private void CreateGadgets()
{
_types = new ArrayList<Mount<?>>();
_types = new ArrayList<>();
_types.add(new MountUndead(this));
_types.add(new MountFrost(this));
@ -64,6 +77,7 @@ public class MountManager extends MiniPlugin
_types.add(new MountValentinesSheep(this));
_types.add(new MountFreedomHorse(this));
_types.add(new MountNightmareSteed(this));
_types.add(new MountChicken(this));
//_types.add(new MountSheep(this));
}

View File

@ -1,32 +1,47 @@
package mineplex.core.mount.types;
import java.lang.reflect.Field;
import java.util.Map;
import net.minecraft.server.v1_8_R3.EntityLiving;
import org.bukkit.Material;
import org.bukkit.entity.Chicken;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.mount.Mount;
import mineplex.core.disguise.disguises.DisguiseChicken;
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;
public class MountChicken extends Mount<SingleEntityMountData<Chicken>>
public class MountChicken extends HorseMount
{
public MountChicken(MountManager manager)
{
super(manager, "Chicken Mount", Material.SLIME_BALL, (byte)0,
UtilText.splitLineToArray(C.cGray + "Placeholder", LineFormat.LORE),
15000);
KnownPackage = false;
super(manager, "Chicken Mount",
UtilText.splitLinesToArray(new String[]
{
"Placeholder"
}, LineFormat.LORE),
Material.GLASS, (byte) 0, -1, Horse.Color.BLACK, Horse.Style.NONE, Horse.Variant.HORSE, 2.0, Material.AIR);
}
@Override
public void enableCustom(Player player)
{
player.leaveVehicle();
@ -35,50 +50,108 @@ public class MountChicken extends Mount<SingleEntityMountData<Chicken>>
//Remove other mounts
Manager.DeregisterAll(player);
SingleEntityMountData<Chicken> mount = new SingleEntityMountData<>(player, player.getWorld().spawn(player.getLocation(), Chicken.class));
mount.getEntity().setBaby();
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.setMaxHealth(20);
horse.setHealth(horse.getMaxHealth());
horse.getInventory().setSaddle(new ItemStack(Material.SADDLE));
mount.getEntity().setCustomName(player.getName() + "'s " + getName());
if (horse.getVariant() == Horse.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
SingleEntityMountData<Horse> mount = new SingleEntityMountData<>(player, horse);
_active.put(player, mount);
DisguiseChicken chicken = new DisguiseChicken(horse);
chicken.setName(player.getName() + "'s Chicken Mount");
Manager.getDisguiseManager().disguise(chicken);
UtilEnt.silence(horse, true);
}
public void disable(Player player)
// Detects player falling and slows down, like it happens with a chicken falling
@EventHandler
public void onPlayerFall(PlayerMoveEvent event)
{
SingleEntityMountData<Chicken> mount = _active.remove(player);
if (mount != null)
Player player = event.getPlayer();
for (Map.Entry<Player, SingleEntityMountData<Horse>> entry : getActive().entrySet())
{
mount.remove();
Horse horse = entry.getValue().getEntity();
//Inform
UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(getName()) + "."));
Manager.removeActive(player);
if (horse.getPassenger() == player)
{
if (event.getFrom().getY() > event.getTo().getY())
{
// Slows down horse
horse.setVelocity(horse.getVelocity().setY(horse.getVelocity().getY() * .75));
}
}
}
}
@EventHandler
public void interactMount(PlayerInteractEntityEvent event)
public void jump(UpdateEvent event)
{
if (event.getRightClicked() == null)
if (event.getType() != UpdateType.TICK)
return;
SingleEntityMountData<Chicken> data = getActive().get(event.getPlayer());
for (Player player : getActive().keySet())
{
final Horse horse = getActive().get(player).getEntity();
if(data == null) return;
if (horse.getPassenger() != player)
continue;
if(!data.ownsMount(event.getPlayer())) return;
if (!UtilEnt.isGrounded(horse))
continue;
if(!data.isPartOfMount(event.getRightClicked())) return;
if (!Recharge.Instance.use(player, "Chicken Mount Jump", 100, false, false))
continue;
event.getPlayer().leaveVehicle();
event.getPlayer().eject();
try
{
Field jump = EntityLiving.class.getDeclaredField("aY");
final boolean accessible = jump.isAccessible();
event.getRightClicked().setPassenger(event.getPlayer());
jump.setAccessible(true);
boolean isJumping = jump.getBoolean(((CraftPlayer) player).getHandle());
jump.setAccessible(accessible);
if (!isJumping)
continue;
//Not jumping anymore
((CraftPlayer) player).getHandle().i(false);
//Velocity
UtilAction.velocity(horse, 1.4, 0.38, .8, true);
//Sound
player.playSound(horse.getLocation(), Sound.CHICKEN_IDLE, .4F, 1.0F);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
}

View File

@ -4,6 +4,8 @@ import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Map.Entry;
import net.minecraft.server.v1_8_R3.EntityLiving;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
@ -33,7 +35,6 @@ 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
{
@ -152,43 +153,6 @@ public class MountSpider extends HorseMount
}
}
}
// @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;
//
// Horse horse = getActive().get(event.getPlayer());
//
// if (!UtilEnt.isGrounded(horse))
// return;
//
// event.setCancelled(true);
// player.setFlying(false);
//
// //Disable Flight
// player.setAllowFlight(false);
//
// //Velocity
// UtilAction.velocity(horse, 1.4, 0.38, 1, true);
//
// //Sound
// player.playSound(horse.getLocation(), Sound.SPIDER_IDLE, .4F, 1.0F);
// }
@EventHandler
public void jump(UpdateEvent event)
@ -212,12 +176,12 @@ public class MountSpider extends HorseMount
try
{
Field jump = EntityLiving.class.getDeclaredField("aY");
final boolean accessable = jump.isAccessible();
final boolean accessible = jump.isAccessible();
jump.setAccessible(true);
boolean isJumping = jump.getBoolean(((CraftPlayer) player).getHandle());
jump.setAccessible(accessable);
jump.setAccessible(accessible);
if (!isJumping)
continue;