Missing Gadgets

This commit is contained in:
Chiss 2014-08-26 08:17:41 +10:00
parent 0e3cf67402
commit 07ee44508e
10 changed files with 532 additions and 7 deletions

View File

@ -82,13 +82,13 @@ public class GadgetManager extends MiniPlugin
_gadgets = new NautHashMap<GadgetType, List<Gadget>>();
// Items
addGadget(new ItemPaintballGun(this));
addGadget(new ItemBatGun(this));
addGadget(new ItemEtherealPearl(this));
addGadget(new ItemFirework(this));
addGadget(new ItemTNT(this));
addGadget(new ItemFleshHook(this));
addGadget(new ItemMelonLauncher(this));
addGadget(new ItemEtherealPearl(this));
addGadget(new ItemFleshHook(this));
addGadget(new ItemPaintballGun(this));
addGadget(new ItemBatGun(this));
addGadget(new ItemCoinBomb(this));
//addGadget(new ItemFootball(this));
//addGadget(new ItemDuelingSword(this));
@ -118,12 +118,12 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphBlaze(this));
// Particles
addGadget(new ParticleGreen(this));
addGadget(new ParticleFoot(this));
addGadget(new ParticleEnchant(this));
addGadget(new ParticleFireRings(this));
addGadget(new ParticleRain(this));
addGadget(new ParticleHelix(this));
addGadget(new ParticleGreen(this));
// Music
addGadget(new MusicGadget(this, "13 Disc", new String[] {""}, 5000, 2256, 178000));

View File

@ -0,0 +1,94 @@
package mineplex.core.gadget.gadgets;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Material;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class ItemEtherealPearl extends ItemGadget
{
public ItemEtherealPearl(GadgetManager manager)
{
super(manager, "Ethereal Pearl", new String[]
{
C.cWhite + "Take a ride through the skies",
C.cWhite + "on your very own Ethereal Pearl!",
},
-1,
Material.ENDER_PEARL, (byte)0,
500, new Ammo("Ethereal Pearl", "50 Bats", Material.ENDER_PEARL, (byte)0, new String[] { C.cWhite + "50 Pearls to get around with!" }, 500, 50));
}
@Override
public void DisableCustom(Player player)
{
super.DisableCustom(player);
}
@Override
public void ActivateCustom(Player player)
{
player.eject();
player.leaveVehicle();
EnderPearl pearl = player.launchProjectile(EnderPearl.class);
pearl.setPassenger(player);
//Inform
UtilPlayer.message(player, F.main("Skill", "You threw " + F.skill(GetName()) + "."));
//Dont Collide
((CraftPlayer)player).getHandle().spectating = true;
UtilInv.Update(player);
}
@EventHandler
public void teleportCancel(PlayerTeleportEvent event)
{
if (event.getCause() == TeleportCause.ENDER_PEARL)
{
//Firework
FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.PURPLE).with(Type.BALL).trail(true).build();
try
{
UtilFirework.playFirework(event.getTo(), effect);
}
catch (Exception e)
{
e.printStackTrace();
}
event.setCancelled(true);
}
}
@EventHandler
public void disableNoCollide(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
for (Player player : UtilServer.getPlayers())
if (player.getVehicle() == null)
((CraftPlayer)player).getHandle().spectating = false;
}
}

View File

