From bbd70d0692d948034472442ba2dd55c01aca0136 Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Mon, 5 Aug 2019 14:34:05 +0200 Subject: [PATCH] Add names to class pets. This commit adds custom names to class pets in the form `'s pet`. This should help players more easily distinguish between pets and hostile mobs. --- changelog.md | 1 + src/main/java/com/garbagemule/MobArena/SpawnsPets.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/changelog.md b/changelog.md index 6821b98..b053e6c 100644 --- a/changelog.md +++ b/changelog.md @@ -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+. diff --git a/src/main/java/com/garbagemule/MobArena/SpawnsPets.java b/src/main/java/com/garbagemule/MobArena/SpawnsPets.java index 7e943a1..7abab72 100644 --- a/src/main/java/com/garbagemule/MobArena/SpawnsPets.java +++ b/src/main/java/com/garbagemule/MobArena/SpawnsPets.java @@ -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);