Renamed MobType->CreatureType and MobSpawner->CreatureSpawner.
This is to bring the names in line with the rest of bukkit. Deprecated code has been left in to ensure nothing breaks as a result of refactoring MobType. This will be removed after 1 week, to give plugin devs time to migrate
This commit is contained in:
parent
42def68966
commit
ac68b8594e
54
src/main/java/org/bukkit/block/CreatureSpawner.java
Normal file
54
src/main/java/org/bukkit/block/CreatureSpawner.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package org.bukkit.block;
|
||||||
|
|
||||||
|
import org.bukkit.entity.CreatureType;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a creature spawner.
|
||||||
|
*
|
||||||
|
* @author sk89q
|
||||||
|
* @author Cogito
|
||||||
|
*/
|
||||||
|
public interface CreatureSpawner extends BlockState {
|
||||||
|
/**
|
||||||
|
* Get the spawner's creature type.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public CreatureType getCreatureType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the spawner creature type.
|
||||||
|
*
|
||||||
|
* @param mobType
|
||||||
|
*/
|
||||||
|
public void setCreatureType(CreatureType creatureType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the spawner's creature type.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getCreatureTypeId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the spawner mob type.
|
||||||
|
*
|
||||||
|
* @param creatureType
|
||||||
|
*/
|
||||||
|
public void setCreatureTypeId(String creatureType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the spawner's delay.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getDelay();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the spawner's delay.
|
||||||
|
*
|
||||||
|
* @param delay
|
||||||
|
*/
|
||||||
|
public void setDelay(int delay);
|
||||||
|
}
|
@ -6,6 +6,8 @@ import org.bukkit.entity.MobType;
|
|||||||
* Represents a mob spawner.
|
* Represents a mob spawner.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public interface MobSpawner extends BlockState {
|
public interface MobSpawner extends BlockState {
|
||||||
/**
|
/**
|
||||||
|
42
src/main/java/org/bukkit/entity/CreatureType.java
Normal file
42
src/main/java/org/bukkit/entity/CreatureType.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package org.bukkit.entity;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public enum CreatureType {
|
||||||
|
CHICKEN("Chicken"),
|
||||||
|
COW("Cow"),
|
||||||
|
CREEPER("Creeper"),
|
||||||
|
GHAST("Ghast"),
|
||||||
|
PIG("Pig"),
|
||||||
|
PIG_ZOMBIE("PigZombie"),
|
||||||
|
SHEEP("Sheep"),
|
||||||
|
SKELETON("Skeleton"),
|
||||||
|
SPIDER("Spider"),
|
||||||
|
ZOMBIE("Zombie"),
|
||||||
|
SQUID("Squid");
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private static final Map<String, CreatureType> mapping
|
||||||
|
= new HashMap<String, CreatureType>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (CreatureType type : EnumSet.allOf(CreatureType.class)) {
|
||||||
|
mapping.put(type.name, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CreatureType(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CreatureType fromName(String name) {
|
||||||
|
return mapping.get(name);
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,10 @@ package org.bukkit.entity;
|
|||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
/**
|
||||||
|
* @deprecated Should be using CreatureType
|
||||||
|
*
|
||||||
|
*/
|
||||||
public enum MobType {
|
public enum MobType {
|
||||||
CHICKEN("Chicken"),
|
CHICKEN("Chicken"),
|
||||||
COW("Cow"),
|
COW("Cow"),
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.bukkit.event.player;
|
package org.bukkit.event.player;
|
||||||
|
|
||||||
|
import org.bukkit.entity.CreatureType;
|
||||||
import org.bukkit.entity.Egg;
|
import org.bukkit.entity.Egg;
|
||||||
import org.bukkit.entity.MobType;
|
import org.bukkit.entity.MobType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -13,10 +14,10 @@ import org.bukkit.entity.Player;
|
|||||||
public class PlayerEggThrowEvent extends PlayerEvent {
|
public class PlayerEggThrowEvent extends PlayerEvent {
|
||||||
private Egg egg;
|
private Egg egg;
|
||||||
private boolean hatching;
|
private boolean hatching;
|
||||||
private MobType hatchType;
|
private CreatureType hatchType;
|
||||||
private byte numHatches;
|
private byte numHatches;
|
||||||
|
|
||||||
public PlayerEggThrowEvent(Type type, Player player, Egg egg, boolean hatching, byte numHatches, MobType hatchType) {
|
public PlayerEggThrowEvent(Type type, Player player, Egg egg, boolean hatching, byte numHatches, CreatureType hatchType) {
|
||||||
super(type, player);
|
super(type, player);
|
||||||
this.egg = egg;
|
this.egg = egg;
|
||||||
this.hatching = hatching;
|
this.hatching = hatching;
|
||||||
@ -24,6 +25,13 @@ public class PlayerEggThrowEvent extends PlayerEvent {
|
|||||||
this.hatchType = hatchType;
|
this.hatchType = hatchType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlayerEggThrowEvent(Type type, Player player, Egg egg, boolean hatching, byte numHatches, MobType hatchType) {
|
||||||
|
super(type, player);
|
||||||
|
this.egg = egg;
|
||||||
|
this.hatching = hatching;
|
||||||
|
this.numHatches = numHatches;
|
||||||
|
this.hatchType = CreatureType.fromName(hatchType.getName());
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Get the egg.
|
* Get the egg.
|
||||||
*
|
*
|
||||||
@ -59,7 +67,7 @@ public class PlayerEggThrowEvent extends PlayerEvent {
|
|||||||
* @return The type of the mob being hatched by the egg
|
* @return The type of the mob being hatched by the egg
|
||||||
*/
|
*/
|
||||||
public MobType getHatchType() {
|
public MobType getHatchType() {
|
||||||
return hatchType;
|
return MobType.fromName(hatchType.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,10 +75,21 @@ public class PlayerEggThrowEvent extends PlayerEvent {
|
|||||||
*
|
*
|
||||||
* @param hatchType The type of the mob being hatched by the egg
|
* @param hatchType The type of the mob being hatched by the egg
|
||||||
*/
|
*/
|
||||||
public void setHatchType(MobType hatchType) {
|
public void setHatchType(CreatureType hatchType) {
|
||||||
this.hatchType = hatchType;
|
this.hatchType = hatchType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the type of mob being hatched by the egg
|
||||||
|
*
|
||||||
|
* @param hatchType The type of the mob being hatched by the egg
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
public void setHatchType(MobType hatchType) {
|
||||||
|
this.hatchType = CreatureType.fromName(hatchType.getName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of mob hatches from the egg. By default the number
|
* Get the number of mob hatches from the egg. By default the number
|
||||||
* will be he number the server would've done
|
* will be he number the server would've done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user