mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 20:00:46 +00:00
Further changes for 1.11 update.
- Dropped usage of deprecated methods for a cleaner future. - Zombies no longer throw errors in SpawnMob due to setVillager(false). - Removed MobData where they have been replaced with actual entities.
This commit is contained in:
parent
8b0659a2b4
commit
944ddf8d70
6 changed files with 14 additions and 35 deletions
|
@ -167,9 +167,9 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb {
|
|||
List<ItemStack> is = new ArrayList<>();
|
||||
|
||||
if (args.length < 1) {
|
||||
is.add(user.getBase().getItemInHand());
|
||||
is.add(user.getItemInHand());
|
||||
} else if (args[0].equalsIgnoreCase("hand")) {
|
||||
is.add(user.getBase().getItemInHand());
|
||||
is.add(user.getItemInHand());
|
||||
} else if (args[0].equalsIgnoreCase("inventory") || args[0].equalsIgnoreCase("invent") || args[0].equalsIgnoreCase("all")) {
|
||||
for (ItemStack stack : user.getBase().getInventory().getContents()) {
|
||||
if (stack == null || stack.getType() == Material.AIR) {
|
||||
|
|
|
@ -29,11 +29,6 @@ public enum MobData {
|
|||
TAME_TAMEABLE("tame", Tameable.class, Data.TAMED, false),
|
||||
RANDOM_SHEEP("random", EntityType.SHEEP, Data.COLORABLE, true),
|
||||
COLORABLE_SHEEP("", StringUtil.joinList(DyeColor.values()).toLowerCase(Locale.ENGLISH), EntityType.SHEEP, Data.COLORABLE, true),
|
||||
DONKEY_HORSE("donkey", EntityType.HORSE, Horse.Variant.DONKEY, true),
|
||||
MULE_HORSE("mule", EntityType.HORSE, Horse.Variant.MULE, true),
|
||||
SKELETON_HORSE("skeleton", EntityType.HORSE, Horse.Variant.SKELETON_HORSE, true),
|
||||
UNDEAD_HORSE("undead", EntityType.HORSE, Horse.Variant.UNDEAD_HORSE, true),
|
||||
ZOMBIE_HORSE("zombie", EntityType.HORSE, Horse.Variant.UNDEAD_HORSE, false),
|
||||
POLKA_HORSE("polka", EntityType.HORSE, Horse.Style.BLACK_DOTS, true),
|
||||
SOOTY_HORSE("sooty", EntityType.HORSE, Horse.Style.BLACK_DOTS, false),
|
||||
BLAZE_HORSE("blaze", EntityType.HORSE, Horse.Style.WHITE, true),
|
||||
|
@ -56,7 +51,6 @@ public enum MobData {
|
|||
DBROWN_HORSE("dbrown", EntityType.HORSE, Horse.Color.DARK_BROWN, false),
|
||||
BAY_HORSE("bay", EntityType.HORSE, Horse.Color.BROWN, true),
|
||||
BROWN_HORSE("brown", EntityType.HORSE, Horse.Color.BROWN, false),
|
||||
CHEST_HORSE("chest", EntityType.HORSE, Data.CHEST, true),
|
||||
SADDLE_HORSE("saddle", EntityType.HORSE, Data.HORSESADDLE, true),
|
||||
GOLD_ARMOR_HORSE("goldarmor", EntityType.HORSE, Material.GOLD_BARDING, true),
|
||||
DIAMOND_ARMOR_HORSE("diamondarmor", EntityType.HORSE, Material.DIAMOND_BARDING, true),
|
||||
|
@ -68,7 +62,6 @@ public enum MobData {
|
|||
TABBY_CAT("tabby", EntityType.OCELOT, Ocelot.Type.RED_CAT, false),
|
||||
BLACK_CAT("black", EntityType.OCELOT, Ocelot.Type.BLACK_CAT, true),
|
||||
TUXEDO_CAT("tuxedo", EntityType.OCELOT, Ocelot.Type.BLACK_CAT, false),
|
||||
VILLAGER_ZOMBIE("villager", EntityType.ZOMBIE.getEntityClass(), Data.VILLAGER, true),
|
||||
BABY_ZOMBIE("baby", EntityType.ZOMBIE.getEntityClass(), Data.BABYZOMBIE, true),
|
||||
ADULT_ZOMBIE("adult", EntityType.ZOMBIE.getEntityClass(), Data.ADULTZOMBIE, true),
|
||||
DIAMOND_SWORD_ZOMBIE("diamondsword", EntityType.ZOMBIE.getEntityClass(), Material.DIAMOND_SWORD, true),
|
||||
|
@ -82,7 +75,6 @@ public enum MobData {
|
|||
STONE_SWORD_SKELETON("stonesword", EntityType.SKELETON, Material.STONE_SWORD, false),
|
||||
SWORD_SKELETON("sword", EntityType.SKELETON, Material.STONE_SWORD, true),
|
||||
BOW_SKELETON("bow", EntityType.SKELETON, Material.BOW, true),
|
||||
WITHER_SKELETON("wither", EntityType.SKELETON, Data.WITHER, true),
|
||||
POWERED_CREEPER("powered", EntityType.CREEPER, Data.ELECTRIFIED, true),
|
||||
ELECTRIC_CREEPER("electric", EntityType.CREEPER, Data.ELECTRIFIED, false),
|
||||
CHARGED_CREEPER("charged", EntityType.CREEPER, Data.ELECTRIFIED, false),
|
||||
|
@ -105,11 +97,9 @@ public enum MobData {
|
|||
CHEST,
|
||||
ADULTZOMBIE,
|
||||
BABYZOMBIE,
|
||||
VILLAGER,
|
||||
HORSESADDLE,
|
||||
PIGSADDLE,
|
||||
ELECTRIFIED,
|
||||
WITHER,
|
||||
ANGRY,
|
||||
TAMED,
|
||||
COLORABLE,
|
||||
|
@ -196,9 +186,6 @@ public enum MobData {
|
|||
((Zombie) spawned).setBaby(false);
|
||||
} else if (this.value.equals(Data.BABYZOMBIE)) {
|
||||
((Zombie) spawned).setBaby(true);
|
||||
} else if (this.value.equals(Data.CHEST)) {
|
||||
((Horse) spawned).setTamed(true);
|
||||
((Horse) spawned).setCarryingChest(true);
|
||||
} else if (this.value.equals(Data.ELECTRIFIED)) {
|
||||
((Creeper) spawned).setPowered(true);
|
||||
} else if (this.value.equals(Data.HORSESADDLE)) {
|
||||
|
@ -212,10 +199,6 @@ public enum MobData {
|
|||
final Tameable tameable = ((Tameable) spawned);
|
||||
tameable.setTamed(true);
|
||||
tameable.setOwner(target);
|
||||
} else if (this.value.equals(Data.VILLAGER)) {
|
||||
((Zombie) spawned).setVillager(this.value.equals(Data.VILLAGER));
|
||||
} else if (this.value.equals(Data.WITHER)) {
|
||||
((Skeleton) spawned).setSkeletonType(Skeleton.SkeletonType.WITHER);
|
||||
} else if (this.value.equals(Data.COLORABLE)) {
|
||||
final String color = rawData.toUpperCase(Locale.ENGLISH);
|
||||
try {
|
||||
|
@ -247,8 +230,6 @@ public enum MobData {
|
|||
((Horse) spawned).setColor((Horse.Color) this.value);
|
||||
} else if (this.value instanceof Horse.Style) {
|
||||
((Horse) spawned).setStyle((Horse.Style) this.value);
|
||||
} else if (this.value instanceof Horse.Variant) {
|
||||
((Horse) spawned).setVariant((Horse.Variant) this.value);
|
||||
} else if (this.value instanceof Ocelot.Type) {
|
||||
((Ocelot) spawned).setCatType((Ocelot.Type) this.value);
|
||||
} else if (this.value instanceof Villager.Profession) {
|
||||
|
@ -259,8 +240,8 @@ public enum MobData {
|
|||
((Horse) spawned).getInventory().setArmor(new ItemStack((Material) this.value, 1));
|
||||
} else if (this.type.equals(EntityType.ZOMBIE.getEntityClass()) || this.type.equals(EntityType.SKELETON)) {
|
||||
final EntityEquipment invent = ((LivingEntity) spawned).getEquipment();
|
||||
invent.setItemInHand(new ItemStack((Material) this.value, 1));
|
||||
invent.setItemInHandDropChance(0.1f);
|
||||
invent.setItemInMainHand(new ItemStack((Material) this.value, 1));
|
||||
invent.setItemInMainHandDropChance(0.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,8 +224,8 @@ public class SpawnMob {
|
|||
private static void defaultMobData(final EntityType type, final Entity spawned) {
|
||||
if (type == EntityType.SKELETON) {
|
||||
final EntityEquipment invent = ((LivingEntity) spawned).getEquipment();
|
||||
invent.setItemInHand(new ItemStack(Material.BOW, 1));
|
||||
invent.setItemInHandDropChance(0.1f);
|
||||
invent.setItemInMainHand(new ItemStack(Material.BOW, 1));
|
||||
invent.setItemInMainHandDropChance(0.1f);
|
||||
|
||||
invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
|
||||
invent.setBootsDropChance(0.0f);
|
||||
|
@ -233,11 +233,10 @@ public class SpawnMob {
|
|||
|
||||
if (type == EntityType.PIG_ZOMBIE) {
|
||||
final PigZombie zombie = ((PigZombie) spawned);
|
||||
zombie.setVillager(false);
|
||||
|
||||
final EntityEquipment invent = zombie.getEquipment();
|
||||
invent.setItemInHand(new ItemStack(Material.GOLD_SWORD, 1));
|
||||
invent.setItemInHandDropChance(0.1f);
|
||||
invent.setItemInMainHand(new ItemStack(Material.GOLD_SWORD, 1));
|
||||
invent.setItemInMainHandDropChance(0.1f);
|
||||
|
||||
invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
|
||||
invent.setBootsDropChance(0.0f);
|
||||
|
@ -245,7 +244,6 @@ public class SpawnMob {
|
|||
|
||||
if (type == EntityType.ZOMBIE) {
|
||||
final Zombie zombie = ((Zombie) spawned);
|
||||
zombie.setVillager(false);
|
||||
|
||||
final EntityEquipment invent = zombie.getEquipment();
|
||||
invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
|
||||
|
|
|
@ -17,7 +17,7 @@ public class Commandbook extends EssentialsCommand {
|
|||
//TODO: Translate this
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
final ItemStack item = user.getBase().getItemInHand();
|
||||
final ItemStack item = user.getItemInHand();
|
||||
final String player = user.getName();
|
||||
if (item.getType() == Material.WRITTEN_BOOK) {
|
||||
BookMeta bmeta = (BookMeta) item.getItemMeta();
|
||||
|
@ -42,7 +42,7 @@ public class Commandbook extends EssentialsCommand {
|
|||
if (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others")) {
|
||||
ItemStack newItem = new ItemStack(Material.BOOK_AND_QUILL, item.getAmount());
|
||||
newItem.setItemMeta(bmeta);
|
||||
user.getBase().setItemInHand(newItem);
|
||||
user.getBase().getInventory().setItemInMainHand(newItem);
|
||||
user.sendMessage(tl("editBookContents"));
|
||||
} else {
|
||||
throw new Exception(tl("denyBookEdit"));
|
||||
|
@ -55,7 +55,7 @@ public class Commandbook extends EssentialsCommand {
|
|||
}
|
||||
ItemStack newItem = new ItemStack(Material.WRITTEN_BOOK, item.getAmount());
|
||||
newItem.setItemMeta(bmeta);
|
||||
user.getBase().setItemInHand(newItem);
|
||||
user.getBase().getInventory().setItemInMainHand(newItem);
|
||||
user.sendMessage(tl("bookLocked"));
|
||||
} else {
|
||||
throw new Exception(tl("holdBook"));
|
||||
|
|
|
@ -25,7 +25,7 @@ public class Commandenchant extends EssentialsCommand {
|
|||
//TODO: Implement charge costs: final Trade charge = new Trade("enchant-" + enchantmentName, ess);
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
final ItemStack stack = user.getBase().getItemInHand();
|
||||
final ItemStack stack = user.getItemInHand();
|
||||
if (stack == null || stack.getType() == Material.AIR) {
|
||||
throw new Exception(tl("nothingInHand"));
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class Commandenchant extends EssentialsCommand {
|
|||
final MetaItemStack metaStack = new MetaItemStack(stack);
|
||||
final Enchantment enchantment = metaStack.getEnchantment(user, args[0]);
|
||||
metaStack.addEnchantment(user.getSource(), allowUnsafe, enchantment, level);
|
||||
user.getBase().getInventory().setItemInHand(metaStack.getItemStack());
|
||||
user.getBase().getInventory().setItemInMainHand(metaStack.getItemStack());
|
||||
|
||||
user.getBase().updateInventory();
|
||||
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
|
||||
|
|
|
@ -26,7 +26,7 @@ public class Commandpotion extends EssentialsCommand {
|
|||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
final ItemStack stack = user.getBase().getItemInHand();
|
||||
final ItemStack stack = user.getItemInHand();
|
||||
|
||||
if (args.length == 0) {
|
||||
final Set<String> potionslist = new TreeSet<>();
|
||||
|
|
Loading…
Reference in a new issue