How do you change someone's skin to a steve and change the player's in-game name to args[0]?

Discussion in 'Plugin Development' started by FoxinatorDev, Oct 25, 2017.

Thread Status:
Not open for further replies.
  1. @FoxinatorDev
    Odd. What about clicking the red minus sign (the top left one), and creating an artifact with an entirely new name (using 'From Modules with dependencies')?
     
  2. Offline

    FoxinatorDev

    What do you mean by that?
     
  3. @FoxinatorDev
    You select your artifact, click the red minus (the top left most one), and then click the green plus icon, and create a new artifact, but you choose a new name.
     
  4. Offline

    FoxinatorDev

    I don't know how to add a artifact. Sorry, I'm kinda new to API's
     
  5. @FoxinatorDev
    You have your artifact named 'Extra Commands'. What I want you to do is select it in the menu to the left, and then click the red minus sign above it where you selected it. Then I want you to click the green plus right next to that, and add a new one, which should fix the problem.

    EDIT:
    Here's a picture of what I mean:
    [​IMG]
     
  6. Offline

    FoxinatorDev

    Still an error

    Nick.java:

    Code:
    package duels.commands;
    
    import com.bringholm.nametagchanger.NameTagChanger;
    import com.bringholm.nametagchanger.skin.Skin;
    import duels.utils.ChatUtils;
    import duels.utils.ConfigUtils;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    public class Nick implements CommandExecutor {
    
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            final Player p = (Player) sender;
    
            if(!p.hasPermission("duels.command.nick")) {
                ChatUtils.getInstance().noPermission(p);
                return true;
            } else {
                if(args.length == 0) {
                    ChatUtils.getInstance().commandUsage(p, "nick <Nickname>");
                    return true;
                } else if(args.length == 1) {
                    String nickname = args[0];
    
                    NameTagChanger.INSTANCE.changePlayerName(p, nickname);
                    NameTagChanger.INSTANCE.setPlayerSkin(p, Skin.EMPTY_SKIN);
                    return true;
                }
            }
    
            return true;
        }
    
        private String format(String string) {
            return ChatColor.translateAlternateColorCodes('&', string);
        }
    }
    
    Main.java:
    Code:
    package duels.main;
    
    import com.bringholm.nametagchanger.NameTagChanger;
    import duels.commands.*;
    import duels.events.AsyncChat;
    import duels.events.Join;
    import duels.utils.ChatUtils;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import java.io.Console;
    import java.io.File;
    import java.io.InputStream;
    import java.util.HashSet;
    import java.util.Set;
    
    public class Main extends JavaPlugin {
    
        private File configfile;
    
        public static Set<String> onlinePlayers = new HashSet<String>();
    
        public void onEnable() {
            registerCommands();
            registerEvents();
            setUpConfig();
            registerOnlinePlayers();
            NameTagChanger.INSTANCE.setPlugin(this);
            System.out.println(format("&aDuels plugin has been enabled! &cIf there are any errors, please report them to Justin."));
    
            if(!NameTagChanger.INSTANCE.isEnabled()) {
                NameTagChanger.INSTANCE.enable();
            }
    
        }
    
        public void setUpConfig() {
            configfile = new File(getDataFolder(), "config.yml");
    
            if(!configfile.exists()) {
                configfile.getParentFile().mkdirs();
                copy(getResource("config.yml"), configfile);
                getConfig().createSection("players");
                saveConfig();
            } else if(configfile.exists()) {
                return;
            }
        }
    
        private void copy(InputStream resource, File configfile2) {
            return;
        }
    
        public void onDisable() {
    
            if (NameTagChanger.INSTANCE.isEnabled()) {
                NameTagChanger.INSTANCE.disable();
            }
        }
    
        private void registerCommands() {
            setCommand("invsee", new Invsee());
            setCommand("addplayer", new AddPlayer());
            setCommand("nick", new Nick());
            setCommand("list", new List());
            setCommand("fly", new Fly());
        }
    
        private void registerEvents() {
            setEvent(new Join());
            setEvent(new AsyncChat());
        }
    
        private void setCommand(String command, CommandExecutor file) {
            getCommand(command).setExecutor(file);
        }
    
        private void setEvent(Listener file) {
            Bukkit.getPluginManager().registerEvents(file, this);
        }
    
        private void registerOnlinePlayers() {
            for(Player players : Bukkit.getServer().getOnlinePlayers()) {
                onlinePlayers.add(players.getName());
            }
        }
    
        private static String format(String string) {
            return ChatColor.translateAlternateColorCodes('&', string);
        }
    
    }
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  7. @FoxinatorDev
    There's nothing wrong with your code. If it's the same 'NoClassDefFoundError' as before, it's to do with the shading. If you have removed and re-added the artifact, can you again post a screenshot of it? It needs to say 'Extracted NameTagChanger...' like in my screenshot above.
     
  8. Offline

    FoxinatorDev

    How did you extract it?

    Screenshot:
    upload_2017-10-28_12-0-38.png
     
  9. @FoxinatorDev
    Please try what I said above. Remove the artifact using the red minus, create a new one using the green plus and choose a new name (IE not Extra Commands).
     
  10. Offline

    FoxinatorDev

    I already did
     
  11. @FoxinatorDev
    You didn't pick a new name. I can see that the name is 'Extra Commands' in both screenshots, you know.
     
  12. Offline

    FoxinatorDev

    I deleted it upload_2017-10-28_12-13-5.png

    Then added
    upload_2017-10-28_12-14-4.png Then I clicked on everything in the red shape
    upload_2017-10-28_12-15-34.png Anything I did wrong?
     
  13. @FoxinatorDev
    You didn't click 'From Modules with dependencies'. If you click that, you will get it all automatically added for you, including the extracted thing.
    [​IMG]
     
  14. Offline

    FoxinatorDev

    Oh. I feel dumb.

    It is still not working

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 28, 2017
  15. Offline

    FoxinatorDev

    It is

    Here's a screenshot:
    upload_2017-10-28_13-16-15.png
     
  16. @FoxinatorDev
    Well, at least we've made progress now. What is the error now?

    Also, you shouldn't have spigot.jar set to compile into your project, it will include the entirety of the spigot server, which is just unnecessary.
     
  17. Offline

    FoxinatorDev

    It's the same error.
     
  18. @FoxinatorDev
    Are you sure you've recompiled the jar? (Easiest way is to just build project and use that).

    If you have, can you open up the jar with a zip program and check if the 'com.bringholm.nametagchanger' package is in there?
     
  19. Offline

    FoxinatorDev

  20. @FoxinatorDev
    Okay, is the 'com.bringholm.nametagchanger' package inside the jar when you open it with a zip program?
     
  21. Offline

    FoxinatorDev

    What do you mean?
     
  22. @FoxinatorDev
    If you open the jar with a zip program of your choice, do you see that the com/bringholm/nametagchanger folder is in there?
     
  23. Offline

    FoxinatorDev

    Yes I do see it.
     
  24. @FoxinatorDev
    Right, and that's the jar you're putting in your plugins folder?

    Can you copy and paste the error from the console again for me, please.
     
  25. Offline

    FoxinatorDev

    Wait... You put that in the plugins folder too?
     
  26. @FoxinatorDev
    No, if you're opening the NameTagChanger jar. What I meant was that you should open the jar that you've compiled and see if that has the package.
     
  27. Offline

    FoxinatorDev

    It does have the package
     
  28. @FoxinatorDev
    Then can you copy and paste the error you're getting?
     
  29. Offline

    FoxinatorDev

    Code:
    [17:11:24 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'nick' in plugin ExtraCommands v1.0
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot.jar:git-Spigot-21fe707-e1ebe52]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-21fe707-e1ebe52]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_144]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_144]
            at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-21fe707-e1ebe52]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-21fe707-e1ebe52]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_144]
    Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.bringholm.nametagchanger.NameTagChanger
            at duels.commands.Nick.onCommand(Nick.java:28) ~[?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-21fe707-e1ebe52]
            ... 15 more
     
Thread Status:
Not open for further replies.

Share This Page