[SOLVED] sending a title + subtitle on join (kinda like mineplex)

Discussion in 'Spigot Plugin Development' started by Yazio, Jun 11, 2015.

Thread Status:
Not open for further replies.
  1. ok so im trying to make a 100% custom hub but i want a title + subtitle appear when they join

    error:
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-"8c26a90"] at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:509) [spigot.jar:git-Spigot-"8c26a90"] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:494) [spigot.jar:git-Spigot-"8c26a90"] at net.minecraft.server.v1_8_R1.PlayerList.onPlayerJoin(PlayerList.java:262) [spigot.jar:git-Spigot-"8c26a90"] at net.minecraft.server.v1_8_R1.PlayerList.a(PlayerList.java:147) [spigot.jar:git-Spigot-"8c26a90"] at net.minecraft.server.v1_8_R1.LoginListener.b(LoginListener.java:109) [spigot.jar:git-Spigot-"8c26a90"] at net.minecraft.server.v1_8_R1.LoginListener.c(LoginListener.java:41) [spigot.jar:git-Spigot-"8c26a90"] at net.minecraft.server.v1_8_R1.NetworkManager.a(NetworkManager.java:159) [spigot.jar:git-Spigot-"8c26a90"] at net.minecraft.server.v1_8_R1.ServerConnection.c(ServerConnection.java:82) [spigot.jar:git-Spigot-"8c26a90"] at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:786) [spigot.jar:git-Spigot-"8c26a90"] at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot.jar:git-Spigot-"8c26a90"] at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:625) [spigot.jar:git-Spigot-"8c26a90"] at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:528) [spigot.jar:git-Spigot-"8c26a90"] at java.lang.Thread.run(Unknown Source) [?:1.8.0_40] Caused by: java.lang.StackOverflowError at MAIN.MAIN.sendTitle(MAIN.java:563) ~[?:?]"]

    code:
    Code (Text):
    @Deprecated
        public static void sendTitle(Player player, Integer fadeIn, Integer stay, Integer fadeOut, String title, String subtitle) {
            sendTitle(player, fadeIn, stay, fadeOut, title, subtitle);
        }
       
        @EventHandler
        public void PlayerJoin(PlayerJoinEvent e) {
            e.setJoinMessage("");
            Player p = e.getPlayer();
                    sendTitle(p, 30, 100, 10, "§7§lWelcome " + p.getName() + " to", "§5§l§oOP§f§l§oHub");
    note: yes u can have a package called "MAIN" and a class called "MAIN"
     
  2. JamesJ

    Supporter

    What is your code for
    #sendTitle()
     
  3. if u didn't notice
    :p
     
  4. Um.... What?

    (Also, make your package name all lowercase and dont make your main class all uppercase)
     
    #4 Regablith, Jun 11, 2015
    Last edited: Jun 11, 2015
  5. I don't understand. Are you calling #sendTitle inside #sendTitle infinitely? You're not checking any of the parameters, you're just repeatedly calling it until it overflows.
    Code (Java):
    Caused by: java.lang.StackOverflowError at MAIN.MAIN.sendTitle(MAIN.java:563) ~[?:?]
    Edit: You may want to check this out for sending titles to your players.
     
    • Agree Agree x 1
  6. The reason for this error is because of your sendtitle method calls itself continually, and the jvm doesn't know what to do since it does not stop. Read the bottom of the stack trace, it's a stack overflow error.

    Edit: Ninja'd
     
    • Agree Agree x 1
  7. why??
     
  8. It's convention in Java to have lowercase package names and class names that are camel case.
     
    • Agree Agree x 1
  9. don't need this anymore i got it :)

    //PLEASE CLOSE THIS THREAD
     
  10. Report the thread to have it closed. It's the fastest and easiest way to get in contact with the moderators.
     
  11. In a way it could be as simple as doing this:
    Code (Text):
        @EventHandler(priority = EventPriority.LOWEST)
        public void onJoin(PlayerJoinEvent e) {
            sendTitle("§6Welcome back, §e" + e.getPlayer().getName(), e.getPlayer());
        }
        void sendTitle(String s, Player p) {
            getServer().dispatchCommand(getServer().getConsoleSender(), "title " + p.getName() + " title " + s);
        }
           
    And this is just running the vanilla minecraft commands /title.
     
Thread Status:
Not open for further replies.