Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex
This commit is contained in:
commit
158cc0909b
@ -97,11 +97,13 @@ public class AntiHack extends MiniPlugin
|
||||
_movementDetectors = new ArrayList<Detector>();
|
||||
_combatDetectors = new ArrayList<Detector>();
|
||||
|
||||
_movementDetectors.add(new Fly(this));
|
||||
_movementDetectors.add(new Idle(this));
|
||||
_movementDetectors.add(new Speed(this));
|
||||
// _movementDetectors.add(new Fly(this));
|
||||
// _movementDetectors.add(new Idle(this));
|
||||
// _movementDetectors.add(new Speed(this));
|
||||
//
|
||||
// _combatDetectors.add(new Reach(this));
|
||||
|
||||
_combatDetectors.add(new Reach(this));
|
||||
_enabled = false;
|
||||
}
|
||||
|
||||
public static void Initialize(JavaPlugin plugin, Punish punish, Portal portal, PreferencesManager preferences, CoreClientManager clientManager)
|
||||
|
@ -119,6 +119,7 @@ public class GadgetManager extends MiniPlugin
|
||||
addGadget(new MorphBlaze(this));
|
||||
//addGadget(new MorphGeno(this));
|
||||
addGadget(new MorphWither(this));
|
||||
addGadget(new MorphBunny(this));
|
||||
|
||||
// Particles
|
||||
addGadget(new ParticleFoot(this));
|
||||
|
@ -0,0 +1,241 @@
|
||||
package mineplex.core.gadget.gadgets;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.ItemDespawnEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.disguise.disguises.DisguiseRabbit;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.MorphGadget;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class MorphBunny extends MorphGadget
|
||||
{
|
||||
private HashSet<Player> _jumpCharge = new HashSet<Player>();
|
||||
private HashMap<Item, String> _eggs = new HashMap<Item, String>();
|
||||
|
||||
private short[] durs = new short[] {51,55,57,61,66,90,93,98,101};
|
||||
|
||||
public MorphBunny(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Easter Bunny Morph", new String[]
|
||||
{
|
||||
C.cWhite + "Happy Easter!",
|
||||
" ",
|
||||
C.cYellow + "Charge Crouch" + C.cGray + " to use " + C.cGreen + "Super Jump",
|
||||
C.cYellow + "Left Click" + C.cGray + " to use " + C.cGreen + "Hide Easter Egg",
|
||||
" ",
|
||||
C.cRed +C.Bold + "WARNING: " + ChatColor.RESET + "Hide Easter Egg uses 500 Coins" ,
|
||||
" ",
|
||||
C.cPurple + "Special Limited Time Morph",
|
||||
C.cPurple + "Purchase at www.mineplex.com/shop",
|
||||
},
|
||||
1,
|
||||
Material.MONSTER_EGG, (byte)98);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void EnableCustom(final Player player)
|
||||
{
|
||||
this.ApplyArmor(player);
|
||||
|
||||
DisguiseRabbit disguise = new DisguiseRabbit(player);
|
||||
disguise.setName(player.getName(), Manager.getClientManager().Get(player).GetRank());
|
||||
disguise.setCustomNameVisible(true);
|
||||
Manager.getDisguiseManager().disguise(disguise);
|
||||
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999999, 1));
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 999999999, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DisableCustom(Player player)
|
||||
{
|
||||
_jumpCharge.remove(player);
|
||||
this.RemoveArmor(player);
|
||||
Manager.getDisguiseManager().undisguise(player);
|
||||
|
||||
player.removePotionEffect(PotionEffectType.SPEED);
|
||||
player.removePotionEffect(PotionEffectType.JUMP);
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void jumpTrigger(PlayerToggleSneakEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!IsActive(player))
|
||||
return;
|
||||
|
||||
//Start
|
||||
if (!event.getPlayer().isSneaking())
|
||||
{
|
||||
if (UtilEnt.isGrounded(event.getPlayer()))
|
||||
_jumpCharge.add(event.getPlayer());
|
||||
}
|
||||
//Jump
|
||||
else if (_jumpCharge.remove(event.getPlayer()))
|
||||
{
|
||||
float power = player.getExp();
|
||||
player.setExp(0f);
|
||||
|
||||
UtilAction.velocity(player, power * 4, 0.4, 4, true);
|
||||
|
||||
player.getWorld().playSound(player.getLocation(), Sound.CAT_HIT, 0.75f, 2f);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void jumpBoost(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
Iterator<Player> jumpIter = _jumpCharge.iterator();
|
||||
|
||||
while (jumpIter.hasNext())
|
||||
{
|
||||
Player player = jumpIter.next();
|
||||
|
||||
if (!player.isValid() || !player.isOnline() || !player.isSneaking())
|
||||
{
|
||||
jumpIter.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
player.setExp(Math.min(0.9999f, player.getExp() + 0.03f));
|
||||
|
||||
player.playSound(player.getLocation(), Sound.FIZZ, 0.25f + player.getExp() * 0.5f, 0.5f + player.getExp());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void eggHide(PlayerInteractEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!IsActive(player))
|
||||
return;
|
||||
|
||||
if (!UtilEvent.isAction(event, ActionType.L))
|
||||
return;
|
||||
|
||||
if (Manager.getDonationManager().Get(player.getName()).GetBalance(CurrencyType.Coins) < 500)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Gadget", "You do not have enough Coins."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Recharge.Instance.use(player, "Hide Egg", 30000, true, false))
|
||||
return;
|
||||
|
||||
//Color
|
||||
|
||||
|
||||
//Item
|
||||
ItemStack eggStack = ItemStackFactory.Instance.CreateStack(Material.MONSTER_EGG, (byte)0, 1, "Hidden Egg" + System.currentTimeMillis());
|
||||
eggStack.setDurability(durs[UtilMath.r(durs.length)]);
|
||||
|
||||
Item egg = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), eggStack);
|
||||
UtilAction.velocity(egg, player.getLocation().getDirection(), 0.2, false, 0, 0.2, 1, false);
|
||||
|
||||
|
||||
Manager.getDonationManager().RewardCoinsLater(this.GetName() + " Egg Hide", player, -500);
|
||||
|
||||
egg.setPickupDelay(40);
|
||||
|
||||
_eggs.put(egg, player.getName());
|
||||
|
||||
//Announce
|
||||
Bukkit.broadcastMessage(C.cYellow + C.Bold + player.getName() +
|
||||
ChatColor.RESET + C.Bold + " has hidden an " +
|
||||
C.cYellow + C.Bold + "Easter Egg" +
|
||||
ChatColor.RESET + C.Bold + " worth " +
|
||||
C.cYellow + C.Bold + "450 Coins");
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
player.playSound(other.getLocation(), Sound.CAT_HIT, 1.5f, 1.5f);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void eggPickup(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (_eggs.containsKey(event.getItem()) && !_eggs.get(event.getItem()).equals(event.getPlayer().getName()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getItem().remove();
|
||||
|
||||
Manager.getDonationManager().RewardCoinsLater(GetName() + " Egg Pickup", event.getPlayer(), 450);
|
||||
|
||||
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1.5f, 0.75f);
|
||||
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1.5f, 1.25f);
|
||||
|
||||
UtilFirework.playFirework(event.getItem().getLocation(), Type.BURST, Color.YELLOW, true, true);
|
||||
|
||||
UtilPlayer.message(event.getPlayer(),
|
||||
ChatColor.RESET + C.Bold + "You picked up an " +
|
||||
C.cYellow + C.Bold + "Easter Egg" +
|
||||
ChatColor.RESET + C.Bold + " worth " +
|
||||
C.cYellow + C.Bold + "450 Coins");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void eggClean(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
Iterator<Item> gemIterator = _eggs.keySet().iterator();
|
||||
|
||||
while (gemIterator.hasNext())
|
||||
{
|
||||
Item gem = gemIterator.next();
|
||||
|
||||
if (!gem.isValid() || gem.getTicksLived() > 24000)
|
||||
{
|
||||
gem.remove();
|
||||
gemIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void eggDespawnCancel(ItemDespawnEvent event)
|
||||
{
|
||||
if (_eggs.containsKey(event.getEntity()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
@ -34,7 +34,7 @@ public class ParticleBlizzard extends ParticleGadget
|
||||
C.cWhite + "Your double jumps and arrows",
|
||||
C.cWhite + "are enchanted with snow powers.",
|
||||
" ",
|
||||
C.cPurple + "Purchased at www.mineplex.com/shop",
|
||||
C.cPurple + "No longer available",
|
||||
},
|
||||
-1,
|
||||
Material.SNOW_BALL, (byte)0);
|
||||
|
@ -109,6 +109,7 @@ import nautilus.game.arcade.managers.GameSpectatorManager;
|
||||
import nautilus.game.arcade.managers.GameStatManager;
|
||||
import nautilus.game.arcade.managers.GameTournamentManager;
|
||||
import nautilus.game.arcade.managers.GameWorldManager;
|
||||
import nautilus.game.arcade.managers.HolidayManager;
|
||||
import nautilus.game.arcade.managers.IdleManager;
|
||||
import nautilus.game.arcade.managers.MiscManager;
|
||||
import nautilus.game.arcade.shop.ArcadeShop;
|
||||
@ -264,7 +265,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
new MiscManager(this);
|
||||
_hologramManager = hologramManager;
|
||||
_idleManager = new IdleManager(this);
|
||||
//new HalloweenManager(this);
|
||||
new HolidayManager(this);
|
||||
|
||||
// Game Addons
|
||||
new CompassAddon(plugin, this);
|
||||
|
@ -1495,6 +1495,9 @@ public class SurvivalGames extends SoloGame
|
||||
@EventHandler
|
||||
public void borderBlockDamage(ProjectileHitEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (!(event.getEntity() instanceof Fireball))
|
||||
return;
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class GameGemManager implements Listener
|
||||
{
|
||||
ArcadeManager Manager;
|
||||
|
||||
boolean DoubleGem = false;
|
||||
boolean DoubleGem = true;
|
||||
|
||||
public GameGemManager(ArcadeManager manager)
|
||||
{
|
||||
@ -174,7 +174,7 @@ public class GameGemManager implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
if (DoubleGem && game.GemDoubleEnabled)
|
||||
if (DoubleGem && game.GemDoubleEnabled && UtilPlayer.is1_8(player))
|
||||
total += earned;
|
||||
|
||||
Manager.GetDonation().RewardGems(null, "Earned " + game.GetName(), player.getName(), player.getUniqueId(), total);
|
||||
@ -245,7 +245,7 @@ public class GameGemManager implements Listener
|
||||
}
|
||||
|
||||
//Double Gem
|
||||
if (DoubleGem && game.GemDoubleEnabled)
|
||||
if (DoubleGem && game.GemDoubleEnabled && UtilPlayer.is1_8(player))
|
||||
{
|
||||
UtilPlayer.message(player, F.elem(C.cGreen + "+" + (earnedGems) + " Gems") + " for " + F.elem(C.cDGreen + "Double Gem Weekend"));
|
||||
|
||||
|
@ -4,40 +4,89 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
|
||||
import net.minecraft.server.v1_7_R4.TileEntity;
|
||||
import net.minecraft.server.v1_7_R4.TileEntityEnderChest;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class HolidayManager implements Listener
|
||||
{
|
||||
public enum HolidayType
|
||||
{
|
||||
Christmas(Material.CHEST, "Present", Sound.LEVEL_UP),
|
||||
Halloween(Material.PUMPKIN, "Pumpkin", Sound.ZOMBIE_REMEDY),
|
||||
Easter(Material.CHEST, "Egg Basket", Sound.CAT_MEOW);
|
||||
|
||||
private Material _blockType;
|
||||
private String _blockName;
|
||||
private Sound _blockBreakSound;
|
||||
|
||||
HolidayType(Material blockType, String blockName, Sound blockBreakSound)
|
||||
{
|
||||
_blockType = blockType;
|
||||
_blockName = blockName;
|
||||
_blockBreakSound = blockBreakSound;
|
||||
}
|
||||
|
||||
public String getBlockName()
|
||||
{
|
||||
return _blockName;
|
||||
}
|
||||
|
||||
public Sound getBlockSound()
|
||||
{
|
||||
return _blockBreakSound;
|
||||
}
|
||||
|
||||
public Material getBlockType()
|
||||
{
|
||||
return _blockType;
|
||||
}
|
||||
}
|
||||
|
||||
private HolidayType type = HolidayType.Easter;
|
||||
|
||||
ArcadeManager Manager;
|
||||
|
||||
|
||||
public HashSet<Block> _active = new HashSet<Block>();
|
||||
|
||||
|
||||
private HashSet<Item> _eggs = new HashSet<Item>();
|
||||
|
||||
private HashSet<Item> _coins = new HashSet<Item>();
|
||||
|
||||
|
||||
public long _lastSpawn = System.currentTimeMillis();
|
||||
|
||||
public HolidayManager(ArcadeManager manager)
|
||||
@ -46,70 +95,96 @@ public class HolidayManager implements Listener
|
||||
|
||||
Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void reset(GameStateChangeEvent event)
|
||||
{
|
||||
_active.clear();
|
||||
|
||||
|
||||
_lastSpawn = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void pumpkinEffect(UpdateEvent event)
|
||||
public void blockEffect(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() == UpdateType.TICK)
|
||||
return;
|
||||
|
||||
|
||||
Iterator<Block> blockIterator = _active.iterator();
|
||||
|
||||
|
||||
while (blockIterator.hasNext())
|
||||
{
|
||||
Block block = blockIterator.next();
|
||||
|
||||
if (block.getType() != Material.PUMPKIN && block.getType() != Material.JACK_O_LANTERN)
|
||||
|
||||
//Break
|
||||
if (block.getType() != Material.PUMPKIN &&
|
||||
block.getType() != Material.JACK_O_LANTERN &&
|
||||
block.getType() != Material.CHEST)
|
||||
{
|
||||
pumpkinBreak(block);
|
||||
specialBlockBreak(block);
|
||||
blockIterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.FLAME, block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0.06f, 4);
|
||||
if (Math.random() > 0.90)
|
||||
|
||||
if (type == HolidayType.Halloween)
|
||||
{
|
||||
if (block.getType() == Material.PUMPKIN)
|
||||
UtilParticle.PlayParticle(ParticleType.FLAME, block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0.06f, 4);
|
||||
if (Math.random() > 0.90)
|
||||
{
|
||||
block.setType(Material.JACK_O_LANTERN);
|
||||
if (block.getType() == Material.PUMPKIN)
|
||||
{
|
||||
block.setType(Material.JACK_O_LANTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
block.setType(Material.PUMPKIN);
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else if (type == HolidayType.Easter)
|
||||
{
|
||||
UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, block.getLocation().add(0.5, 0.2, 0.5), 0.3f, 0.2f, 0.3f, 0, 1);
|
||||
|
||||
if (Math.random() > 0.90)
|
||||
{
|
||||
block.setType(Material.PUMPKIN);
|
||||
Item egg = block.getWorld().dropItem(block.getLocation().add(0.5, 0.8, 0.5),
|
||||
ItemStackFactory.Instance.CreateStack(Material.EGG, (byte)0, 1, System.currentTimeMillis() + "Egg"));
|
||||
egg.setVelocity(new Vector((Math.random()-0.5)*0.3, Math.random()-0.4, (Math.random()-0.5)*0.3));
|
||||
|
||||
_eggs.add(egg);
|
||||
|
||||
block.getWorld().playSound(block.getLocation(), Sound.CHICKEN_EGG_POP, 0.25f + (float)Math.random() * 0.75f, 0.75f + (float)Math.random() * 0.5f);
|
||||
}
|
||||
|
||||
if (Math.random() > 0.95)
|
||||
{
|
||||
sendChestPackets(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void spawnPumpkinUpdate(UpdateEvent event)
|
||||
public void spawnSpecialBlockUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
|
||||
if (Manager.GetGame() == null)
|
||||
return;
|
||||
|
||||
Game game = Manager.GetGame();
|
||||
|
||||
int requirement = (int)((double)Manager.GetPlayerFull() * 0.75d);
|
||||
int requirement = (int)((double)Manager.GetPlayerFull() * 0.5d);
|
||||
if (UtilServer.getPlayers().length < requirement)
|
||||
return;
|
||||
|
||||
|
||||
if (game.GetState() != GameState.Live)
|
||||
return;
|
||||
|
||||
if (!UtilTime.elapsed(_lastSpawn, 120000))
|
||||
if (!UtilTime.elapsed(_lastSpawn, 90000))
|
||||
return;
|
||||
|
||||
|
||||
if (Math.random() > 0.01)
|
||||
return;
|
||||
|
||||
@ -117,129 +192,199 @@ public class HolidayManager implements Listener
|
||||
for (int i=0 ; i< toDrop ; i++)
|
||||
{
|
||||
double interval = 1 / (double)(toDrop);
|
||||
|
||||
|
||||
if (Math.random() >= (i * interval)) // Diminishing per growth
|
||||
{
|
||||
spawnPumpkin(getPumpkinBlock(game));
|
||||
spawnSpecialBlock(findSpecialBlockLocation(game));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_lastSpawn = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private void spawnPumpkin(Block block)
|
||||
private void spawnSpecialBlock(Block block)
|
||||
{
|
||||
if (block == null)
|
||||
{
|
||||
System.out.println("Pumpkin: Could Not Find Suitable Block");
|
||||
System.out.println("Holiday Block: Could Not Find Suitable Block");
|
||||
return;
|
||||
}
|
||||
|
||||
block.setType(Material.PUMPKIN);
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.PUMPKIN);
|
||||
|
||||
block.setType(type.getBlockType());
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, type.getBlockType());
|
||||
|
||||
if (type.getBlockType() == Material.CHEST)
|
||||
{
|
||||
sendChestPackets(block);
|
||||
}
|
||||
|
||||
_active.add(block);
|
||||
|
||||
System.out.println("Spawned Pumpkin: " + UtilWorld.locToStrClean(block.getLocation()));
|
||||
|
||||
System.out.println("Spawned Holiday Block: " + UtilWorld.locToStrClean(block.getLocation()));
|
||||
}
|
||||
|
||||
private void sendChestPackets(Block block)
|
||||
{
|
||||
PacketPlayOutBlockAction packet = new PacketPlayOutBlockAction(block.getX(), block.getY(), block.getZ(),
|
||||
CraftMagicNumbers.getBlock(block), 1, 1);
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
((CraftPlayer) other).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
private Block getPumpkinBlock(Game game)
|
||||
private Block findSpecialBlockLocation(Game game)
|
||||
{
|
||||
Block block = null;
|
||||
int attempts = 2000;
|
||||
while (attempts > 0)
|
||||
{
|
||||
attempts--;
|
||||
|
||||
|
||||
int x = game.WorldData.MinX + UtilMath.r(Math.abs(game.WorldData.MaxX - game.WorldData.MinX));
|
||||
int z = game.WorldData.MinZ + UtilMath.r(Math.abs(game.WorldData.MaxZ - game.WorldData.MinZ));
|
||||
|
||||
|
||||
block = UtilBlock.getHighest(game.WorldData.World, x, z, null);
|
||||
|
||||
|
||||
if (block.getLocation().getY() <= 2 || block.getLocation().getY() < game.WorldData.MinY || block.getLocation().getY() > game.WorldData.MaxY)
|
||||
continue;
|
||||
|
||||
|
||||
if (block.getRelative(BlockFace.DOWN).isLiquid())
|
||||
continue;
|
||||
|
||||
|
||||
if (!UtilBlock.airFoliage(block) || !UtilBlock.airFoliage(block.getRelative(BlockFace.UP)))
|
||||
continue;
|
||||
|
||||
|
||||
if (!UtilBlock.solid(block.getRelative(BlockFace.DOWN)))
|
||||
continue;
|
||||
|
||||
|
||||
boolean nextToChest = false;
|
||||
for (Block other : UtilBlock.getSurrounding(block, false))
|
||||
{
|
||||
if (other.getType() == Material.CHEST)
|
||||
nextToChest = true;
|
||||
}
|
||||
if (nextToChest)
|
||||
continue;
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void pumpkinDamage(BlockDamageEvent event)
|
||||
public void specialBlockInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (_active.contains(event.getBlock()))
|
||||
{
|
||||
Manager.GetGame().AddStat(event.getPlayer(), "Pumpkins Smashed", 1, false, true);
|
||||
pumpkinBreak(event.getBlock());
|
||||
}
|
||||
if (UtilPlayer.isSpectator(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (!UtilEvent.isAction(event, ActionType.R_BLOCK))
|
||||
return;
|
||||
|
||||
if (event.getClickedBlock() == null)
|
||||
return;
|
||||
|
||||
if (event.getClickedBlock().getType() != Material.CHEST)
|
||||
return;
|
||||
|
||||
if (!_active.contains(event.getClickedBlock()))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
specialBlockBreak(event.getClickedBlock());
|
||||
}
|
||||
|
||||
private void pumpkinBreak(Block block)
|
||||
@EventHandler
|
||||
public void specialBlockDamage(BlockDamageEvent event)
|
||||
{
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.PUMPKIN);
|
||||
block.setType(Material.AIR);
|
||||
if (UtilPlayer.isSpectator(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (!_active.contains(event.getBlock()))
|
||||
return;
|
||||
|
||||
specialBlockBreak(event.getBlock());
|
||||
}
|
||||
|
||||
private void specialBlockBreak(Block block)
|
||||
{
|
||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, type.getBlockType());
|
||||
block.setType(Material.AIR);
|
||||
|
||||
//Coins
|
||||
for (int i=0 ; i < 4 + Math.random()*16 ; i++)
|
||||
{
|
||||
Item coin = block.getWorld().dropItem(block.getLocation().add(0.5, 1, 0.5), new ItemStack(Material.getMaterial(175)));
|
||||
|
||||
Item coin = block.getWorld().dropItem(block.getLocation().add(0.5, 1, 0.5),
|
||||
ItemStackFactory.Instance.CreateStack(175, (byte)0, 1, UtilMath.r(999999) + "Coin"));
|
||||
|
||||
Vector vel = new Vector(
|
||||
(Math.random() - 0.5) * 0.5,
|
||||
0.1 + Math.random() * 0.3,
|
||||
(Math.random() - 0.5) * 0.5);
|
||||
|
||||
|
||||
coin.setVelocity(vel);
|
||||
|
||||
|
||||
coin.setPickupDelay(20);
|
||||
|
||||
|
||||
_coins.add(coin);
|
||||
}
|
||||
|
||||
|
||||
//Effect
|
||||
block.getWorld().playSound(block.getLocation(), Sound.ZOMBIE_REMEDY, 1f, 1f);
|
||||
block.getWorld().playSound(block.getLocation(), type.getBlockSound(), 1f, 1f);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void coinPickup(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (_coins.contains(event.getItem()))
|
||||
if (_coins.contains(event.getItem()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getItem().remove();
|
||||
|
||||
Manager.GetDonation().RewardCoins(null, "Halloween Pumpkin", event.getPlayer().getName(), Manager.GetClients().Get(event.getPlayer()).getAccountId(), 4 * event.getItem().getItemStack().getAmount());
|
||||
|
||||
|
||||
Manager.GetDonation().RewardCoins(null, type + " Coins", event.getPlayer().getName(), Manager.GetClients().Get(event.getPlayer()).getAccountId(), 4 * event.getItem().getItemStack().getAmount());
|
||||
|
||||
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f);
|
||||
}
|
||||
|
||||
else if (_eggs.contains(event.getItem()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void coinClean(UpdateEvent event)
|
||||
public void itemClean(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
|
||||
Iterator<Item> coinIterator = _coins.iterator();
|
||||
|
||||
|
||||
while (coinIterator.hasNext())
|
||||
{
|
||||
Item coin = coinIterator.next();
|
||||
|
||||
|
||||
if (!coin.isValid() || coin.getTicksLived() > 1200)
|
||||
{
|
||||
coin.remove();
|
||||
coinIterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<Item> eggIterator = _eggs.iterator();
|
||||
|
||||
while (eggIterator.hasNext())
|
||||
{
|
||||
Item egg = eggIterator.next();
|
||||
|
||||
if (!egg.isValid() || egg.getTicksLived() > 40)
|
||||
{
|
||||
egg.remove();
|
||||
eggIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user