Solved Filtering plugin sending command's outputs or spawning armorstand with a custom head

Discussion in 'Spigot Plugin Development' started by Atomix, Jan 12, 2020.

  1. I'm pretty sure there is a way and im just doing it wrong so how can i filter some command's output from sending in the console? And before you ask why do i even do that...its because i got confused with the way you can summon an armorstand with a head/skull having some Value for a skin ( so basically either way will work for me. If you can tell me how can i filter such messages it would be great. If you could also help me with the summoning without dispatching commands from the plugin it would be even better. The more you know the better.
    • Creative Creative x 1
  2. Code (Java):
    public class CustomHead {

        public static ItemStack get(String base64EncodedString) {
            final ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
            SkullMeta meta = (SkullMeta) skull.getItemMeta();
            assert meta != null;
            GameProfile profile = new GameProfile(UUID.randomUUID(), null);
            profile.getProperties().put("textures", new Property("textures", base64EncodedString));
            try {
                Field profileField = meta.getClass().getDeclaredField("profile");
                profileField.set(meta, profile);
            } catch (NoSuchFieldException | IllegalAccessException e) {
            return skull;

    base64EncodedString is the value box from the website. This only works with custom heads not player heads.

    Edit: Turning off command block output to console is a gamerule.
    #2 Tarluin, Jan 12, 2020
    Last edited: Jan 12, 2020
  3. yeah i know but i wanted to do it only for my plugin and only for certain commands.

    Thanks for the head skin example but unfortunately it doesnt work or im not using it correctly... By which i mean i get steve heads. (and if i could ask what does the try/catch part of the code do exacly?)
    here is my code:
    Code (Java):
        static void SummonArmorStand(Location location, String value) {
            ArmorStand armorstand = (ArmorStand) location.getWorld().spawnEntity(location, EntityType.ARMOR_STAND);

        public static ItemStack getCustomHead(String value) {
            // your code

    just in case you misunderstood me which i doubt, here is an example of the values im putting it:
  4. So do you want to prevent some output to go to the console or just get the command and filter out a part that you are interrested in?
  5. To elaborate on that try / catch part: That's for the reflection stuff.
    The first exception that could be thrown is NoSuchFieldException. You are accessing a field by name. This field could not be present so it can throw a NoSuchFieldException.
    The second exception is IllegalAccesException. You are setting a field accessible, meaning you want to modify it. This is not possible if your method does not have access to the field and thus cannot access it.

    The code works for me (mainly because I believe that code was written by me) on version 1.15.1. What MC-version are you using?
    • Informative Informative x 1
  6. sorry for the late reply. As the title says im making the plugin on 1.13.2

    as for the fields not that advanced yet not sure what all that does.

    Since im trying to summon the armorstand by dispatching a command there is an output which i dont want to show (Summoned new ArmorStand) and i have a command which kills the armorstands with a given name which shows an output too...
    I would really prefer summoning the armorstand the correct way through code instead of trying to mask the commands
  7. Welp the code works perfectly for me.
    I don't know if that is the issue, but instead of using EntityType.ARMOR_STAND, use ArmorStand.class
    I don't know why, but this usually works better.

    For the steve skin; I have the same code and it works perfectly. Maybe (but I doubt that), your string is somehow wrong. Lemme check that real quick

    Edit: skin value works perfectly for me
    #7 Schottky, Jan 12, 2020
    Last edited: Jan 12, 2020
  8. Yea, Schottky gave me that code last week. It works so well I thought I would pass it on. BTW if you are just putting it in your code and not a separate class it doesn't need to be static ;)
    • Friendly Friendly x 1
  9. is there any way this depends on whether the server is with online-mode=true or not
  10. DONT KNOW WHY but it works thank you so much Tarluin and Schottky. Marked as solved