[ECON/FUN] BuyAbilities v0.7 - Purchase Permissions [556]

Discussion in 'WIP and Development Status' started by rcjrrjcr, Mar 15, 2011.

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


    BuyPermissions - Purchase Permissions:
    Version: v0.7

    THIS PLUGIN HAS BEEN COMPLETED! Go to http://forums.bukkit.org/threads/econ-fun-buyabilities-v0-7-1-purchase-permissions-602.10627/ for the new thread.
    BuyPermissions is a plugin that allows your players to purchase abilities or permissions with iConomy/EssentialsEco money!

    Original Suggestion Thread
    Purchasable Permissions/Abilities

    • Rent permissions
    • Purchase permissions

    Source Code

    Usage Instructions:
    • Plugin commands are "/bab" and "/buyab"
    • From console, "/bab listall" lists all active abilities.
    • From player's chat
      • "/bab categories" returns all accessible categories.
      • "/bab category <categoryname>" returns all abilities in the category.
      • "/bab page" lists all accessible abilites.
      • "/bab current" lists all active abilities.
      • "/bab buy <abilityname>" buys an ability.
      • "/bab rent <abilityname>" rents an ability for a period of time.
      • "/bab rentuse <abilityname>" rents uses of an ability.
      • "/bab info <abilityname>" returns information about that ability.
      • "/bab help <abilityname>" returns the help text about that ability.
    • For admins:
      • To allow usage of the /bab command, grant the permission "buyabilities.use".
      • To allow access to a category, grant the permission "buyabilities.abilities.<categoryname>" where <categoryname> is the name of the category, with periods replacing spaces.
      • A user can access an ability if he can access any single one of its categories. It does not matter if he can access its other categories, just one.
    Version 0.7
    • Added suggestions for ability/category names in case it is misspelled.
    Show Spoiler

    Version 0.6
    • Added usage counters.
    Version 0.5.6
    • Changed package names to conform to Java's naming conventions.
    Version 0.5.5
    • Minor optimisations.
    Version 0.5.4

    • Abilities can belong to multiple categories.
    Version 0.5.3

    • Fixed another NPE due to FakePermissions confusing the plugin.
    • Added permissions to use /bab.
    • Changed category permission format.
    Version 0.5.2

    • Fixed actual cause behind NPE.
    Version 0.5.1

    • Fixed NPE bug when hooking into economy.
    Version 0.5

    • First release. Permissions unsupported though.
    Version 0.01

    • First announced version. Not working yet.

    2. Better and easier implementation of ranks

    • Economy: Support for EssentialsEco and iConomy (100%)
    • Permissions: Support for GroupManager and Permissions (100%)
    • Settings and Storage via YAML (100%)
    • Expiry time checking (100%)
    • Main plugin (100%)
    • Commands (100%)
    • Usage checking (100%)
    Suggestions and ideas are welcome!

    Report bugs by enclosing the exception's stack trace, your costs.yml and data.yml in spoilers.
  2. Offline


    Obviously I'm looking forward to this ;)
  3. Offline


    First release! Only GroupManager is supported for now as Permissions lacks a way for me to remove/add permissions.
  4. Offline


    Heh, darn =P I only use permissions on my main server because I dislike how GM re-formats your permissions file every time (getting rid of comments and such) but I'll test it out on another test server.

    If this works well I'll just have to switch.
  5. Offline


    Same here.:) However, the way I'm adding permission nodes for Permissions 2.5.4 is not working. I poked around in the source and found out that the newly added permission is not checked.:( I posted in the Permissions thread and also added an issue to its GitHub repo as I said in the first post. Hopefully it will be fixed.

    EDIT: There's a very "hacky" way to make Permissions see the new permissions but it involves editing the world.yml file directly and forcing a refresh. Not nice, though. I'll see how it works.
  6. Offline


    Yikes, yeah, would be good if there was a way without forcing a refresh.

    One suggestion would be to disable it if no economy plugin can be found; at the moment it throws some Null Pointer Exceptions if you don't have one in place. Will test it more now.
  7. Offline


    Hmm? NPEs? Can you tell me what plugins you use and post the entire stack trace too?

    EDIT: Found the bug. Forgot to implement empty Economy interface if iConomy/EssentialsEco haven't been activated.

    Version 0.5.1 uploaded. NPE bug fixed.

    Version 0.5.2 uploaded. Cause behind NPE fixed. Plugin was checking for the status of the permission plugin instead of the economy plugin?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 12, 2016
  8. Offline


    For testing I currently have the following plugins:
    ioncannon v1.1

    /bab categories triggered the in-game message:
    "An internal error occured while attempting to perform this command" with this console error message:
    09:50:18 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'bab' in plugin BuyAbilities v0.5
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:37)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:80)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:229)
        at net.minecraft.server.NetServerHandler.c(NetServerHandler.java:645)
        at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:608)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:602)
        at net.minecraft.server.Packet3Chat.a(SourceFile:24)
        at net.minecraft.server.NetworkManager.a(SourceFile:230)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:76)
        at net.minecraft.server.NetworkListenThread.a(SourceFile:100)
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:357)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:272)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    Caused by: java.lang.NullPointerException
        at com.rcjrrjcr.bukkitplugins.BuyAbilities.PermissionsInterface.PermYetiHandler.hasPerm(PermYetiHandler.java:31)
        at com.rcjrrjcr.bukkitplugins.BuyAbilities.BuyAbilities.hasPermission(BuyAbilities.java:536)
        at com.rcjrrjcr.bukkitplugins.BuyAbilities.Settings.Settings.getCategories(Settings.java:98)
        at com.rcjrrjcr.bukkitplugins.BuyAbilities.BuyAbilities.commandHandler(BuyAbilities.java:308)
        at com.rcjrrjcr.bukkitplugins.BuyAbilities.BuyAbilities.onCommand(BuyAbilities.java:229)
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:35)
        ... 12 more
    The same thing happens with all commands except "/bab current", where it says is in-game that "no abilities are currently active"

    Here is my current costs file:
                name: 'Chicken Bombs'
                description: 'allows user to fire exploding chickens'
                help: 'right click with a feather to fire chickens'
                - 'chickenBombs'
            category: 'fun'
                    cost: 10000
              # permanent ownership of that permission
                    cost: 100
                    duration: 30000
                  # time-based ownership of that permission
                name: 'ion cannon'
                description: 'pew pew'
                help: '/ioncannon <width>, click to fire'
                - 'ioncannon.ioncannon'
            category: 'combat'
                    cost: 10000
                    cost: 1000
                    duration: 3000
    Also, a permissions for the use of /bab would be good to have.

    =Edit= Still happens with 0.5.2
  9. Offline


    Ah. I think FakePermissions is causing the problem by making my plugin think that TheYeti's Permissions is active instead of GroupManager. Going to make changes now. v0.5.2 fixes a different error pertaining to Essentials.
    Sounds interesting. I'll think about it.

    Version 0.5.3 released.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 12, 2016
  10. Offline


    Could you also have it so that one ability can have many categories? You might have an ability that's both 'fun' and 'construction' like magiccarpet.

    Just have the costs file be this:

                 - 'fun'
                 - 'construction'
  11. Offline


    Well, that would be quite a challenge as I have to weed out duplicates when listing all abilities. I'll try.

    Version 0.5.4 released. An ability can now belong to multiple categories. Costs.yml format has changed. Look at included costs.yml for examples.

    I will be on holiday tomorrow (actually today, considering the time) so don't expect any releases until Saturday 4AM GMT.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 12, 2016
  12. Offline


    Great, I'll test it when I have time. Enjoy your holiday, and thanks again for this. Been wanting a plugin like this since before hmod.
  13. Offline


    Version 0.5.5 released. Managed to optimise a few lines of code. Should make not much difference though. If any new errors come up, please report them.

    Will examine ways to monitor command calls from players without registering the commands in plugin.yml.
  14. Offline


    Maybe some video?

    Idea of this is good, but I dont understand how to do it all. :D

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 12, 2016
  15. Offline


    I think it's a little early before a video would make sense, but once it's working correctly and most of the features are in i'll be happy to make a video explaining what to do.
  16. Offline


    Sorry about the unclear instructions. I didn't have much time to write about the new features between releases.

    Apparently, in order to check how many times a player has used a command and decrement the amount of uses left if applicable, I have to add a wrapper around each plugin and override their commands' CommandExecutors with my own, which chains to the plugin after decrementing the amount of uses left. I can't monitor other plugins' commands via a PlayerListener since the change to onCommand from PLAYER_COMMAND.

    If you didn't understand what I said above, don't worry. I'm confused too.

    On another note: Maybe I should include a search function so as to help you find the ability you want even if you misspell the name. Probably will do that after version 1.0.

    Ugh. Poked around in bukkit's source, and realised that it would require unimaginable contortions to seize control of other plugins' commands when they get enabled. Probably will postpone implementing usage counters.

    Maybe I should move this into the plugin submissions forum, since the core features are complete.

    EDIT: Version 0.5.6 released. If there are no more bug reports or suggestions, I will move this to a new thread in the Plugin Submissions forum.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 12, 2016
  17. Offline


    Is it possible when you use /tp /tphere /home /back /warp /time it takes everytime some money from you. No permanent or time based.
  18. Offline


    I did more poking in the source, and found out that though there was a way to monitor commands, I can't tell if the command failed, only if it was used. So no usage counters or pay-as-you-use schemes. And monitoring usage alone is complicated enough. I have to "steal" each command after the plugin is enabled and the sheer amount of code on my part and configuration on your parts (i.e. specifying plugins to hook into, commands to monitor, etc) is not worth it. Yet.
  19. Offline


    This is taking quite a bit to figure out. What's up with the data file not matching the default costs file.

    Also can we get a how to for configuring the 2 files or at least a default with more #info things in it.

    I cant seem to get away from errors in this unfortunately. Tried many different things, bottom line is cb 556, bab .056 is simply not working. The error messages are very unclear. I type /bab it says incorrect syntax instead of bring up a help menu. Confusing setup instructions for the data file, cost file. The default config is giving me many errors just trying to look at the command info. Even if i did get this working i dont think any users would be capable or have the patience to navigate the /bab menu.

    Excellent idea however
  20. Offline


    Sorry about the lack of documentation. My school holidays just ended and I'm stuck with a huge pile of homework. Admittedly, the syntax of the costs.yml is pretty confusing. I plan to write a better one when I have the time. The data.yml should only be edited by the plugin so don't worry about it.

    I plan to work more on this when I have the time. I shouldn't read TvTropes so much.
  21. Offline


    Version v0.6 released! This version now has usage counters! I finally noticed how to do the command monitoring the easy way via PlayerCommandPreprocessEvent. Took me long enough.:)

    EDIT: I seriously think that I should submit this plugin already. Should I?
  22. Offline


    It's up to you, myself I'd hang on until Permissions got in line so I could appeal to the widest audience the first time they see my thread in the forum. Then again, early "marketing" doesn't hurt and if the permissions dev sees people wanting your plugin to work with theirs it might motivate them further.
  23. Offline


    Version 0.7 released! This will be the (hopefully) final in-development release. Once I finish the documentation, I will submit this plugin. Added a new feature. If a user misspells a ability/category name, the plugin will give suggestions.
  24. Offline


    Version 0.71 released at new thread. Plugin submitted.
Thread Status:
Not open for further replies.

Share This Page