Solved Help With My Staffchat Plugin

Discussion in 'Plugin Development' started by Extremesnow, Aug 24, 2016.

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

    Extremesnow

    Hey, I have recently made a staff chat plugin called Zohreh's StaffChat

    I would like some help :D

    Ok First off heres the code
    http://pastebin.com/tgRK2BDt

    What I need is for the Staff chat to display in chat without it being toggled, If you have a certain permission.

    If you can help that would be awesome!
     
  2. Offline

    Zombie_Striker

    1. Don't cast your plugin to a listener if it is already a listener
    2. Don't log your own plugin. Bukkit does this for you. No need to log your plugin twice.
    3. Remember that all events need to have the "@EventrHandler" tag.
    What exactly is your issue? You already know what you need to do (check a players permission. If they have the permission, display the message). What do you need help with?
     
  3. Offline

    N00BHUN73R

    @Extremesnow
    Your code is very all over the place.
    Why are you storing the Player object? Use UUIDs, also, in this situation I think you should use a Collection/Arraylist

    EDIT:
    Also, why do you cast everything you do.. (Object) (Listener) (Plugin) These are useless.
     
  4. Offline

    Extremesnow

    any examples??? Im lost I'm not sure how to efficiently position the code

    All help is appreciated

    UPDATE Does this look any better??
    New Code (open)
     
    Last edited: Aug 24, 2016
  5. @Extremesnow Positioning the code is personal preference. However, If the code doesent look a mess, I'd say it's good code. However, Like @Zombie_Striker and @N00BHUN73R said don't cast it to (Plugin) and (Listener) on your onEnable. First of all, Why did you remove your onEnable method? You need to register the events, Add it back, But do something like:

    Code:
    public void onEnable() {
        Bukkit.getServer().getPluginManager().registerEvents(this, this);
    }
    
    Next, How about when a Player does /staffchat <Message> it will broadcast a message to Players with the permission. Such as using "Bukkit.broadcast" method. Try to reformat your code with your IDEs built in formater using Ctrl+Shift+F if on PC, Or CMD+Shift+F if on Mac. If that doesen't work, I'd redo some things to make it look neater. And by the way, We're not going to straight up give you the code if that's what you meant. Sorry.
     
  6. Offline

    SethxGaming

    When I did my Staff Chat Plugin, I simply just made all the messages a Bukkit.broadcast() to a certain permission, I would recommend this. all you have to do to add this is just do

    Bukkit.broadcast(message. plugin.isstaff);

    Also you can make a command that will make a player staff by adding permissions, or just post the permissions on the plugin description on Bukkit Dev.
     
  7. @SethxGaming yes. It'd be a lot simpler than moving Players to an ArrayList, broadcasting the message, Then putting them back to the regular chat channel. Also It's more effective since you won't get mixed up with what channel you are currently in.

    If you're going to do it the /staffchat <Message> way. Just make a StringBuilder to gather args, Then bukkit.broadcas("Message", "permission node"); Also remember to register perms in plugin#yml. It's something a lot of people forget.

    EDIT: Removed code, I now realise my wrong
    @Zombie_Striker. Sorry.
     
    Last edited: Aug 25, 2016
  8. Offline

    Zombie_Striker

    You are part of the reason we tell people not to spoonfeed. You even say you don't know if it will work. If a person needs code in order to understand how to do something, how will they be able to fix code they did not even write? Please, do not spoonfeed code. Either tell the person what they need to do, recommend tutorials that show working code, or if you absolutely must show code, give psudocode.

    [edit]Inside your code, you are broadcasting a message while building the string. This means there will be fragmented sentences being printed out. And you are even returning inside of the for loop. That means it's not actually building anything, just printing out the first word! Again, this is why we don't like spoonfeeding people.
     
Thread Status:
Not open for further replies.

Share This Page