Array

Plugin Reload & API Docs

Avatar

By Stealth_^ 25 Apr 2016 21:00

Member · 55 comments

You're amazing. Thanks for the hard work!

Avatar

By Scrumplex 26 Apr 2016 05:12

Admin · 2,147,483,647 comments

No problem 🙂


The Developer of the Sprummlbot and the Admin of this forum.

Avatar

By Stealth_^ 28 Apr 2016 22:29

Member · 55 comments

So what do I need to change :

getPermissionGroups().get();

to? I tried doing how it was listed in the update notes, but I get a "Object cannot be applied to string" error.

I wish Java would debug easier lol

Avatar

By Scrumplex 29 Apr 2016 19:30

Admin · 2,147,483,647 comments

getPermissionGroups() returns a Map<String, PermissionGroup>. You need to call getPermissionGroups().get("Admins") to get the PermissionGroup Object, where you can call isClientInGroup(uniqueid).


The Developer of the Sprummlbot and the Admin of this forum.

Avatar

By Stealth_^ 29 Apr 2016 19:48

Member · 55 comments

So for this I would need to do what? (Sorry I'm sounding like a noob, I'm used to Sourcepawn, and C. Java seems to hate lol)

getCommandManager().setCommandPermissionGroup(globalMute, getPermissionGroups().get("SA"));
Avatar

By Liz3 29 Apr 2016 19:55

Member · 9 comments

Hey,
after reading all this i think a documentation, especially for the plugin system would be create to make the work hell more easier 😄

Greedings,

Liz3ga


16 years old Java Developer and Horse Photographer
Friend of Scrumplex
btw is Liz the name of a Horse
contact on this form if you have questions to me

Avatar

By Scrumplex 29 Apr 2016 19:55

Admin · 2,147,483,647 comments
getCommandManager().setCommandPermissionGroup("globalMute", getPermissionGroups().get("SA"));

You forgot the "


The Developer of the Sprummlbot and the Admin of this forum.

Avatar

By Stealth_^ 29 Apr 2016 21:00

Member · 55 comments

When changing it to the above, it said the following:
Wrong 1st argument type. Found: 'java.lang.String', required: 'net.scrumplex.sprummlbot.wrapper.ChatCommand' less...

setCommandPermissionGroup
(net.scrumplex.sprummlbot.wrapper.ChatCommand,
PermissionGroup)
in CommandManager cannot be applied
to
(java.lang.String,
PermissionGroup)

It also still says where "SA" is "'class' or 'interface' expected"
 

Last edited by Stealth_^ (29 Apr 2016 21:42)

Avatar

By Liz3 30 Apr 2016 00:24

Member · 9 comments

Hey, a far as im coming with you it should look like:

        ChatCommand command = getCommandManager().registerCommand("TheCommand", "Usage tooltip");
        getCommandManager().setCommandPermissionGroup(command, getPermissionGroups().get("yourePermissionGroup"));

Infact of that he finds a string and not an object, try to check exactly this line:

ChatCommand command = getCommandManager().registerCommand("TheCommand", "Usage tooltip");

Keep in mind im not sure, im just trying to help by reading what sefa wrote...

For the second: did you maybe forgot an import?

EDIT:
I tried this and this works fine for me:

Code:

package main;

import com.github.theholywaffle.teamspeak3.api.event.ClientJoinEvent;
import com.github.theholywaffle.teamspeak3.api.wrapper.Client;
import com.github.theholywaffle.teamspeak3.api.wrapper.ClientInfo;
import net.scrumplex.sprummlbot.plugins.CommandHandler;
import net.scrumplex.sprummlbot.plugins.SprummlbotPlugin;
import net.scrumplex.sprummlbot.plugins.events.ClientJoinEventHandler;
import net.scrumplex.sprummlbot.plugins.events.EventManager;
import net.scrumplex.sprummlbot.wrapper.ChatCommand;
import net.scrumplex.sprummlbot.wrapper.CommandResponse;

/**
 * Created by yannh on 30.04.2016.
 */
public class Test extends SprummlbotPlugin {

    @Override
    public void onEnable() {

        test();
        registerCommands();
    }

    @Override
    public void onDisable() {
        // Events, which can be executed after the Plugin has been successfully unloaded.
    }

    public void test() {

        getEventManager().addEventListener(new ClientJoinEventHandler() {
            @Override
            public void handleEvent(ClientJoinEvent ev) {

                int id = ev.getClientId();

                getAPI().sendPrivateMessage(id, "Test");


            }
        });

    }
    
    public void registerCommands() {
        ChatCommand command = getCommandManager().registerCommand("test", "Hi, this is a test");
        getCommandManager().setCommandPermissionGroup(command, getPermissionGroups().get("testperm"));
        command.setCommandHandler(this, new CommandHandler() {
            @Override
            public CommandResponse handleCommand(ClientInfo c, String[] args) {
                if (args.length == 0) {
                    getAPI().sendPrivateMessage(c.getId(), "Lol you did it");
                    return CommandResponse.SUCCESS;
                }
                if (args.length == 1) {

                    getAPI().kickClientFromServer("Youre kicked youre self", c.getId());

                }
                // if you return CommandResponse.ERROR then you can send a custom error: getAPI().sendPrivateMessage(c.getId(), "custom error message");
                return CommandResponse.SYNTAX_ERROR; //sends the usage defined above
            }
        });
    }

}

plugin.ini:

[Plugin]
main = main.Test

[Information]
name = Test
author = liz3ga
version = 0.1

[Commands]
!test = true

permissions.ini:

[Admins]
uid = uid1
group = 6

[Supporters]
uid = uid2
group = 6
inherit = Admins

[VIPs]
uid = uid3
uid = uid4
group = 6
inherit = Supporters

[testperm]
uid = uid2
group = 6

Greeding,

Liz3ga

Last edited by Liz3 (30 Apr 2016 02:02)


16 years old Java Developer and Horse Photographer
Friend of Scrumplex
btw is Liz the name of a Horse
contact on this form if you have questions to me

Avatar

By Stealth_^ 30 Apr 2016 02:24

Member · 55 comments

That is weird. I'm using the most recent release, and I'm STILL getting an error, even with your code copy and pasted, in a brand new project. Hmm....

Array