Add names to class pets.

This commit adds custom names to class pets in the form `<player name>'s pet`. This should help players more easily distinguish between pets and hostile mobs.
This commit is contained in:
Andreas Troelsen 2019-08-05 14:34:05 +02:00
parent c6a695e2c3
commit bbd70d0692
2 changed files with 3 additions and 0 deletions

View File

@ -14,6 +14,7 @@ These changes will (most likely) be included in the next version.
- Extended and upgraded potions are now supported in the item syntax by prepending `long_` or `strong_` to the data portion of a potion item (e.g. `potion:strong_instant_heal:1` will yield a Potion of Healing II). Check the wiki for details.
- MobArena now has basic tab completion support for most of the commands that take arguments.
- The `pet-items` node in `global-settings` now supports any living entity as a pet (but only tameable entities will _behave_ as pets). This should allow 1.14 servers to replace `ocelot` with `cat` in their `pet-items` node to get cat pets working again.
- Pets now have custom names that denote who their owner is, e.g. "garbagemule's pet".
- Tridents and crossbows are now considered weapons with regards to the `unbreakable-weapons` flag. All class items that have durability now have their unbreakable flag set to true unless the `unbreakable-weapons` and/or `unbreakable-armor` flags are set to `false`.
- Leaderboards now work again on servers running Minecraft 1.14+.
- Class chests (non-linked) now work again on servers running Minecraft 1.14+.

View File

@ -57,6 +57,8 @@ public class SpawnsPets {
int amount = inv.getItem(index).getAmount();
for (int i = 0; i < amount; i++) {
Entity pet = arena.getWorld().spawn(player.getLocation(), entity.getEntityClass());
pet.setCustomName(player.getDisplayName() + "'s pet");
pet.setCustomNameVisible(true);
if (pet instanceof Tameable) {
Tameable tameable = (Tameable) pet;
tameable.setTamed(true);