mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 17:18:37 +01:00
Add argument to /skull to give skull to other player (#5822)
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
parent
2418a6fb78
commit
38e42f9f90
@ -48,7 +48,14 @@ public class Commandskull extends EssentialsCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||||
final String owner;
|
final String owner;
|
||||||
if (args.length > 0 && user.isAuthorized("essentials.skull.others")) {
|
final User player;
|
||||||
|
if (args.length == 2) {
|
||||||
|
player = getPlayer(server, args, 1, false, false);
|
||||||
|
} else {
|
||||||
|
player = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length > 0 && player.isAuthorized("essentials.skull.others")) {
|
||||||
if (BASE_64_PATTERN.matcher(args[0]).matches()) {
|
if (BASE_64_PATTERN.matcher(args[0]).matches()) {
|
||||||
try {
|
try {
|
||||||
final String decoded = new String(Base64.getDecoder().decode(args[0]));
|
final String decoded = new String(Base64.getDecoder().decode(args[0]));
|
||||||
@ -80,7 +87,7 @@ public class Commandskull extends EssentialsCommand {
|
|||||||
final SkullMeta metaSkull;
|
final SkullMeta metaSkull;
|
||||||
boolean spawn = false;
|
boolean spawn = false;
|
||||||
|
|
||||||
if (itemSkull != null && MaterialUtil.isPlayerHead(itemSkull)) {
|
if (itemSkull != null && MaterialUtil.isPlayerHead(itemSkull) && user == player) {
|
||||||
metaSkull = (SkullMeta) itemSkull.getItemMeta();
|
metaSkull = (SkullMeta) itemSkull.getItemMeta();
|
||||||
} else if (user.isAuthorized("essentials.skull.spawn")) {
|
} else if (user.isAuthorized("essentials.skull.spawn")) {
|
||||||
itemSkull = new ItemStack(SKULL_ITEM, 1, (byte) 3);
|
itemSkull = new ItemStack(SKULL_ITEM, 1, (byte) 3);
|
||||||
@ -94,10 +101,10 @@ public class Commandskull extends EssentialsCommand {
|
|||||||
throw new TranslatableException("noPermissionSkull");
|
throw new TranslatableException("noPermissionSkull");
|
||||||
}
|
}
|
||||||
|
|
||||||
editSkull(user, 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(() -> {
|
ess.runTaskAsynchronously(() -> {
|
||||||
// Run this stuff async because it causes an HTTP request
|
// Run this stuff async because it causes an HTTP request
|
||||||
|
|
||||||
@ -131,8 +138,11 @@ public class Commandskull extends EssentialsCommand {
|
|||||||
ess.scheduleSyncDelayedTask(() -> {
|
ess.scheduleSyncDelayedTask(() -> {
|
||||||
stack.setItemMeta(skullMeta);
|
stack.setItemMeta(skullMeta);
|
||||||
if (spawn) {
|
if (spawn) {
|
||||||
Inventories.addItem(user.getBase(), stack);
|
Inventories.addItem(receive.getBase(), stack);
|
||||||
user.sendTl("givenSkull", shortOwnerName);
|
receive.sendTl("givenSkull", shortOwnerName);
|
||||||
|
if (user != receive) {
|
||||||
|
user.sendTl("givenSkullOther", receive.getDisplayName(), shortOwnerName);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.sendTl("skullChanged", shortOwnerName);
|
user.sendTl("skullChanged", shortOwnerName);
|
||||||
@ -148,6 +158,12 @@ public class Commandskull extends EssentialsCommand {
|
|||||||
} else {
|
} else {
|
||||||
return Lists.newArrayList(user.getName());
|
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 {
|
} else {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
@ -454,6 +454,7 @@ geoIpLicenseMissing=No license key found\! Please visit https\://essentialsx.net
|
|||||||
geoIpUrlEmpty=GeoIP download url is empty.
|
geoIpUrlEmpty=GeoIP download url is empty.
|
||||||
geoIpUrlInvalid=GeoIP download url is invalid.
|
geoIpUrlInvalid=GeoIP download url is invalid.
|
||||||
givenSkull=<primary>You have been given the skull of <secondary>{0}<primary>.
|
givenSkull=<primary>You have been given the skull of <secondary>{0}<primary>.
|
||||||
|
givenSkullOther=<primary>You have given <secondary>{0}<primary> the skull of <secondary>{1}<primary>.
|
||||||
godCommandDescription=Enables your godly powers.
|
godCommandDescription=Enables your godly powers.
|
||||||
godCommandUsage=/<command> [player] [on|off]
|
godCommandUsage=/<command> [player] [on|off]
|
||||||
godCommandUsage1=/<command> [player]
|
godCommandUsage1=/<command> [player]
|
||||||
@ -1208,13 +1209,17 @@ south=S
|
|||||||
southWest=SW
|
southWest=SW
|
||||||
skullChanged=<primary>Skull changed to <secondary>{0}<primary>.
|
skullChanged=<primary>Skull changed to <secondary>{0}<primary>.
|
||||||
skullCommandDescription=Set the owner of a player skull
|
skullCommandDescription=Set the owner of a player skull
|
||||||
skullCommandUsage=/<command> [owner]
|
skullCommandUsage=/<command> [owner] [player]
|
||||||
skullCommandUsage1=/<command>
|
skullCommandUsage1=/<command>
|
||||||
skullCommandUsage1Description=Gets your own skull
|
skullCommandUsage1Description=Gets your own skull
|
||||||
skullCommandUsage2=/<command> <player>
|
skullCommandUsage2=/<command> <player>
|
||||||
skullCommandUsage2Description=Gets the skull of the specified player
|
skullCommandUsage2Description=Gets the skull of the specified player
|
||||||
skullCommandUsage3=/<command> <texture>
|
skullCommandUsage3=/<command> <texture>
|
||||||
skullCommandUsage3Description=Gets a skull with the specified texture (either the hash from a texture URL or a Base64 texture value)
|
skullCommandUsage3Description=Gets a skull with the specified texture (either the hash from a texture URL or a Base64 texture value)
|
||||||
|
skullCommandUsage4=/<command> <owner> <player>
|
||||||
|
skullCommandUsage4Description=Gives a skull of the specified owner to a specified player
|
||||||
|
skullCommandUsage5=/<command> <texture> <player>
|
||||||
|
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=<dark_red>The texture value is invalid.
|
skullInvalidBase64=<dark_red>The texture value is invalid.
|
||||||
slimeMalformedSize=<dark_red>Malformed size.
|
slimeMalformedSize=<dark_red>Malformed size.
|
||||||
smithingtableCommandDescription=Opens up a smithing table.
|
smithingtableCommandDescription=Opens up a smithing table.
|
||||||
|
@ -446,7 +446,7 @@ commands:
|
|||||||
aliases: [sign, esign, eeditsign]
|
aliases: [sign, esign, eeditsign]
|
||||||
skull:
|
skull:
|
||||||
description: Set the owner of a player skull
|
description: Set the owner of a player skull
|
||||||
usage: /<command> [owner]
|
usage: /<command> [owner] [player]
|
||||||
aliases: [eskull, playerskull, eplayerskull, head, ehead]
|
aliases: [eskull, playerskull, eplayerskull, head, ehead]
|
||||||
smithingtable:
|
smithingtable:
|
||||||
description: Opens up a smithing table.
|
description: Opens up a smithing table.
|
||||||
|
Loading…
Reference in New Issue
Block a user