Added Music Gadget

This commit is contained in:
Chiss 2014-08-23 05:35:07 +10:00
parent a159f04d50
commit 2e031f1e4a
8 changed files with 200 additions and 7 deletions

View File

@ -29,6 +29,7 @@ import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.gadget.types.MorphGadget.ArmorSlot;
import mineplex.core.gadget.types.MusicGadget;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.mount.MountManager;
@ -95,6 +96,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphPig(this));
addGadget(new MorphBat(this));
addGadget(new MorphBlock(this));
addGadget(new MorphVillager(this));
// Particles
addGadget(new ParticleGreen(this));
@ -103,6 +105,20 @@ public class GadgetManager extends MiniPlugin
addGadget(new ParticleFireRings(this));
addGadget(new ParticleRain(this));
addGadget(new ParticleHelix(this));
// Music
addGadget(new MusicGadget(this, "13 Disc", new String[] {""}, 5000, 2256, 178000));
addGadget(new MusicGadget(this, "Cat Disc", new String[] {""}, 5000, 2257, 185000));
addGadget(new MusicGadget(this, "Blocks Disc", new String[] {""}, 5000, 2258, 345000));
addGadget(new MusicGadget(this, "Chirp Disc", new String[] {""}, 5000, 2259, 185000));
addGadget(new MusicGadget(this, "Far Disc", new String[] {""}, 5000, 2260, 174000));
addGadget(new MusicGadget(this, "Mall Disc", new String[] {""}, 5000, 2261, 197000));
addGadget(new MusicGadget(this, "Mellohi Disc", new String[] {""}, 5000, 2262, 96000));
addGadget(new MusicGadget(this, "Stal Disc", new String[] {""}, 5000, 2263, 150000));
addGadget(new MusicGadget(this, "Strad Disc", new String[] {""}, 5000, 2264, 188000));
addGadget(new MusicGadget(this, "Ward Disc", new String[] {""}, 5000, 2265, 251000));
addGadget(new MusicGadget(this, "11 Disc", new String[] {""}, 5000, 2266, 71000));
addGadget(new MusicGadget(this, "Wait Disc", new String[] {""}, 5000, 2267, 238000));
}
private void addGadget(Gadget gadget)

View File

@ -10,11 +10,13 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.disguise.disguises.DisguiseBlock;
import mineplex.core.event.StackerEvent;
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;
@ -32,7 +34,7 @@ public class MorphBlock extends MorphGadget
C.cYellow + "Stay Still" + C.cGray + " to use " + C.cGreen + "Solidify",
},
40000,
ArmorSlot.Helmet, Material.LEAVES, (byte)0);
ArmorSlot.Helmet, Material.EMERALD_BLOCK, (byte)0);
}
@Override
@ -40,7 +42,7 @@ public class MorphBlock extends MorphGadget
{
this.ApplyArmor(player);
_active.put(player, new BlockForm(this, player, Material.DIRT));
_active.put(player, new BlockForm(this, player, Material.EMERALD_BLOCK));
}
@Override
@ -76,7 +78,10 @@ public class MorphBlock extends MorphGadget
if (event.getClickedBlock() == null)
return;
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
if (UtilEvent.isAction(event, ActionType.L_BLOCK) || UtilEvent.isAction(event, ActionType.R_BLOCK))
return;
if (!Recharge.Instance.use(event.getPlayer(), GetName(), 500, false, false))
return;
BlockForm form = _active.get(event.getPlayer());

View File

@ -73,7 +73,7 @@ public class MorphPig extends MorphGadget
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, GetName(), 100, false, false))
if (!Recharge.Instance.use(player, GetName(), 400, false, false))
return;
player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, 1f, (float)(0.75 + Math.random() * 0.5));

View File

@ -0,0 +1,68 @@
package mineplex.core.gadget.gadgets;
import java.util.HashSet;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.*;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.disguise.disguises.DisguiseVillager;
import mineplex.core.recharge.Recharge;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.MorphGadget;
public class MorphVillager extends MorphGadget
{
public MorphVillager(GadgetManager manager)
{
super(manager, "Villager Morph", new String[]
{
C.cWhite + "HURRRR! MURR HURRR!",
" ",
C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "HURRR",
},
20000,
ArmorSlot.Helmet, Material.EMERALD, (byte)0);
}
@Override
public void EnableCustom(final Player player)
{
this.ApplyArmor(player);
DisguiseVillager disguise = new DisguiseVillager(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 Audio(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (!IsActive(player))
return;
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, GetName(), 1500, false, false))
return;
player.getWorld().playSound(player.getLocation(), Sound.VILLAGER_IDLE, 1f, 1f);
}
}

View File

@ -0,0 +1,34 @@
package mineplex.core.gadget.gadgets;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import org.bukkit.Material;
import org.bukkit.block.Block;
public class SongData
{
public Block Block;
public long EndTime;
public SongData(Block block, long duration)
{
Block = block;
EndTime = System.currentTimeMillis() + duration;
Block.setType(Material.JUKEBOX);
}
public boolean update()
{
if (System.currentTimeMillis() > EndTime)
{
Block.setType(Material.AIR);
return true;
}
UtilParticle.PlayParticle(ParticleType.NOTE, Block.getLocation().add(0.5, 1, 0.5), 0.5f, 0.5f, 0.5f, 0f, 2);
return false;
}
}

View File

@ -5,4 +5,5 @@ public enum GadgetType
Item,
Morph,
Particle,
MusicDisc,
}

View File

@ -0,0 +1,66 @@
package mineplex.core.gadget.types;
import java.util.ArrayList;
import java.util.Iterator;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.SongData;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class MusicGadget extends Gadget
{
private int _id;
private long _duration;
private ArrayList<SongData> _songs = new ArrayList<SongData>();
public MusicGadget(GadgetManager manager, String name, String[] desc, int cost, int id, long duration)
{
super(manager, GadgetType.MusicDisc, name, desc, cost, Material.getMaterial(id), (byte)0);
_id = id;
_duration = duration;
}
@Override
public void EnableCustom(Player player)
{
if (!Recharge.Instance.use(player, "Play Disc", _duration, true, false))
return;
player.getWorld().playEffect(player.getLocation(), Effect.RECORD_PLAY, _id);
_songs.add(new SongData(player.getLocation().getBlock(), _duration));
}
@Override
public void DisableCustom(Player player)
{
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
return;
Iterator<SongData> songIterator = _songs.iterator();
while (songIterator.hasNext())
{
SongData song = songIterator.next();
if (song.update())
songIterator.remove();
}
}
}

View File

@ -41,20 +41,23 @@ public class MountSheep extends HorseMount
Manager.DeregisterAll(player);
Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class);
horse.setAdult();
/*horse.setAdult();
horse.setAgeLock(true);
horse.setColor(_color);
horse.setStyle(_style);
horse.setVariant(_variant);
*/
horse.setOwner(player);
horse.setMaxDomestication(1);
horse.setJumpStrength(_jump);
//horse.setJumpStrength(_jump);
horse.getInventory().setSaddle(new ItemStack(Material.SADDLE));
DisguiseSheep disguise = new DisguiseSheep(horse);
disguise.SetName(player.getName(), Manager.getClientManager().Get(player).GetRank());
disguise.SetCustomNameVisible(true);
//disguise.setColor(DyeColor.getByColor(org.bukkit.Color.fromRGB(100, 0, 200)));
disguise.setColor(DyeColor.getByColor(org.bukkit.Color.fromRGB(100, 0, 200)));
Manager.getDisguiseManager().disguise(disguise);
//Inform