Bukkit  1.4.7-R1.0
 All Classes Namespaces Files Functions Variables Enumerator Pages
PlayerEggThrowEvent.java
Go to the documentation of this file.
1 package org.bukkit.event.player;
2 
3 import org.bukkit.entity.CreatureType;
4 import org.bukkit.entity.Egg;
5 import org.bukkit.entity.EntityType;
6 import org.bukkit.entity.Player;
7 import org.bukkit.event.HandlerList;
8 
12 public class PlayerEggThrowEvent extends PlayerEvent {
13  private static final HandlerList handlers = new HandlerList();
14  private final Egg egg;
15  private boolean hatching;
16  private EntityType hatchType;
17  private byte numHatches;
18 
19  public PlayerEggThrowEvent(final Player player, final Egg egg, final boolean hatching, final byte numHatches, final EntityType hatchingType) {
20  super(player);
21  this.egg = egg;
22  this.hatching = hatching;
23  this.numHatches = numHatches;
24  this.hatchType = hatchingType;
25  }
26 
27  @Deprecated
28  public PlayerEggThrowEvent(Player player, Egg egg, boolean hatching, byte numHatches, CreatureType hatchingType) {
29  this(player, egg, hatching, numHatches, hatchingType.toEntityType());
30  }
31 
37  public Egg getEgg() {
38  return egg;
39  }
40 
47  public boolean isHatching() {
48  return hatching;
49  }
50 
57  public void setHatching(boolean hatching) {
58  this.hatching = hatching;
59  }
60 
67  @Deprecated
69  return CreatureType.fromEntityType(hatchType);
70  }
71 
78  return hatchType;
79  }
80 
87  @Deprecated
88  public void setHatchType(CreatureType hatchType) {
89  this.hatchType = hatchType.toEntityType();
90  }
91 
97  public void setHatchingType(EntityType hatchType) {
98  if(!hatchType.isSpawnable()) throw new IllegalArgumentException("Can't spawn that entity type from an egg!");
99  this.hatchType = hatchType;
100  }
101 
112  public byte getNumHatches() {
113  return numHatches;
114  }
115 
124  public void setNumHatches(byte numHatches) {
125  this.numHatches = numHatches;
126  }
127 
128  @Override
130  return handlers;
131  }
132 
133  public static HandlerList getHandlerList() {
134  return handlers;
135  }
136 }