[request] Right clicking placed heads show their name in chat
TomLewis opened this issue ยท 9 comments
Im finally taking the time to move away from PlayerHeads which is ancient and many mobs are unsupported to MobHunting! one request that I miss dramatically with PlayerHeads is being able to right click heads that are placed to display their name, when you right click a head in Playerheads it pops up in chat "Thats GodsDead's head" for example. Most all my players love collecting heads from their enemies! Could you add a customisable message for when we right click all heads collected from MobHunting (Bonus points if you can make all existing placed heads display a name too! playerheads named the heads "usernames's Head" no color or anything, I guess it just reads their name and prints it out to chat.
I have 4+ years of heads collected all over my world, can you make it so right clicking any head, just shows its name in chat please :)
I might have found it and a solution
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event) {
Block block = event.getClickedBlock();
Player player = event.getPlayer();
if (block != null && block.getType() == Material.SKULL) {
Skull skullState = (Skull) block.getState();
if (player.hasPermission("playerheads.clickinfo")) {
switch (skullState.getSkullType()) {
case PLAYER:
if (skullState.hasOwner()) {
String owner = skullState.getOwner();
//String ownerStrip = ChatColor.stripColor(owner); //Unnecessary?
CustomSkullType skullType = CustomSkullType.get(owner);
if (skullType != null) {
Tools.formatMsg(player, Lang.CLICKINFO2, skullType.getDisplayName());
if (!owner.equals(skullType.getOwner())) {
skullState.setOwner(skullType.getOwner());
skullState.update();
}
} else {
Tools.formatMsg(player, Lang.CLICKINFO, owner);
}
} else {
Tools.formatMsg(player, Lang.CLICKINFO2, Lang.HEAD);
}
break;
case CREEPER:
Tools.formatMsg(player, Lang.CLICKINFO2, Tools.format(Lang.HEAD_CREEPER));
break;
case SKELETON:
Tools.formatMsg(player, Lang.CLICKINFO2, Tools.format(Lang.HEAD_SKELETON));
break;
case WITHER:
Tools.formatMsg(player, Lang.CLICKINFO2, Tools.format(Lang.HEAD_WITHER));
break;
case ZOMBIE:
Tools.formatMsg(player, Lang.CLICKINFO2, Tools.format(Lang.HEAD_ZOMBIE));
break;
}
} else if ((skullState.getSkullType() == SkullType.PLAYER) && (skullState.hasOwner())) {
String owner = skullState.getOwner();
CustomSkullType skullType = CustomSkullType.get(owner);
if ((skullType != null) && (!owner.equals(skullType.getOwner()))) {
skullState.setOwner(skullType.getOwner());
skullState.update();
}
}
}
}
I made my own code based on how it was done in Playerheads.
It is released in V5.1.5
I have not added any permission to get the name, I don't think that is needed.
Fantastic news! I cant think of any reason why a permission would be needed. I just gave my one from playerheads to everyone.
Yeah the source code is here! https://github.com/meiskam/PlayerHeads
I don't know Java I have no idea if that would work haha!