Draft of the PPC cosmetic
This commit is contained in:
parent
f3c3ee806d
commit
18eaf84fc3
@ -157,6 +157,7 @@ import mineplex.core.gadget.gadgets.item.ItemPaintballGun;
|
||||
import mineplex.core.gadget.gadgets.item.ItemPaintbrush;
|
||||
import mineplex.core.gadget.gadgets.item.ItemPartyPopper;
|
||||
import mineplex.core.gadget.gadgets.item.ItemSnowball;
|
||||
import mineplex.core.gadget.gadgets.item.ItemSwortal;
|
||||
import mineplex.core.gadget.gadgets.item.ItemTNT;
|
||||
import mineplex.core.gadget.gadgets.item.ItemTrampoline;
|
||||
import mineplex.core.gadget.gadgets.kitselector.HalloweenKitSelector;
|
||||
@ -583,6 +584,7 @@ public class GadgetManager extends MiniPlugin
|
||||
addGadget(new ItemConnect4(this));
|
||||
addGadget(new ItemMaryPoppins(this));
|
||||
addGadget(new ItemClacker(this));
|
||||
addGadget(new ItemSwortal(this));
|
||||
|
||||
// Costume
|
||||
addGadget(new OutfitRaveSuitHelmet(this));
|
||||
|
@ -0,0 +1,242 @@
|
||||
package mineplex.core.gadget.gadgets.item;
|
||||
|
||||
import java.time.Month;
|
||||
import java.time.YearMonth;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
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.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.particles.ColoredParticle;
|
||||
import mineplex.core.common.util.particles.DustSpellColor;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.ItemGadget;
|
||||
import mineplex.core.gadget.util.CostConstants;
|
||||
|
||||
public class ItemSwortal extends ItemGadget
|
||||
{
|
||||
|
||||
private static final Material[] SWORD_TYPES =
|
||||
{
|
||||
Material.GOLD_SWORD,
|
||||
Material.IRON_SWORD,
|
||||
Material.DIAMOND_SWORD
|
||||
};
|
||||
|
||||
public ItemSwortal(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Swortal", new String[]
|
||||
{
|
||||
|
||||
}, CostConstants.POWERPLAY_BONUS, Material.BONE, (byte) 0, 50, null);
|
||||
|
||||
// Free = false;
|
||||
setPPCYearMonth(YearMonth.of(2018, Month.AUGUST));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ActivateCustom(Player player)
|
||||
{
|
||||
createAndFire(player.getLocation().add(0, 3, 0), 20);
|
||||
}
|
||||
|
||||
private void createAndFire(Location location, int delay)
|
||||
{
|
||||
Swortal swortal = new Swortal(location);
|
||||
|
||||
Manager.runSyncTimer(new BukkitRunnable()
|
||||
{
|
||||
int ticks = 0;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (ticks % 5 == 0)
|
||||
{
|
||||
swortal.drawParticles();
|
||||
}
|
||||
|
||||
if (ticks > delay)
|
||||
{
|
||||
swortal.throwSword();
|
||||
}
|
||||
|
||||
ticks++;
|
||||
|
||||
if (ticks > 150 || !swortal.Sword.isValid())
|
||||
{
|
||||
swortal.remove();
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}, 0, 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void command(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (!event.getMessage().equalsIgnoreCase("/gil") || !event.getPlayer().isOp())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
Location center = event.getPlayer().getLocation().add(0, 0.5, 0);
|
||||
|
||||
Manager.runSyncTimer(new BukkitRunnable()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (i++ >= 25)
|
||||
{
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
Location location = center.clone().add(UtilAlg.getTrajectory(UtilMath.r(360), -UtilMath.r(60) - 20).multiply(18));
|
||||
location.setDirection(UtilAlg.getTrajectory(location, center));
|
||||
|
||||
createAndFire(location, 80 - (i * 2) + UtilMath.r(25));
|
||||
}
|
||||
}, 20, 2);
|
||||
}
|
||||
|
||||
private class Swortal
|
||||
{
|
||||
|
||||
final Location Point;
|
||||
final Vector Direction;
|
||||
final ArmorStand Sword;
|
||||
final DustSpellColor PortalColour = new DustSpellColor(240 + UtilMath.rRange(-5, 5), 205 + UtilMath.rRange(-20, 20), UtilMath.r(5));
|
||||
final DustSpellColor SwordColour = new DustSpellColor(255, UtilMath.r(20), UtilMath.r(20));
|
||||
final List<Location> PortalPoints, SwordPathPoints;
|
||||
|
||||
double DistFactor;
|
||||
|
||||
Swortal(Location point)
|
||||
{
|
||||
Point = point;
|
||||
Direction = point.getDirection();
|
||||
|
||||
Location armourStand = point.clone()
|
||||
.subtract(0, 0.7, 0)
|
||||
.add(UtilAlg.getLeft(Direction).multiply(0.35));
|
||||
|
||||
Sword = point.getWorld().spawn(armourStand, ArmorStand.class);
|
||||
Sword.setGravity(false);
|
||||
Sword.setArms(true);
|
||||
Sword.setVisible(false);
|
||||
Sword.setRightArmPose(new EulerAngle(Math.toRadians(Point.getPitch() - 4), 0, 0));
|
||||
|
||||
PortalPoints = new ArrayList<>();
|
||||
SwordPathPoints = new ArrayList<>();
|
||||
createPortalPoints();
|
||||
}
|
||||
|
||||
void createPortalPoints()
|
||||
{
|
||||
Vector pointVector = Point.toVector();
|
||||
double yaw = Math.toRadians(Point.getYaw()), pitch = Math.toRadians(Point.getPitch());
|
||||
|
||||
for (double radius = 0.2; radius < 1.1; radius += 0.2)
|
||||
{
|
||||
for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 10)
|
||||
{
|
||||
Location location = Point.clone().add(Math.cos(theta) * radius, Math.sin(theta) * radius, 0);
|
||||
Vector vector = location.toVector().subtract(pointVector);
|
||||
|
||||
UtilAlg.rotateAroundXAxis(vector, pitch);
|
||||
UtilAlg.rotateAroundYAxis(vector, yaw);
|
||||
|
||||
PortalPoints.add(Point.clone().add(vector));
|
||||
}
|
||||
}
|
||||
|
||||
UtilParticle.PlayParticleToAll(ParticleType.FLAME, Point, null, 0.1F, 20, ViewDist.LONGER);
|
||||
Point.getWorld().playSound(Point, Sound.PORTAL, 1, 0.5F);
|
||||
}
|
||||
|
||||
void drawParticles()
|
||||
{
|
||||
PortalPoints.forEach(location -> new ColoredParticle(ParticleType.RED_DUST, PortalColour, location).display(ViewDist.LONGER));
|
||||
SwordPathPoints.forEach(location -> new ColoredParticle(ParticleType.RED_DUST, SwordColour, location).display(ViewDist.LONGER));
|
||||
}
|
||||
|
||||
void throwSword()
|
||||
{
|
||||
if (DistFactor == 0)
|
||||
{
|
||||
Material material = UtilMath.randomElement(SWORD_TYPES);
|
||||
|
||||
if (material != null)
|
||||
{
|
||||
Sword.setItemInHand(new ItemStack(material));
|
||||
}
|
||||
Point.getWorld().playSound(Point, Sound.ZOMBIE_REMEDY, 1, 0.5F);
|
||||
}
|
||||
|
||||
Vector direction = Direction.clone().multiply(DistFactor += 0.5);
|
||||
Location newLocation = Sword.getLocation().add(Direction.clone().multiply(0.5));
|
||||
|
||||
if (newLocation.getBlock().getType() != Material.AIR)
|
||||
{
|
||||
explode();
|
||||
return;
|
||||
}
|
||||
|
||||
UtilEnt.setPosition(Sword, newLocation);
|
||||
SwordPathPoints.add(Point.clone().add(direction));
|
||||
}
|
||||
|
||||
void explode()
|
||||
{
|
||||
Location location = Sword.getLocation();
|
||||
|
||||
UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, location, null, 0, 1, ViewDist.LONGER);
|
||||
location.getWorld().playSound(location, Sound.EXPLODE, 2, 0.5F);
|
||||
|
||||
UtilPlayer.getInRadius(location, 8).forEach((player, scale) ->
|
||||
{
|
||||
if (!Manager.selectEntity(ItemSwortal.this, player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UtilAction.velocity(player, UtilAlg.getTrajectory(location, player.getLocation())
|
||||
.setY(0.8)
|
||||
.multiply(scale * 2));
|
||||
});
|
||||
|
||||
remove();
|
||||
}
|
||||
|
||||
void remove()
|
||||
{
|
||||
Sword.remove();
|
||||
PortalPoints.clear();
|
||||
SwordPathPoints.clear();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user