mirror of
https://github.com/songoda/EpicBosses.git
synced 2024-11-13 21:35:13 +01:00
Converted to Core versioning system.
This commit is contained in:
parent
6135f9c257
commit
22d58040f2
@ -1,6 +1,7 @@
|
||||
package com.songoda.epicbosses.panel.skills.custom;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.EpicBosses;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
@ -11,7 +12,6 @@ import com.songoda.epicbosses.skills.types.PotionSkillElement;
|
||||
import com.songoda.epicbosses.utils.NumberUtils;
|
||||
import com.songoda.epicbosses.utils.ServerUtils;
|
||||
import com.songoda.epicbosses.utils.StringUtils;
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.epicbosses.utils.itemstack.ItemStackUtils;
|
||||
import com.songoda.epicbosses.utils.panel.Panel;
|
||||
import com.songoda.epicbosses.utils.panel.base.handlers.VariablePanelHandler;
|
||||
@ -110,7 +110,7 @@ public class PotionSkillEditorPanel extends VariablePanelHandler<Skill> {
|
||||
ItemStack itemStack = new ItemStack(Material.POTION);
|
||||
PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
|
||||
|
||||
if (new VersionHandler().getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1)) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
|
||||
PotionType potionType = PotionType.getByEffect(PotionEffectType.BLINDNESS);
|
||||
|
||||
if (potionType == null) potionType = PotionType.WATER;
|
||||
|
@ -1,19 +1,18 @@
|
||||
package com.songoda.epicbosses.panel.skills.custom.potions;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.EpicBosses;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.utils.PotionEffectFinder;
|
||||
import com.songoda.epicbosses.utils.ServerUtils;
|
||||
import com.songoda.epicbosses.utils.StringUtils;
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.epicbosses.utils.itemstack.ItemStackUtils;
|
||||
import com.songoda.epicbosses.utils.panel.Panel;
|
||||
import com.songoda.epicbosses.utils.panel.base.handlers.SubVariablePanelHandler;
|
||||
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
|
||||
import com.songoda.epicbosses.utils.potion.PotionEffectConverter;
|
||||
import com.songoda.epicbosses.utils.potion.holder.PotionEffectHolder;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -78,13 +77,14 @@ public class PotionEffectTypeEditorPanel extends SubVariablePanelHandler<Skill,
|
||||
|
||||
ServerUtils.get().runTaskAsync(() -> panel.loadPage(requestedPage, ((slot, realisticSlot) -> {
|
||||
if (slot >= potionEffectTypes.size()) {
|
||||
panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {});
|
||||
panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {
|
||||
});
|
||||
} else {
|
||||
PotionEffectType potionEffectType = potionEffectTypes.get(slot);
|
||||
ItemStack itemStack = new ItemStack(Material.POTION);
|
||||
PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
|
||||
|
||||
if (new VersionHandler().getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1)) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
|
||||
PotionType potionType = PotionType.getByEffect(potionEffectType);
|
||||
|
||||
if (potionType == null) potionType = PotionType.WATER;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.songoda.epicbosses.skills.custom;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.EpicBosses;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
@ -83,8 +85,8 @@ public class Cage extends CustomSkillHandler {
|
||||
@Override
|
||||
public List<ICustomSettingAction> getOtherSkillDataActions(Skill skill, CustomSkillElement customSkillElement) {
|
||||
List<ICustomSettingAction> clickActions = new ArrayList<>();
|
||||
ItemStack clickStack = new ItemStack(versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1) ? Material.STONE_PRESSURE_PLATE : Material.valueOf("STONE_PLATE"));
|
||||
ItemStack duration = new ItemStack(versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1) ? Material.CLOCK : Material.valueOf("WATCH"));
|
||||
ItemStack clickStack = CompatibleMaterial.STONE_PRESSURE_PLATE.getItem();
|
||||
ItemStack duration = CompatibleMaterial.CLOCK.getItem();
|
||||
ClickAction flatAction = (event -> this.flatTypeEditor.openFor((Player) event.getWhoClicked(), skill, customSkillElement));
|
||||
ClickAction wallAction = (event -> this.wallTypeEditor.openFor((Player) event.getWhoClicked(), skill, customSkillElement));
|
||||
ClickAction insideAction = (event -> this.insideTypeEditor.openFor((Player) event.getWhoClicked(), skill, customSkillElement));
|
||||
@ -140,7 +142,7 @@ public class Cage extends CustomSkillHandler {
|
||||
BlockState oldState = cageLocationData.getOldBlockState();
|
||||
|
||||
if(oldState != null) {
|
||||
if (versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1)) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
|
||||
location.getBlock().setBlockData(oldState.getBlockData());
|
||||
} else {
|
||||
if (setBlockDataMethod == null) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.epicbosses.skills.custom;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.epicbosses.EpicBosses;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
@ -12,9 +13,7 @@ import com.songoda.epicbosses.skills.interfaces.IOtherSkillDataElement;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.NumberUtils;
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.epicbosses.utils.panel.base.ClickAction;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -31,8 +30,6 @@ import java.util.List;
|
||||
*/
|
||||
public class Minions extends CustomSkillHandler {
|
||||
|
||||
private static final VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
private EpicBosses plugin;
|
||||
|
||||
public Minions(EpicBosses plugin) {
|
||||
@ -54,7 +51,7 @@ public class Minions extends CustomSkillHandler {
|
||||
List<ICustomSettingAction> clickActions = new ArrayList<>();
|
||||
|
||||
clickActions.add(BossSkillManager.createCustomSkillAction("Amount Editor", getAmountCurrent(customSkillElement), new ItemStack(Material.REDSTONE), getAmountAction(skill, customSkillElement)));
|
||||
clickActions.add(BossSkillManager.createCustomSkillAction("Minion to Spawn Editor", getMinionToSpawnCurrent(customSkillElement), new ItemStack(versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1) ? Material.CREEPER_SPAWN_EGG : Material.valueOf("MONSTER_EGG")), getMinionToSpawnAction(skill, customSkillElement)));
|
||||
clickActions.add(BossSkillManager.createCustomSkillAction("Minion to Spawn Editor", getMinionToSpawnCurrent(customSkillElement), CompatibleMaterial.CREEPER_SPAWN_EGG.getItem(), getMinionToSpawnAction(skill, customSkillElement)));
|
||||
|
||||
return clickActions;
|
||||
}
|
||||
|
@ -1,66 +0,0 @@
|
||||
package com.songoda.epicbosses.utils;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 27-Jun-18
|
||||
*/
|
||||
public enum Versions {
|
||||
|
||||
v1_7_R3(1, "1.7.9"),
|
||||
v1_7_R4(2, "1.7.10"),
|
||||
v1_8_R1(3, "1.8"),
|
||||
v1_8_R2(4, "1.8.3"),
|
||||
v1_8_R3(5, "1.8.9"),
|
||||
v1_9_R1(6, "1.9"),
|
||||
v1_9_R2(7, "1.9.4"),
|
||||
v1_10_R1(8, "1.10"),
|
||||
v1_11_R1(9, "1.11.2"),
|
||||
v1_12_R1(10, "1.12.1"),
|
||||
v1_13_R1(11, "1.13"),
|
||||
v1_13_R2(12, "1.13.2"),
|
||||
v1_14_R1(13, "1.14");
|
||||
|
||||
private String displayVersion, bukkitVersion;
|
||||
private int weight;
|
||||
|
||||
Versions(int weight, String displayVersion) {
|
||||
this.weight = weight;
|
||||
this.displayVersion = displayVersion;
|
||||
this.bukkitVersion = name();
|
||||
}
|
||||
|
||||
public boolean isLessThan(Versions input) {
|
||||
return this.weight < input.weight;
|
||||
}
|
||||
|
||||
public boolean isLessThanOrEqualTo(Versions input) {
|
||||
return this.weight <= input.weight;
|
||||
}
|
||||
|
||||
public boolean isHigherThanOrEqualTo(Versions input) {
|
||||
return this.weight >= input.weight;
|
||||
}
|
||||
|
||||
public boolean isHigherThan(Versions input) {
|
||||
return this.weight > input.weight;
|
||||
}
|
||||
|
||||
public static Versions getVersion(String input) {
|
||||
for(Versions versions : values()) {
|
||||
if(versions.getBukkitVersion().equalsIgnoreCase(input)) {
|
||||
return versions;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getDisplayVersion() {
|
||||
return this.displayVersion;
|
||||
}
|
||||
|
||||
public String getBukkitVersion() {
|
||||
return this.bukkitVersion;
|
||||
}
|
||||
}
|
@ -1,19 +1,16 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public class CatHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_14_R1)) {
|
||||
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_14)) {
|
||||
throw new NullPointerException("This feature is only implemented in version 1.14 and above of Minecraft.");
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
@ -13,7 +13,7 @@ public class DolphinHandler implements ICustomEntityHandler {
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_13_R1)) {
|
||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
|
||||
throw new NullPointerException("This feature is only implemented in version 1.13 and above of Minecraft.");
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Horse;
|
||||
@ -15,17 +14,13 @@ import org.bukkit.entity.LivingEntity;
|
||||
*/
|
||||
public class DonkeyHorseHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_11_R1)) {
|
||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_11))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.11 and above of Minecraft.");
|
||||
}
|
||||
|
||||
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_11_R1)) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11))
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.DONKEY);
|
||||
}
|
||||
|
||||
Horse horse = (Horse) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.HORSE);
|
||||
horse.setVariant(Horse.Variant.DONKEY);
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
@ -13,7 +13,7 @@ public class DrownedHandler implements ICustomEntityHandler {
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_13_R1)) {
|
||||
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
|
||||
throw new NullPointerException("This feature is only implemented in version 1.13 and above of Minecraft.");
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
@ -18,9 +18,8 @@ public class ElderGuardianHandler implements ICustomEntityHandler {
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThanOrEqualTo(Versions.v1_7_R4)) {
|
||||
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_8))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.8 and above of Minecraft.");
|
||||
}
|
||||
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.ELDER_GUARDIAN);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
@ -18,9 +18,8 @@ public class EndermiteHandler implements ICustomEntityHandler {
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_8_R1)) {
|
||||
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_8))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.8 and above of Minecraft.");
|
||||
}
|
||||
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.ENDERMITE);
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -14,11 +13,9 @@ import org.bukkit.entity.LivingEntity;
|
||||
*/
|
||||
public class EvokerHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_11_R1)) {
|
||||
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_11)) {
|
||||
throw new NullPointerException("This feature is only implemented in version 1.11 and above of Minecraft.");
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
@ -13,9 +13,8 @@ public class FishHandler implements ICustomEntityHandler {
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_13_R1)) {
|
||||
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_13))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.13 and above of Minecraft.");
|
||||
}
|
||||
|
||||
|
||||
EntityType fishEntityType;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
@ -13,9 +13,8 @@ public class FoxHandler implements ICustomEntityHandler {
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_14_R1)) {
|
||||
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_14))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.14 and above of Minecraft.");
|
||||
}
|
||||
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.FOX);
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -14,13 +13,10 @@ import org.bukkit.entity.LivingEntity;
|
||||
*/
|
||||
public class GuardianHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_8_R1)) {
|
||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_8))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.8 and above of Minecraft.");
|
||||
}
|
||||
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.GUARDIAN);
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -14,13 +13,10 @@ import org.bukkit.entity.LivingEntity;
|
||||
*/
|
||||
public class HuskZombieHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_10_R1)) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_10))
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.HUSK);
|
||||
}
|
||||
|
||||
throw new NullPointerException("This feature is only implemented in version 1.10 and above of Minecraft.");
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -15,13 +14,10 @@ import org.bukkit.entity.LivingEntity;
|
||||
*/
|
||||
public class IllusionerHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if (this.versionHandler.getVersion().isLessThan(Versions.v1_11_R1)) {
|
||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_11))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.11 and above of Minecraft.");
|
||||
}
|
||||
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.ILLUSIONER);
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -15,13 +14,10 @@ import org.bukkit.entity.Rabbit;
|
||||
*/
|
||||
public class KillerBunnyHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThanOrEqualTo(Versions.v1_7_R4)) {
|
||||
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_8))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.8 and above of Minecraft.");
|
||||
}
|
||||
|
||||
Rabbit rabbit = (Rabbit) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.RABBIT);
|
||||
rabbit.setRabbitType(Rabbit.Type.THE_KILLER_BUNNY);
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Horse;
|
||||
@ -15,15 +14,12 @@ import org.bukkit.entity.LivingEntity;
|
||||
*/
|
||||
public class LlamaHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_11_R1)) {
|
||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_11))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.11 and above of Minecraft.");
|
||||
}
|
||||
|
||||
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_11_R1)) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.LLAMA);
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Horse;
|
||||
@ -15,17 +14,14 @@ import org.bukkit.entity.LivingEntity;
|
||||
*/
|
||||
public class MuleHorseHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_11_R1)) {
|
||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_11))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.11 and above of Minecraft.");
|
||||
}
|
||||
|
||||
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_11_R1)) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11))
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.MULE);
|
||||
}
|
||||
|
||||
Horse horse = (Horse) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.HORSE);
|
||||
horse.setVariant(Horse.Variant.MULE);
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
@ -13,9 +13,8 @@ public class PandaHandler implements ICustomEntityHandler {
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_14_R1)) {
|
||||
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_14))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.14 and above of Minecraft.");
|
||||
}
|
||||
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.PANDA);
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -14,13 +13,10 @@ import org.bukkit.entity.LivingEntity;
|
||||
*/
|
||||
public class ParrotHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_12_R1)) {
|
||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_12))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.12 and above of Minecraft.");
|
||||
}
|
||||
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.PARROT);
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -10,13 +9,10 @@ import org.bukkit.entity.Phantom;
|
||||
|
||||
public class PhantomHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_13_R1)) {
|
||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.13 and above of Minecraft.");
|
||||
}
|
||||
|
||||
int size = 4;
|
||||
if (entityType.contains(":")) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
@ -13,9 +13,8 @@ public class PillagerHandler implements ICustomEntityHandler {
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_14_R1)) {
|
||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_14))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.14 and above of Minecraft.");
|
||||
}
|
||||
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.PILLAGER);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
@ -14,13 +14,10 @@ import org.bukkit.entity.LivingEntity;
|
||||
*/
|
||||
public class PolarBearHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_10_R1)) {
|
||||
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_10))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.10 and above of Minecraft.");
|
||||
}
|
||||
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.POLAR_BEAR);
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -14,11 +13,10 @@ import org.bukkit.entity.LivingEntity;
|
||||
*/
|
||||
public class RabbitHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_8_R1)) {
|
||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_8)) {
|
||||
throw new NullPointerException("This feature is only implemented in version 1.8 and above of Minecraft.");
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
@ -9,11 +9,10 @@ import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public class RavagerHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_14_R1)) {
|
||||
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_14)) {
|
||||
throw new NullPointerException("This feature is only implemented in version 1.14 and above of Minecraft.");
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
@ -18,7 +18,7 @@ public class ShulkerHandler implements ICustomEntityHandler {
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_9_R1)) {
|
||||
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_9)) {
|
||||
throw new NullPointerException("This feature is only implemented in version 1.9 and above of Minecraft.");
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Horse;
|
||||
@ -15,13 +14,10 @@ import org.bukkit.entity.LivingEntity;
|
||||
*/
|
||||
public class SkeletonHorseHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_11_R1)) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11))
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.SKELETON_HORSE);
|
||||
}
|
||||
|
||||
Horse horse = (Horse) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.HORSE);
|
||||
horse.setVariant(Horse.Variant.SKELETON_HORSE);
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
@ -15,17 +15,13 @@ import org.bukkit.entity.Skeleton;
|
||||
*/
|
||||
public class StraySkeletonHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThanOrEqualTo(Versions.v1_9_R2)) {
|
||||
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_10))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.10 and above of Minecraft.");
|
||||
}
|
||||
|
||||
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_11_R1)) {
|
||||
if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_10))
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.STRAY);
|
||||
}
|
||||
|
||||
Skeleton skeleton = (Skeleton) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.SKELETON);
|
||||
skeleton.setSkeletonType(Skeleton.SkeletonType.STRAY);
|
||||
|
@ -1,21 +1,17 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public class TraderLlamaHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_14_R1)) {
|
||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_12))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.12 and above of Minecraft.");
|
||||
}
|
||||
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.TRADER_LLAMA);
|
||||
}
|
||||
|
@ -1,21 +1,17 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public class TurtleHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_13_R1)) {
|
||||
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_13))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.13 and above of Minecraft.");
|
||||
}
|
||||
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.TURTLE);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
@ -14,13 +14,10 @@ import org.bukkit.entity.LivingEntity;
|
||||
*/
|
||||
public class VexHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_11_R1)) {
|
||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_11))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.11 and above of Minecraft.");
|
||||
}
|
||||
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.VEX);
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -14,13 +13,10 @@ import org.bukkit.entity.LivingEntity;
|
||||
*/
|
||||
public class VindicatorHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_11_R1)) {
|
||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_11))
|
||||
throw new NullPointerException("This feature is only implemented in version 1.11 and above of Minecraft.");
|
||||
}
|
||||
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.VINDICATOR);
|
||||
}
|
||||
|
@ -1,19 +1,16 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public class WanderingTraderHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isLessThan(Versions.v1_14_R1)) {
|
||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_14)) {
|
||||
throw new NullPointerException("This feature is only implemented in version 1.14 and above of Minecraft.");
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
@ -19,7 +19,7 @@ public class WitherSkeletonHandler implements ICustomEntityHandler {
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_11_R1)) {
|
||||
if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.WITHER_SKELETON);
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Horse;
|
||||
@ -15,13 +14,10 @@ import org.bukkit.entity.LivingEntity;
|
||||
*/
|
||||
public class ZombieHorseHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_11_R1)) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11))
|
||||
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.ZOMBIE_HORSE);
|
||||
}
|
||||
|
||||
Horse horse = (Horse) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.HORSE);
|
||||
horse.setVariant(Horse.Variant.UNDEAD_HORSE);
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.songoda.epicbosses.utils.entity.handlers;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.entity.ICustomEntityHandler;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
@ -13,11 +12,9 @@ import org.bukkit.entity.*;
|
||||
*/
|
||||
public class ZombieVillagerHandler implements ICustomEntityHandler {
|
||||
|
||||
private VersionHandler versionHandler = new VersionHandler();
|
||||
|
||||
@Override
|
||||
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
|
||||
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_11_R1)) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
|
||||
ZombieVillager zombieVillager = (ZombieVillager) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.ZOMBIE_VILLAGER);
|
||||
String[] split = entityType.split(":");
|
||||
|
||||
|
@ -1,13 +1,8 @@
|
||||
package com.songoda.epicbosses.utils.file;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
@ -32,15 +27,8 @@ public abstract class FileHandler<T> implements IFileHandler<T> {
|
||||
if (!this.file.exists()) {
|
||||
if (this.saveResource) {
|
||||
String name = this.file.getName();
|
||||
String folder = new VersionHandler().getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1) ? "/current/" : "/legacy/";
|
||||
String path = folder + name;
|
||||
|
||||
try (InputStream resourceStream = this.getClass().getResourceAsStream(path)) {
|
||||
Files.copy(resourceStream, new File(this.javaPlugin.getDataFolder(), name).toPath());
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
javaPlugin.saveResource(name, false);
|
||||
}
|
||||
|
||||
FileUtils.get().createFile(this.file);
|
||||
|
@ -1,14 +1,9 @@
|
||||
package com.songoda.epicbosses.utils.file;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.songoda.epicbosses.utils.itemstack;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicbosses.utils.NumberUtils;
|
||||
import com.songoda.epicbosses.utils.ServerUtils;
|
||||
import com.songoda.epicbosses.utils.StringUtils;
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.epicbosses.utils.itemstack.enchants.GlowEnchant;
|
||||
import com.songoda.epicbosses.utils.itemstack.holder.ItemStackHolder;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
@ -33,7 +34,7 @@ public class ItemStackUtils {
|
||||
spawnableEntityMaterials = new HashMap<>();
|
||||
spawnableEntityIds = new HashMap<>();
|
||||
|
||||
boolean isLegacy = versionHandler.getVersion().isLessThanOrEqualTo(Versions.v1_12_R1);
|
||||
boolean isLegacy = ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_12);
|
||||
|
||||
Arrays.stream(EntityType.values()).filter(EntityType::isSpawnable).forEach(entityType -> {
|
||||
if (isLegacy) {
|
||||
@ -48,7 +49,7 @@ public class ItemStackUtils {
|
||||
}
|
||||
|
||||
public static List<EntityType> getSpawnableEntityTypes() {
|
||||
if (versionHandler.getVersion().isLessThanOrEqualTo(Versions.v1_12_R1)) {
|
||||
if (ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_12)) {
|
||||
return new ArrayList<>(spawnableEntityIds.keySet());
|
||||
} else {
|
||||
return new ArrayList<>(spawnableEntityMaterials.keySet());
|
||||
@ -59,7 +60,7 @@ public class ItemStackUtils {
|
||||
if (!entityType.isSpawnable())
|
||||
return new ItemStack(Material.AIR);
|
||||
|
||||
if (versionHandler.getVersion().isLessThanOrEqualTo(Versions.v1_12_R1)) {
|
||||
if (ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_12)) {
|
||||
return new ItemStack(Material.valueOf("MONSTER_EGG"), 1, spawnableEntityIds.get(entityType));
|
||||
} else {
|
||||
return new ItemStack(spawnableEntityMaterials.get(entityType));
|
||||
@ -223,7 +224,7 @@ public class ItemStackUtils {
|
||||
itemStack.setDurability(dura);
|
||||
}
|
||||
|
||||
if(configurationSection.contains("owner") && itemStack.getType() == MaterialUtils.getSkullMaterial()) {
|
||||
if (configurationSection.contains("owner") && itemStack.getType() == CompatibleMaterial.PLAYER_HEAD.getMaterial()) {
|
||||
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
|
||||
|
||||
skullMeta.setOwner(owner);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.songoda.epicbosses.utils.itemstack;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||
import org.bukkit.Material;
|
||||
|
||||
@ -9,7 +8,6 @@ import java.util.Map;
|
||||
|
||||
public class MaterialUtils {
|
||||
|
||||
private static final VersionHandler versionHandler = new VersionHandler();
|
||||
private static Map<Integer, Material> materialIdMap;
|
||||
|
||||
static {
|
||||
@ -26,12 +24,4 @@ public class MaterialUtils {
|
||||
return materialIdMap.get(id);
|
||||
}
|
||||
|
||||
public static Material getSkullMaterial() {
|
||||
if (versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1)) {
|
||||
return Material.PLAYER_HEAD;
|
||||
} else {
|
||||
return Material.getMaterial("SKULL_ITEM");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.songoda.epicbosses.utils.version;
|
||||
|
||||
import com.songoda.epicbosses.utils.Versions;
|
||||
import org.bukkit.Bukkit;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -12,22 +11,12 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class VersionHandler {
|
||||
|
||||
private Versions version;
|
||||
|
||||
public VersionHandler() {
|
||||
String v = Bukkit.getServer().getClass().getPackage().getName();
|
||||
|
||||
v = v.substring(v.lastIndexOf(".") + 1);
|
||||
|
||||
this.version = Versions.getVersion(v);
|
||||
}
|
||||
|
||||
public boolean canUseOffHand() {
|
||||
return this.version.isHigherThanOrEqualTo(Versions.v1_9_R1);
|
||||
return ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9);
|
||||
}
|
||||
|
||||
public ItemStack getItemInHand(HumanEntity humanEntity) {
|
||||
if(this.version.isLessThanOrEqualTo(Versions.v1_8_R3)) {
|
||||
if (ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_8)) {
|
||||
return humanEntity.getItemInHand();
|
||||
} else {
|
||||
return humanEntity.getInventory().getItemInMainHand();
|
||||
@ -35,14 +24,10 @@ public class VersionHandler {
|
||||
}
|
||||
|
||||
public void setItemInHand(HumanEntity humanEntity, ItemStack itemStack) {
|
||||
if(this.version.isLessThanOrEqualTo(Versions.v1_8_R3)) {
|
||||
if (ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_8)) {
|
||||
humanEntity.setItemInHand(itemStack);
|
||||
} else {
|
||||
humanEntity.getInventory().setItemInMainHand(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
public Versions getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user