From a6cf533bb635039da815620945536e32d101ca98 Mon Sep 17 00:00:00 2001 From: Danny Meyers <78126278+Yurakaii@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:44:18 -0400 Subject: [PATCH 1/4] adds the option to give a skull to another player with the /skull command --- .../essentials/commands/Commandskull.java | 29 +++++++++++++++---- Essentials/src/main/resources/plugin.yml | 2 +- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java index d914cdfb916..82f12cd2d69 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java @@ -48,7 +48,18 @@ public Commandskull() { @Override protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { final String owner; - if (args.length > 0 && user.isAuthorized("essentials.skull.others")) { + final User player; + if(args.length == 2){ + try{ + player = getPlayer(server, args[1], true, false); + } catch (final Exception e) { + throw new TranslatableException("playerNotFound"); + } + } else { + player = user; + } + + if (args.length > 0 && player.isAuthorized("essentials.skull.others")) { if (BASE_64_PATTERN.matcher(args[0]).matches()) { try { final String decoded = new String(Base64.getDecoder().decode(args[0])); @@ -73,16 +84,16 @@ protected void run(final Server server, final User user, final String commandLab owner = args[0]; } } else { - owner = user.getName(); + owner = player.getName(); } - ItemStack itemSkull = user.getItemInHand(); + ItemStack itemSkull = player.getItemInHand(); final SkullMeta metaSkull; boolean spawn = false; if (itemSkull != null && MaterialUtil.isPlayerHead(itemSkull)) { metaSkull = (SkullMeta) itemSkull.getItemMeta(); - } else if (user.isAuthorized("essentials.skull.spawn")) { + } else if (player.isAuthorized("essentials.skull.spawn")) { itemSkull = new ItemStack(SKULL_ITEM, 1, (byte) 3); metaSkull = (SkullMeta) itemSkull.getItemMeta(); spawn = true; @@ -90,11 +101,11 @@ protected void run(final Server server, final User user, final String commandLab throw new TranslatableException("invalidSkull"); } - if (metaSkull.hasOwner() && !user.isAuthorized("essentials.skull.modify")) { + if (metaSkull.hasOwner() && !player.isAuthorized("essentials.skull.modify")) { throw new TranslatableException("noPermissionSkull"); } - editSkull(user, itemSkull, metaSkull, owner, spawn); + editSkull(player, itemSkull, metaSkull, owner, spawn); } private void editSkull(final User user, final ItemStack stack, final SkullMeta skullMeta, final String owner, final boolean spawn) { @@ -148,6 +159,12 @@ protected List getTabCompleteOptions(final Server server, final User use } else { return Lists.newArrayList(user.getName()); } + } else if (args.length == 2){ + if (user.isAuthorized("essentials.skull.others")) { + return getPlayers(server, user); + } else { + return Lists.newArrayList(user.getName()); + } } else { return Collections.emptyList(); } diff --git a/Essentials/src/main/resources/plugin.yml b/Essentials/src/main/resources/plugin.yml index 51af179a95f..8efb209ad23 100644 --- a/Essentials/src/main/resources/plugin.yml +++ b/Essentials/src/main/resources/plugin.yml @@ -446,7 +446,7 @@ commands: aliases: [sign, esign, eeditsign] skull: description: Set the owner of a player skull - usage: / [owner] + usage: / [owner] [player] aliases: [eskull, playerskull, eplayerskull, head, ehead] smithingtable: description: Opens up a smithing table. From 00e3c7d2942f96cd8b4fab7052079fd04da31675 Mon Sep 17 00:00:00 2001 From: Danny Meyers <78126278+Yurakaii@users.noreply.github.com> Date: Tue, 23 Jul 2024 17:26:34 -0400 Subject: [PATCH 2/4] updated the skullCommandUsage messages --- Essentials/src/main/resources/messages.properties | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Essentials/src/main/resources/messages.properties b/Essentials/src/main/resources/messages.properties index d2d07e06d08..c6074acd858 100644 --- a/Essentials/src/main/resources/messages.properties +++ b/Essentials/src/main/resources/messages.properties @@ -1207,13 +1207,17 @@ south=S southWest=SW skullChanged=Skull changed to {0}. skullCommandDescription=Set the owner of a player skull -skullCommandUsage=/ [owner] +skullCommandUsage=/ [owner] [player] skullCommandUsage1=/ -skullCommandUsage1Description=Gets your own skull -skullCommandUsage2=/ -skullCommandUsage2Description=Gets the skull of the specified player +skullCommandUsage1Description=Gives you your own skull +skullCommandUsage2=/ +skullCommandUsage2Description=Gives you the skull of the specified player skullCommandUsage3=/ skullCommandUsage3Description=Gets a skull with the specified texture (either the hash from a texture URL or a Base64 texture value) +skullCommandUsage4=/ +skullCommandUsage4Description=Gives a skull of the specified owner to a specified player +skullCommandUsage5=/ +skullCommandUsage5Description=Gives a skull with the specified texture (either the hash from a texture URL or a Base64 texture value) to a specified player skullInvalidBase64=The texture value is invalid. slimeMalformedSize=Malformed size. smithingtableCommandDescription=Opens up a smithing table. From a861e7d046754d48a41a5e02594ee6ac2cb3cea9 Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Sun, 24 Nov 2024 20:36:34 -0500 Subject: [PATCH 3/4] misc changes --- .../essentials/commands/Commandskull.java | 27 +++++++++---------- .../src/main/resources/messages.properties | 7 ++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java index 82f12cd2d69..5b972d3454f 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java @@ -50,11 +50,7 @@ protected void run(final Server server, final User user, final String commandLab final String owner; final User player; if(args.length == 2){ - try{ - player = getPlayer(server, args[1], true, false); - } catch (final Exception e) { - throw new TranslatableException("playerNotFound"); - } + player = getPlayer(server, args, 1, false, false); } else { player = user; } @@ -84,16 +80,16 @@ protected void run(final Server server, final User user, final String commandLab owner = args[0]; } } else { - owner = player.getName(); + owner = user.getName(); } - ItemStack itemSkull = player.getItemInHand(); + ItemStack itemSkull = user.getItemInHand(); final SkullMeta metaSkull; boolean spawn = false; - if (itemSkull != null && MaterialUtil.isPlayerHead(itemSkull)) { + if (itemSkull != null && MaterialUtil.isPlayerHead(itemSkull) && user == player) { metaSkull = (SkullMeta) itemSkull.getItemMeta(); - } else if (player.isAuthorized("essentials.skull.spawn")) { + } else if (user.isAuthorized("essentials.skull.spawn")) { itemSkull = new ItemStack(SKULL_ITEM, 1, (byte) 3); metaSkull = (SkullMeta) itemSkull.getItemMeta(); spawn = true; @@ -101,14 +97,14 @@ protected void run(final Server server, final User user, final String commandLab throw new TranslatableException("invalidSkull"); } - if (metaSkull.hasOwner() && !player.isAuthorized("essentials.skull.modify")) { + if (metaSkull.hasOwner() && !user.isAuthorized("essentials.skull.modify")) { throw new TranslatableException("noPermissionSkull"); } - editSkull(player, itemSkull, metaSkull, owner, spawn); + editSkull(user, player, itemSkull, metaSkull, owner, spawn); } - private void editSkull(final User user, final ItemStack stack, final SkullMeta skullMeta, final String owner, final boolean spawn) { + private void editSkull(final User user, final User receive, final ItemStack stack, final SkullMeta skullMeta, final String owner, final boolean spawn) { ess.runTaskAsynchronously(() -> { // Run this stuff async because it causes an HTTP request @@ -142,8 +138,11 @@ private void editSkull(final User user, final ItemStack stack, final SkullMeta s ess.scheduleSyncDelayedTask(() -> { stack.setItemMeta(skullMeta); if (spawn) { - Inventories.addItem(user.getBase(), stack); - user.sendTl("givenSkull", shortOwnerName); + Inventories.addItem(receive.getBase(), stack); + receive.sendTl("givenSkull", shortOwnerName); + if (user != receive) { + user.sendTl("givenSkullOther", receive.getDisplayName(), shortOwnerName); + } return; } user.sendTl("skullChanged", shortOwnerName); diff --git a/Essentials/src/main/resources/messages.properties b/Essentials/src/main/resources/messages.properties index c6074acd858..725caa67a60 100644 --- a/Essentials/src/main/resources/messages.properties +++ b/Essentials/src/main/resources/messages.properties @@ -453,6 +453,7 @@ geoIpLicenseMissing=No license key found\! Please visit https\://essentialsx.net geoIpUrlEmpty=GeoIP download url is empty. geoIpUrlInvalid=GeoIP download url is invalid. givenSkull=You have been given the skull of {0}. +givenSkullOther=You have given {0} the skull of {1}. godCommandDescription=Enables your godly powers. godCommandUsage=/ [player] [on|off] godCommandUsage1=/ [player] @@ -1209,9 +1210,9 @@ skullChanged=Skull changed to {0}. skullCommandDescription=Set the owner of a player skull skullCommandUsage=/ [owner] [player] skullCommandUsage1=/ -skullCommandUsage1Description=Gives you your own skull -skullCommandUsage2=/ -skullCommandUsage2Description=Gives you the skull of the specified player +skullCommandUsage1Description=Gets your own skull +skullCommandUsage2=/ +skullCommandUsage2Description=Gets the skull of the specified player skullCommandUsage3=/ skullCommandUsage3Description=Gets a skull with the specified texture (either the hash from a texture URL or a Base64 texture value) skullCommandUsage4=/ From 004a4c1a975cdfa6e3378d4ad23a7a597abf5c35 Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Sun, 24 Nov 2024 20:37:05 -0500 Subject: [PATCH 4/4] Update Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java --- .../java/com/earth2me/essentials/commands/Commandskull.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java index 5b972d3454f..e91a3addbf6 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandskull.java @@ -49,7 +49,7 @@ public Commandskull() { protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { final String owner; final User player; - if(args.length == 2){ + if (args.length == 2) { player = getPlayer(server, args, 1, false, false); } else { player = user;