Skip to content

Commit

Permalink
Fix /head command silently failing
Browse files Browse the repository at this point in the history
  • Loading branch information
WizardCM committed Oct 20, 2023
1 parent d4ec068 commit 99c0da8
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ public boolean runCommand(final CommandSender cs, final Command cmd, final Strin
return false;
}
final Player p = (Player) cs;
final ItemStack head = new ItemStack(Material.SKELETON_SKULL, 1, (short) 3);
if (!(head.getItemMeta() instanceof SkullMeta)) {
cs.sendMessage(MessageColor.NEGATIVE + "The head had incorrect item metadata!");
return true;
}
// final ItemStack head = new ItemStack(Material.SKELETON_SKULL, 1, (short) 3);
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
final SkullMeta sm = (SkullMeta) head.getItemMeta();
final OfflinePlayer t = RUtils.getOfflinePlayer(args[0]);
if (!t.getName().equalsIgnoreCase(p.getName()) && !this.ah.isAuthorized(cs, cmd, PermType.OTHERS)) {
Expand All @@ -50,7 +47,11 @@ public boolean runCommand(final CommandSender cs, final Command cmd, final Strin
cs.sendMessage(MessageColor.NEGATIVE + "You cannot spawn that player's head!");
return true;
}
sm.setOwner(t.getName());
if (t.hasPlayedBefore()) {
sm.setOwningPlayer(t);
} else {
sm.setOwner(args[0]);
}
head.setItemMeta(sm);
p.getInventory().addItem(head);
cs.sendMessage(MessageColor.POSITIVE + "You have been given the head of " + MessageColor.NEUTRAL + t.getName() + MessageColor.POSITIVE + ".");
Expand Down

0 comments on commit 99c0da8

Please sign in to comment.