@ -0,0 +1,162 @@
package mineplex.core.gadget.gadgets;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.disguise.disguises.DisguiseEnderman;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class MorphEnderman extends MorphGadget
{
public MorphEnderman(GadgetManager manager)
{
super(manager, "Enderman Morph", new String[]
{
C.cWhite + "Transforms the wearer into an Enderman!",
" ",
C.cYellow + "Double Jump" + C.cGray + " to use " + C.cGreen + "Blink",
},
30000,
Material.ENDER_PEARL, (byte)0);
}
@Override
public void EnableCustom(final Player player)
{
this.ApplyArmor(player);
DisguiseEnderman disguise = new DisguiseEnderman(player);
disguise.SetName(player.getName(), Manager.getClientManager().Get(player).GetRank());
disguise.SetCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguise);
}
@Override
public void DisableCustom(Player player)
{
this.RemoveArmor(player);
Manager.getDisguiseManager().undisguise(player);
}
@EventHandler
public void teleport(PlayerToggleFlightEvent event)
{
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE)
return;
if (!IsActive(player))
return;
event.setCancelled(true);
player.setFlying(false);
//Disable Flight
player.setAllowFlight(false);
//Set Recharge
Recharge.Instance.use(player, GetName(), 2000, false, false);
//Smoke Trail
Block lastSmoke = player.getLocation().getBlock();
double curRange = 0;
while (curRange <= 16)
{
Location newTarget = player.getLocation().add(new Vector(0,0.2,0)).add(player.getLocation().getDirection().multiply(curRange));
if (!UtilBlock.airFoliage(newTarget.getBlock()) ||
!UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP)))
break;
//Progress Forwards
curRange += 0.2;
//Smoke Trail
if (!lastSmoke.equals(newTarget.getBlock()))
{
lastSmoke.getWorld().playEffect(lastSmoke.getLocation(), Effect.SMOKE, 4);
}
lastSmoke = newTarget.getBlock();
}
//Modify Range
curRange -= 0.4;
if (curRange < 0)
curRange = 0;
//Destination
Location loc = player.getLocation().add(player.getLocation().getDirection().multiply(curRange).add(new Vector(0, 0.4, 0)));
if (curRange > 0)
{
//Firework
FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.BLACK).with(Type.BALL).trail(false).build();
try
{
UtilFirework.playFirework(player.getEyeLocation(), effect);
player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f);
}
catch (Exception e)
{
e.printStackTrace();
}
player.teleport(loc);
//Firework
try
{
UtilFirework.playFirework(player.getEyeLocation(), effect);
player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f);
}
catch (Exception e)
{
e.printStackTrace();
}
}
player.setFallDistance(0);
}
@EventHandler
public void teleportUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : GetActive())
{
if (player.getGameMode() == GameMode.CREATIVE)
continue;
if (Recharge.Instance.usable(player, GetName()))
{
player.setAllowFlight(true);
}
}
}
}

View File

@ -0,0 +1,166 @@
package mineplex.core.gadget.gadgets;
import java.util.HashMap;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilServer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.OutfitGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class OutfitRaveSuit extends OutfitGadget
{
private HashMap<String, Integer> _colorPhase = new HashMap<String, Integer>();
public OutfitRaveSuit(GadgetManager manager, String name,
int cost, ArmorSlot slot, Material mat, byte data)
{
super(manager, name, new String[] {"Wear the complete set for","awesome bonus effects!", "Bonus coming soon..."}, cost, slot, mat, data);
}
@Override
public void EnableCustom(Player player)
{
ApplyArmor(player);
_colorPhase.put(player.getName(), -1);
}
@Override
public void DisableCustom(Player player)
{
RemoveArmor(player);
_colorPhase.remove(player.getName());
}
@EventHandler
public void updateColor(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : UtilServer.getPlayers())
{
if (!IsActive(player))
continue;
//Get Item
ItemStack stack;
if (GetSlot() == ArmorSlot.Helmet)
{
stack = player.getInventory().getHelmet();
if (!UtilGear.isMat(stack, GetDisplayMaterial()))
{
Disable(player);
continue;
}
}
else if (GetSlot() == ArmorSlot.Chest)
{
stack = player.getInventory().getChestplate();
if (!UtilGear.isMat(stack, GetDisplayMaterial()))
{
Disable(player);
continue;
}
}
else if (GetSlot() == ArmorSlot.Legs)
{
stack = player.getInventory().getLeggings();
if (!UtilGear.isMat(stack, GetDisplayMaterial()))
{
Disable(player);
continue;
}
}
else if (GetSlot() == ArmorSlot.Boots)
{
stack = player.getInventory().getBoots();
if (!UtilGear.isMat(stack, GetDisplayMaterial()))
{
Disable(player);
continue;
}
}
else
{
continue;
}
//Rainbow
int phase = _colorPhase.get(player.getName());
LeatherArmorMeta meta = (LeatherArmorMeta)stack.getItemMeta();
if (phase == -1)
{
meta.setColor(Color.fromRGB(250, 0, 0));
_colorPhase.put(player.getName(), 0);
}
//Red > Yellow
else if (phase == 0)
{
meta.setColor(Color.fromRGB(250, Math.min(250, meta.getColor().getGreen() + 25), 0));
if (meta.getColor().getGreen() >= 250)
_colorPhase.put(player.getName(), 1);
}
//Yellow > Green
else if (phase == 1)
{
meta.setColor(Color.fromRGB(Math.max(0, meta.getColor().getRed() - 25), 250, 0));
if (meta.getColor().getRed() <= 0)
_colorPhase.put(player.getName(), 2);
}
//Green > Blue
else if (phase == 2)
{
meta.setColor(Color.fromRGB(0, Math.max(0, meta.getColor().getGreen() - 25), Math.min(250, meta.getColor().getBlue() + 25)));
if (meta.getColor().getGreen() <= 0)
_colorPhase.put(player.getName(), 3);
}
//Blue > Red
else if (phase == 3)
{
meta.setColor(Color.fromRGB(Math.min(250, meta.getColor().getRed() + 25), 0, Math.max(0, meta.getColor().getBlue() - 25)));
if (meta.getColor().getBlue() <= 0)
_colorPhase.put(player.getName(), 0);
}
stack.setItemMeta(meta);
}
}
@EventHandler
public void debug(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().contains("on"))
{
this.Enable(event.getPlayer());
event.setCancelled(true);
}
if (event.getMessage().contains("off"))
{
this.Disable(event.getPlayer());
event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,28 @@
package mineplex.core.gadget.gadgets;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.OutfitGadget;
public class OutfitSpaceSuit extends OutfitGadget
{
public OutfitSpaceSuit(GadgetManager manager, String name,
int cost, ArmorSlot slot, Material mat, byte data)
{
super(manager, name, new String[] {"Wear the complete set for","awesome bonus effects!", "Bonus coming soon..."}, cost, slot, mat, data);
}
@Override
public void EnableCustom(Player player)
{
ApplyArmor(player);
}
@Override
public void DisableCustom(Player player)
{
RemoveArmor(player);
}
}

View File

@ -0,0 +1,68 @@
package mineplex.core.gadget.types;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.itemstack.ItemStackFactory;
public abstract class OutfitGadget extends Gadget
{
public enum ArmorSlot
{
Helmet,
Chest,
Legs,
Boots
}
private ArmorSlot _slot;
public OutfitGadget(GadgetManager manager, String name, String[] desc, int cost, ArmorSlot slot, Material mat, byte data)
{
super(manager, GadgetType.Costume, name, desc, cost, mat, data);
_slot = slot;
}
public ArmorSlot GetSlot()
{
return _slot;
}
public void ApplyArmor(Player player)
{
Manager.RemoveMorph(player);
_active.add(player);
UtilPlayer.message(player, F.main("Gadget", "You put on " + F.elem(GetName()) + "."));
if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(
ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName()));
else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(
ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName()));
else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(
ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName()));
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(
ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName()));
}
public void RemoveArmor(Player player)
{
if (!_active.remove(player))
return;
UtilPlayer.message(player, F.main("Gadget", "You took off " + F.elem(GetName()) + "."));
if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(null);
else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(null);
else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(null);
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(null);
}
}

