CCBlueX Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Where is the mistake?

    ScriptAPI
    4
    9
    228
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ButterChicken
      ButterChicken last edited by ButterChicken

      help me!Why can't it be detected?

      var S45PacketTitle = Java.type("net.minecraft.network.play.server.S45PacketTitle");
      
      	this.onPacket = function(event) {
      			var packet = event.getPacket();
      			if(packet instanceof S45PacketTitle) {
      				if(packet.getType().equals(S45PacketTitle.Type.TITLE)) {
      					var text = packet.getMessage().getUnformattedText();
      					if (text.equals("Victory!")) { //problem
      						mc.thePlayer.sendChatMessage("GG");
      					}
      			}
      }
      
      C 1 Reply Last reply Reply Quote 0
      • I
        idkwhome v2 last edited by

        gettype()

        ButterChicken 1 Reply Last reply Reply Quote 0
        • ButterChicken
          ButterChicken @idkwhome v2 last edited by

          @idkwhome-v2 How to deal with it?

          CzechHek 1 Reply Last reply Reply Quote 0
          • CzechHek
            CzechHek @ButterChicken last edited by

            @ButterChicken Title messages are often in siblings or smth, print the component and find where the "Victory!" is.

            1 Reply Last reply Reply Quote 1
            • C
              commandblock2 @ButterChicken last edited by commandblock2

              @ButterChicken said in Where is the mistake?:

              if (text.equals("Victory!")) { //problem
              mc.thePlayer.sendChatMessage("GG");
              }

              if (text.equals("Victory!")) { //problem
                  mc.thePlayer.sendChatMessage("GG");
              } else chat.print(text) //So that u can actually see what the title really is (exact string will be shown in [CHAT in .minecraft/logs/latest.txt)
              

              but anyway I suggest to find/match part of the string. like text.contains("Victory") but it seemed that there is no such method in nashorn so u might have to use text.indexOf("Victory") != -1

              CzechHek 1 Reply Last reply Reply Quote 0
              • CzechHek
                CzechHek @commandblock2 last edited by

                @commandblock2 Text would probably return "". So he would need to get siblings and stuff to get the msg. String.contains() is in Nashorn tho.

                C 1 Reply Last reply Reply Quote 0
                • C
                  commandblock2 @CzechHek last edited by commandblock2

                  @CzechHek nvm I was blind

                  if (text.equals("Victory!")) { //problem
                      mc.thePlayer.sendChatMessage("GG");
                  } else chat.print(packet.getMessage()) // anyway that's better
                  
                  1 Reply Last reply Reply Quote 0
                  • ButterChicken
                    ButterChicken last edited by

                    So have figured out a solution?

                    CzechHek 1 Reply Last reply Reply Quote 0
                    • CzechHek
                      CzechHek @ButterChicken last edited by

                      @ButterChicken That's what you were supposed to do.

                      @CzechHek said in Where is the mistake?:

                      @ButterChicken Title messages are often in siblings or smth, print the component and find where the "Victory!" is.

                      Here is the documentation: https://scriptapi.liquidbounce.net/net/minecraft/util/ChatComponentText.html

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      About
                      • Terms of Service
                      • Privacy Policy
                      • Status
                      • Contact Us
                      Downloads
                      • Releases
                      • Source code
                      • License
                      Docs
                      • Tutorials
                      • CustomHUD
                      • AutoSettings
                      • ScriptAPI
                      Community
                      • Forum
                      • Guilded
                      • YouTube
                      • Twitter
                      • D.Tube