Check Inventory Title Error?

Discussion in 'Spigot Plugin Development' started by Gober, Aug 12, 2018.

  1. So basically, I'm making this plugin called "Shipment Box".
    I wanted to check if player clicked on a Shipment Box Inventory / Not.
    It turn's out, doesn't work?
    Code (Java):
            String title = Utility.TransColor(inv.getTitle()); // Take inventory title
            Utility.sendConsole(title + ", " + GuiName); // Sends the Inventory Title & GuiName = The inventory title but replaced %OWNER% with ""
            if (!title.contains(GuiName)) {
                Utility.sendConsole("reach here");
                return;
            }

    // Utility#TransColor returns a String from ChatColor#translateAlternateColorCodes('&', String);

    // Utility#sendconsole sends message to console
     
    Code (Text):

    Reinassance's Shipment Box, 's Shipment Box

    New Output:
    Code (Text):
    12.08 08:16:28 [Server] INFO [08:16:28 INFO]: Reinassance's Shipment Box, 's Shipment Box
    12.08 08:16:28 [Server] INFO [08:16:28 INFO]: Inventory Title: Reinassance's Shipment Box
    12.08 08:16:28 [Server] INFO [08:16:28 INFO]: Inventory Title (Color): Reinassance's Shipment Box
    12.08 08:16:28 [Server] INFO [08:16:28 INFO]: Base title: 's Shipment Box
    12.08 08:16:28 [Server] INFO [08:16:28 INFO]: Base title (Color): 's Shipment Box
    12.08 08:16:28 [Server] INFO [08:16:28 INFO]: reach here
     
    Code (Java):
    // The new code
            String title = inv.getTitle();
            Utility.sendConsole(title + ", " + GuiName);
            System.out.println("Inventory Title: " + title);
            System.out.println("Inventory Title (Color): " + Utility.TransColor(title));
            System.out.println("Base title: " + GuiName);
            System.out.println("Base title (Color): " + Utility.TransColor(GuiName));
            if (!title.contains(GuiName)) {
                Utility.sendConsole("reach here");
                return;
            }

    Any ideas?
     
    #1 Gober, Aug 12, 2018
    Last edited: Aug 12, 2018
  2. Add all of the shipment box inventories to a set and then check if the clicked inventory is inside the set on InventoryClickEvent.
     
    • Creative Creative x 1
  3. Still confused why the one I use doesn't work. :/
     
  4. You really dont need that utility...might be messing w/things.

    Use Chatcolor.translateAlternate.....not in IDE rn