Inventorying issues and banning system issues

Discussion in 'Plugin Development' started by acdavis02, Jul 9, 2016.

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

    acdavis02

    So first off, I wanna say sorry for creating double threads, I didn't read that part of the terms, I have now and I wont do it again. But now the issues. So what I have a command called /chatcolor and what it does (supposed to do) is open up an inventory and there a different colors a wool that represent the different ChatColors you can use(like Blue wool would be &3). so what's happening is when you do the command it opens up the inventory and everything shows up right. but when you click the wools and doesn't run my InvetoryClickEvent like its supposed to. it just picks up the wool and lets you move it around and you're not supposed to be able to do that it should just change a String in a file save the file then cancel the event and close the inventory and then send a player a message, but it does none of that, any help? Code:
    ChatColors.java:
    http://pastebin.com/x1CtvAhg
    PlayerEvents.java(InventoryClickEvent):
    http://pastebin.com/ZT35AuiY

    Thanks for your time!
    Also if anyone know a way that would make the code shorter so the Files don't have to be so big that would be appreciated! Thanks everyone!
     
  2. Offline

    SuperSniper

    You might not be registering the listener class in your onEnable()

    as for making your code shorter, you can do

    Code:
    ChatColor.valueOf(item.getItemMeta().getDisplayName().toUpperCase());
    
    and set their chat color from what that returns, instead of having a bunch of "if" methods
     
  3. Offline

    acdavis02

    onEnable()
    http://pastebin.com/ap0m0FLi
    registerEvents()
    http://pastebin.com/jdss9cDU

    My InventoryClickEvent is in my PlayerEvents class. I have other events like AsynPlayerChatEvent and PlayerJoinEvent running and working fine, also while im in the Player join event topic, how would I change what it says when a player logs in? so it doesn't say Adventum has joined the game! and Adventum has Quit!, and set them to nothing?
    thanks in advanced @SuperSniper
     
    Last edited: Jul 9, 2016
  4. Offline

    ipodtouch0218

    @acdavis02
    Regarding Join and Quit Messages:
    Code:
    event.setJoinMessage(null); //In PlayerJoinEvent event
    event.setQuitMessage(null); //In PlayerQuitEvent event
    Regarding InventoryClickEvent:
    It's most likely because the names of the Wool items are colored. Use
    Code:
    ChatColor.stripColor(String)
    to remove the ChatColor from the strings, allowing you to then check using #equalsIgnoreCase();
     
  5. Offline

    acdavis02

    Thanks for the Join and quit messages. But the ChatColor thing did not work, any other help?
    I did
    Code:
    if(item...(ChatColor.stripColor("dark blue")){}
    that did not work.. any other help? I think the whole entire Inventory click event isn't working right. I did something that should close the inventory whether I click something specific or not and it didn't do what the code told it to do.
    @ipodtouch0218
     
  6. Offline

    ipodtouch0218

    @acdavis02
    You have to strip down the color of the item name, not the string "dark blue" you just created.
    Code:
    ChatColor.stripColor(item.getItemMeta().getDisplayName()).equalsIgnoreCase("dark blue")
     
  7. Offline

    acdavis02

    @ipodtouch0218
    So what you just showed gave me the error cant use on Boolean statement. So what I did was
    Code:
    String iName = ChatColor.stripColor(item.getItemMeta().getDisplayName());
    if(iName.equalsIgnoreCase("dark blue")){blah blah blah}
    and it still doesn't work. I think that the event is not registering because nothing happens at all in the event like it should. because if you look at the bottom of the InventoryClickEvent whether I click something right or not it should at least cancel the event and close the inventory but it doesn't.

    Im having another problem now. I added a Banning system to where the players file has a banned in that String there's a Banned by and Banned reason and when the player join is those two aren't set to 'null' (not null its 'null' as in a String 'null') it will kick the player you are banned by something for the reason. But when it is actually kicking the player the Minecraft game itself freezes up on Loading Terrain instead of saying you are banned and the stuff and the console gives a warning saying "handleDisconnection() called twice" Any more help? Thanks. Code:
    onPlayerJoin:
    http://pastebin.com/ijfANgJP

    If anymore information is needed just ask! Thanks!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 10, 2016
Thread Status:
Not open for further replies.

Share This Page