Solved Mineplex login message

Discussion in 'Plugin Help/Development/Requests' started by sgavster, Mar 3, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    sgavster

    Hello everyone! As some of you may know, I used to be on here all the time.

    I have not coded in almost 2 years, and I want to get back into it. I have started the basic plugin for my server but I want this:
    [​IMG]

    I know it is possible with CMD blocks, but I would really like to do it with code.

    Again, I used to code, I was good! I am just starting back up, today! Thanks for any help
     
    Last edited: Mar 3, 2015
  2. Offline

    iReD_xBlaDeZ

  3. Offline

    sgavster

    @iReD_xBlaDeZ So sorry! Just fixed it, still getting used to things :p
     
  4. Offline

    Tecno_Wizard

    @sgavster, I've been very interested in this myself, but I don't know either.
    Also, if you have been gone for 2 years, I suggest googling bukkit DMCA
     
  5. Offline

    sgavster

    @Tecno_Wizard I read up on it a bit, it's so sad all this is going on, but I hope everything gets back to normal!
     
  6. Offline

    xTigerRebornx

  7. Offline

    sgavster

    @xTigerRebornx I was really trying to stay away from API's, (I'm also not really sure how I should set it up, lol) is there a good tutorial for setting it up?
     
    Last edited: Mar 3, 2015
  8. Offline

    nj2miami

    Code:
        public static void send(String title, String subtitle, int in, int out, int stay, Player p) {
           
            PlayerConnection connection = ((CraftPlayer) p).getHandle().playerConnection;
            IChatBaseComponent titleJSON = ChatSerializer.a("{'text': '" + title + "'}");
            IChatBaseComponent subtitleJSON = ChatSerializer.a("{'text': '" + subtitle + "'}");
            PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleJSON, in, stay, out);
            PacketPlayOutTitle subtitlePacket = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, subtitleJSON);
            connection.sendPacket(titlePacket);
            connection.sendPacket(subtitlePacket);
           
        }
     
    sgavster likes this.
  9. Offline

    AdityaTD

    Hey check this out:dev.bukkit.org/bukkit-plugins/title-welcome-message/ use JD-GUI for its source code and yes I made the plugin so I allow you to do it but make sure to give credit...
     
  10. Offline

    Tecno_Wizard

    @sgavster, I can assure you it won't. I'm just waiting for trident to be released.
     
    xTrollxDudex and mythbusterma like this.
  11. Offline

    mythbusterma

  12. Offline

    xTigerRebornx

    @sgavster Not sure what the reason would be for staying away from APIs, they are there to make life easier. The only other way is through NMS, or if Spigot's 1.8 build happens to have an API (which I still doubt it does).
    As for actually using it, there is a tutorial on their page, and all you need to do is install the plugin on your server and depend/softdepend and handle loading.
     
  13. Offline

    Tecno_Wizard

    @mythbusterma, any time ;), but seriously, bukkit is really just managed by spigot at this point, plus I would like to see how they preform.
     
  14. Offline

    bwfcwalshy Retired Staff

    Moved to Bukkit Alternates, this is a 1.8 feature.
     
  15. Offline

    sgavster

    @nj2miami Thanks! I tried it, but I'm not sure what I'm doing wrong, here is some code...
    Code:
    //MAIN, onEnable
    
        @Override
        public void onEnable()
        {
            loginHandler lh = new loginHandler(this);
            getServer().getPluginManager().registerEvents(lh, this);
            this.getCommand("test").setExecutor(lh);
            l.info("QuadularMC enabled.");
        }
       
    //loginHandler class
    
    package me.sgavster.qmc.func;
    
    import me.sgavster.qmc.Main;
    import net.minecraft.server.v1_8_R1.ChatSerializer;
    import net.minecraft.server.v1_8_R1.EnumTitleAction;
    import net.minecraft.server.v1_8_R1.IChatBaseComponent;
    import net.minecraft.server.v1_8_R1.PacketPlayOutTitle;
    import net.minecraft.server.v1_8_R1.PlayerConnection;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    
    public class loginHandler implements Listener, CommandExecutor
    {
        Main main = new Main();
          public loginHandler(Main m) {
            this.main = m;
        }
    
        public static void send(String title, String subtitle, int in, int out, int stay, Player p) {
              
                PlayerConnection connection = ((CraftPlayer) p).getHandle().playerConnection;
                IChatBaseComponent titleJSON = ChatSerializer.a("{'text': '" + title + "'}");
                IChatBaseComponent subtitleJSON = ChatSerializer.a("{'text': '" + subtitle + "'}");
                PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleJSON, in, stay, out);
                PacketPlayOutTitle subtitlePacket = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, subtitleJSON);
                connection.sendPacket(titlePacket);
                connection.sendPacket(subtitlePacket);
              
            }
         
    @EventHandler
    public void onLogin(PlayerJoinEvent e)
    {
        Player p = e.getPlayer();
        send("QuadularMC", "Welcome, " + p.toString(), 1, 20, 10, p);
      }
    
    @Override
    public boolean onCommand(CommandSender cs, Command cmd, String string, String[] arg)
    {
        if(cs instanceof Player)
        {
        if(cmd.getName().equalsIgnoreCase("test"))   
        {
            Player p = (Player) cs;
            send("QuadularMC", "Welcome, " + p.toString(), 1, 20, 10, p);
        }
        } else {
            cs.sendMessage("You are not a player :|");
        }
        return false;
    }
    }
    
    
     
  16. Offline

    nj2miami

    What have you done to see what is failing?

    /plugin -> is your plugin listed?

    Server.log -> Did you plugin load? Any error messages?

    Debug -> Put some output inside your events to make sure they are firing. For instance, in your PlayerJoin event make sure it is being triggered, etc.
     
  17. Offline

    sgavster

    EDIT: Ahh, I'm stupid!

    In my loginHandler I was loading a new Main, which was causing it to endlessy load. lol
     
    Last edited: Mar 4, 2015
  18. Offline

    nj2miami

    You need to be able to read those stack traces to debug your code better.

    What is QuadularMC?
     
  19. Offline

    sgavster

    @nj2miami QuadularMC is the plugin name, I actually can read the stack traces, (I'm still getting used to them, again..) but read my edited post above.
     
  20. Offline

    nj2miami

    Does it load now?
     
  21. Offline

    sgavster

    @nj2miami Indeed it does, thank you so much![​IMG]
     
  22. Offline

    nj2miami

    @sgavster Perfect. Edit the topic and marked as SOLVED. Enjoy.
     
    sgavster likes this.
Thread Status:
Not open for further replies.

Share This Page