View File

@ -92,7 +92,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class HubManager extends MiniClientPlugin<HubClient>
{
public String Mode = "Normal";
public String Mode = "Normal";
private BlockRestore _blockRestore;
private CoreClientManager _clientManager;

View File

@ -26,6 +26,7 @@ import nautilus.game.arcade.game.games.halloween.Halloween;
import nautilus.game.arcade.game.games.hideseek.HideSeek;
import nautilus.game.arcade.game.games.micro.Micro;
import nautilus.game.arcade.game.games.milkcow.MilkCow;
import nautilus.game.arcade.game.games.minestrike.MineStrike;
import nautilus.game.arcade.game.games.mineware.MineWare;
import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.quiver.QuiverTeams;
@ -78,6 +79,7 @@ public class GameFactory
else if (gameType == GameType.Halloween) return new Halloween(_manager);
else if (gameType == GameType.HideSeek) return new HideSeek(_manager);
else if (gameType == GameType.Micro) return new Micro(_manager);
else if (gameType == GameType.MineStrike) return new MineStrike(_manager);
else if (gameType == GameType.MineWare) return new MineWare(_manager);
else if (gameType == GameType.MilkCow) return new MilkCow(_manager);
else if (gameType == GameType.Paintball) return new Paintball(_manager);

View File

@ -27,6 +27,7 @@ public enum GameType
SurvivalGames("Survival Games"),
SurvivalGamesTeams("Survival Games Teams"),
Micro("Micro Battle"),
MineStrike("MineStrike"),
MineWare("MineWare"),
MilkCow("Milk the Cow"),
Paintball("Super Paintball"),

View File

@ -19,13 +19,17 @@ public class AssistsStatTracker extends StatTracker<Game>
{
for (CombatComponent log : event.GetLog().GetAttackers())
{
if (!log.IsPlayer())
continue;
if (event.GetLog().GetKiller() != null && log.equals(event.GetLog().GetKiller()))
continue;
Player player = UtilPlayer.searchExact(log.GetName());
getGame().AddStat(player, "Assists", 1, false, false);
getGame().AddStat(player, getGame().GetKit(player).GetName() + " Assists", 1, false, false);
}
}
}