-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Narimm-patch-1' of https://github.com/Narimm/uSkyBlock-1 …
…into Narimm-Narimm-patch-1
- Loading branch information
Showing
3 changed files
with
45 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
uSkyBlock-Core/src/main/java/us/talabrek/ultimateskyblock/handler/EntitySpawner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package us.talabrek.ultimateskyblock.handler; | ||
|
||
import dk.lockfuglsang.minecraft.reflection.ReflectionUtil; | ||
import org.bukkit.Location; | ||
import org.bukkit.Material; | ||
import org.bukkit.entity.Blaze; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.entity.Skeleton; | ||
import org.bukkit.inventory.ItemStack; | ||
import us.talabrek.ultimateskyblock.util.VersionUtil; | ||
|
||
/** | ||
* Abstraction for spawning entities (cross-version-support) | ||
*/ | ||
public class EntitySpawner { | ||
public Skeleton spawnWitherSkeleton(Location location) { | ||
String craftBukkitVersion = ReflectionUtil.getCraftBukkitVersion(); | ||
VersionUtil.Version version = VersionUtil.getVersion(craftBukkitVersion); | ||
Skeleton mob; | ||
// TODO: R4zorax - 29-12-2016: The deprecated parts might need to be used using reflection *sigh* | ||
if (version.isGTE("1.11")) { | ||
mob = (Skeleton) location.getWorld().spawnEntity(location, EntityType.fromId(5)); | ||
} else { | ||
mob = (Skeleton) location.getWorld().spawnEntity(location, EntityType.SKELETON); | ||
mob.setSkeletonType(Skeleton.SkeletonType.WITHER); | ||
} | ||
mob.getEquipment().setItemInMainHand(new ItemStack(Material.STONE_SWORD, 1)); | ||
return mob; | ||
} | ||
|
||
public Blaze spawnBlaze(Location location) { | ||
return (Blaze) location.getWorld().spawnEntity(location, EntityType.BLAZE); | ||
} | ||
|
||
public Skeleton spawnSkeleton(Location location) { | ||
return (Skeleton) location.getWorld().spawnEntity(location, EntityType.SKELETON); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters