fixed aprilfools bugs
mamapig debug :(
This commit is contained in:
parent
24ba42cb16
commit
da9e7892f0
@ -1,8 +1,6 @@
|
||||
package mineplex.core.aprilfools;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -29,8 +27,6 @@ public class AprilFoolsManager extends MiniPlugin
|
||||
private DisguiseManager _disguiseManager;
|
||||
private CoreClientManager _clientManager;
|
||||
|
||||
private HashSet<Player> _disguised = new HashSet<Player>();
|
||||
|
||||
protected AprilFoolsManager(JavaPlugin plugin, CoreClientManager clientManager, DisguiseManager disguiseManager)
|
||||
{
|
||||
super("April Fools", plugin);
|
||||
@ -47,6 +43,16 @@ public class AprilFoolsManager extends MiniPlugin
|
||||
Instance = new AprilFoolsManager(plugin, clientManager, disguiseManager);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateEnabled(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOW)
|
||||
return;
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
_enabled = (c.get(Calendar.MONTH) == Calendar.APRIL && c.get(Calendar.DAY_OF_MONTH) == 1);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void chatAdd(AsyncPlayerChatEvent event)
|
||||
{
|
||||
@ -129,36 +135,23 @@ public class AprilFoolsManager extends MiniPlugin
|
||||
//Disguise
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
//Moo
|
||||
if (_disguiseManager.getDisguise(player) != null)
|
||||
continue;
|
||||
{
|
||||
if (Math.random() > 0.8)
|
||||
{
|
||||
if (_disguiseManager.getDisguise(player) instanceof DisguiseCow)
|
||||
{
|
||||
player.getWorld().playSound(player.getLocation(), Sound.COW_IDLE, (float)Math.random() + 0.5f, (float)Math.random() + 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Disguise
|
||||
DisguiseCow disguise = new DisguiseCow(player);
|
||||
disguise.setName(getName(player), _clientManager.Get(player).GetRank());
|
||||
disguise.setCustomNameVisible(true);
|
||||
_disguiseManager.disguise(disguise);
|
||||
|
||||
_disguised.add(player);
|
||||
}
|
||||
|
||||
//Moo
|
||||
Iterator<Player> disguiseIter = _disguised.iterator();
|
||||
while (disguiseIter.hasNext())
|
||||
{
|
||||
Player player = disguiseIter.next();
|
||||
|
||||
if (!player.isValid() || !player.isOnline() ||
|
||||
_disguiseManager.getDisguise(player) == null ||
|
||||
!(_disguiseManager.getDisguise(player) instanceof DisguiseCow))
|
||||
{
|
||||
disguiseIter.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Math.random() > 0.8)
|
||||
{
|
||||
player.getWorld().playSound(player.getLocation(), Sound.COW_IDLE, (float)Math.random() + 0.5f, (float)Math.random() + 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,11 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.disguise.disguises.DisguisePig;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
@ -65,7 +67,7 @@ public class KitMamaPig extends Kit
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
UtilPlayer.sendPacket(player, new PacketPlayOutEntityDestroy(new int[] { pig.getEntityId() }));
|
||||
@ -73,20 +75,24 @@ public class KitMamaPig extends Kit
|
||||
}, 2);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void damageTransfer(CustomDamageEvent event)
|
||||
{
|
||||
System.out.println("A");
|
||||
if (event.IsCancelled())
|
||||
return;
|
||||
|
||||
System.out.println("B");
|
||||
if (!(event.GetDamageeEntity() instanceof Pig))
|
||||
return;
|
||||
|
||||
System.out.println("C");
|
||||
Pig pig = (Pig)event.GetDamageeEntity();
|
||||
|
||||
if (pig.getVehicle() == null || !(pig.getPassenger() instanceof LivingEntity))
|
||||
return;
|
||||
|
||||
event.setDamagee((LivingEntity)pig.getVehicle());
|
||||
System.out.println("D");
|
||||
event.SetCancelled("Pig Damage");
|
||||
|
||||
Manager.GetDamage().NewDamageEvent((LivingEntity)pig.getVehicle(), event.GetDamagerEntity(true), event.GetProjectile(), event.GetCause(),
|
||||
event.GetDamage(), event.IsKnockback(), event.IgnoreRate(), event.IgnoreArmor(), UtilEnt.getName(pig.getVehicle()), event.GetReason());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user