#How do I execute a console command with the player's name in it, but not send the player a message?
1 messages · Page 1 of 1 (latest)
i want the console to execute command
/give player minecraft:enderman_spawn_egg{display:{Name:'{"text":"Ender Dragon Spawn Egg","italic":false}'},EntityTag:{id:"minecraft:ender_dragon",CustomName:""}}
then use the thing i sent
"
ah nope that wont
it also has '
Why not just parse the players name using Bukkit#getOfflinePlayer(String name)?
the player is online
why would it get the offline player name
(im new to spigot so if thats dumb please tell me)
Yea, but offline players work just fine even if they are actually online.
how would I insert it?
lol
"hihihi" Bukkit#getOfflinePlayer(String name) "hihi"?
Oh, well if they are online you cod use Bukkit#getPlayer(string)
Well Bukkit#getOfflinePlayer() returns an OfflinePlayer. Bukkit#getPlayer() returns a player. So you just need to use the method #getName() on one of those objects if you want to put it in a string.
Player player = Bukkit.getPlayer("FourteenDoggo")
^
By using the methods in the Player object.
Player#getName().
why do you need a player object if youre sending the command with the player name in?
You do know how to concatenate strings right?
Also, if you are making commands and running them from console, you have far fewer things to worry about.
You could just get the input after the player name and use that for your whatever the command does.
Oh wait a minute.
You could also use Bukkit#dispatchCommand() if you wanted to run a premade command.
You’d just want to replace the parts of the string with the proper variables.
ah he thats something too
You may also want to use the namespaced versions of the commands if you are putting it in string format.
Any plugin could overwrite the functionality of an existing command.
So if you want to make sure your code works regardless of whatever plugins you have installed, make sure you prefix it with whatever plugin namespace you need.
Example: /give vs /minecraft:give vs /essentials:give
not everyone >_<
nearly everyone