Inactive [FUN] Lottery 0.6.3 - Let your users buy tickets to a lottery - [superPerms] [1060]

Discussion in 'Inactive/Unsupported Plugins' started by Erbros, Mar 14, 2011.

  1. Offline


    Lottery - The Lottery Plugin:

    I will only be using the BukkitDev website from now on. Please ask for help, submit bugs or enchantments and download the plugin from my page there (LINK).

    This thread is no longer updated - check my page on BukkitDev.

    Beware: Now only supporting superPerms from 0.6.2 and onwards!

    Version: v 0.6.2

    This plugin lets your users buy tickets for a price you decide to a lottery drawing.

    • Users buy a ticket and can win the money of everyone that have bought a ticket.
    • Configurable price, material (including money/coins) and hours between lottery drawings.
    • Supports iConomy v4, iConomy v5, iConomy v6, BOSEconomy v6, BOSEconomy v7, Eco Essentials and MultiCurrency. Thanks to @KHobbits
    • Permission nodes supporting superPerms (Bukkits default permission system)

    The Lottery Plugin v. 0.6.2

    Old releases:
    Source Code (This is my first project ever in java, so I would appreciate any advice in

    how to improve my coding very much)


    In the configuration that is made when the plugin is run the first time, you don't get comments about the different options. Here you do!

    #How many hours between every lottery drawing? Only whole numbers above 0 (like 1 or 2 or 3.... 24 or 25...)
    hours: '24'
    # The next execution option is really not to be touched. Its time in millisecs since 1. January 1970.
    nextexec: 1300368259883
    # Cost is the amount the buyer got to pay to buy a ticket. This applies both to iConomy coins and material. Only whole numbers. Negative numbers will probably work, but I don't see the point.
    cost: '5'
    #The material setting lets you choose which Material Value your users got to pay with, and get if they win. (its the "dec(imal)", value)
    material: '266'
    # If you want to use iConomy coins, set it to "true". If you want to choose your own material (block or item), set it to false.
    useiConomy: 'false'
    # If broadcastBuying is set to false, there will not be sent a message to every player when somebody buys a ticket.
    broadcastBuying: 'true'
    # welcomeMessage decides if there should be sent a message to the player on join about time until draw.
    welcomeMessage: 'true'
    #extraInPot just holds the amount of extra winnings in the pot has been added with /lottery addtopot
    extraInPot: 0
    #clearExtraInPot decides whether the plugin set extraInPot=0 after lottery draw, or if the same amount will stay until somebody changes it with /lottery addtopot <+/-> <amount>
    clearExtraInPot: true
    #netPayout is the percentage of the total pot that is being paid out to the winner. This can be as large as you wish, but not lower than 1 (one). 100 = 100%, which means the winner will get exactly as much as the players have paid in while buying tickets.
    netPayout: 100
    #maxTicketsEachUser sets the max amount of tickets each player can buy
    maxTicketsEachUser: 1
    #debug - This won't show up by itself, and there is really no reason for you to have this unless there is something wrong with your install of the plugin.
    debug: false
    /lottery : Basic information
    /lottery buy <number> : Buy one or <number> of tickets.
    /lottery help : Help pages
    /lottery winners : List over 10 last winners
    /lottery draw : Force the drawing to happen. Op only if not permission plugin.
    /lottery addtopot : Adds extra money/items to the pot. Op only if not permission plugin.
    /lottery config <cost/hours/max/maxTicketsEachUser/reload> : Change/reload the config ingame.

    If you have Permission plugin installed you must add the nodes you need to the config. : Gives you all the basic rights /lottery (buy, help, winners).
    Given to all players by default, remove from users/groups if you want to deny them.
    lottery.admin.draw : Gives the group/user access to the /lottery draw command.
    Given to OP's.
    lottery.admin.addtopot : Gives the group/user access to the /lottery addtopot command
    Given to OP's.
    lottery.admin.editconfig : Grant access to edit/reload the lottery config ingame NEW
    Given to OP's.

    Version 0.6.3:
    • Fixed ClassCastException when using commands from console.
    Version 0.6.2:
    • Supporting superPerms.
    • Removed support for any other permission system.
    • Fixing plugin.yml, so even those not using superperms will have basic given to all users by default, and all OP's will get admin commands.
    Version 0.6.1:
    • Removed showing days in time until draw.
    Version 0.6.0:
    • Adding ability to reload config ingame.
    • Edit the config variables cost, hours and maxTicketsEachUser ingame.
    • Debugging information.
    Old Changelogs (open)

    Version 0.5.6:
    • Hopefully fixed lottery not drawing when it should..
    Version 0.5.5:

    • Fixing users able to buy negative amount of tickets (and again... very stupid mistake by me....)
    Version 0.5.4:

    • Fixing users able to buy negative amount of tickets (again since I forgot to re-add it after merge).
    • Giving users the remaining tickets they can buy if they try to buy too many.
    Version 0.5.3:

    • Max number of tickets a user can buy.
    • Typos
    Version 0.5.2:

    • Implemented a lot of changes by @KHobbits
      • Now supporting iConomy4, iConomy5, iConomy6, BOSEconomy6, BOSEconomy6, MultiCurrency, EcoEssentials
      • Code cleanup
    Version 0.5.1:

    • Don't let players buy a negative amount of tickets... Stupid error...
    Version 0.5.0:

    • Users can buy more than one ticket each now.
    Version 0.4.5:
    • Fixed so correct lottery amount is shown everywhere, WinningAmount() implementing netPayout;
    • Ability to let the plugin remember the money that is added to extraInPot.
    • Fixed NPE when "/lottery addtopot" wasn't followed by a number.
    Version 0.4.4:

    • Added payout percentage configuration.
    • Attempt to fix some of the "waiting for draw to occur" on servers with slight lag.
    Version 0.4.3:

    • Updated for iConomy v5. Not working with v4 anymore.
    • Fixed a new system for timers, it shouldn't take that much time to do a draw even on a laggy server.
    • If time is set to lower in config than is remaining on countdown, set to new value.
    Version 0.4.2:

    • Not setting extraInPot to 0 after draw, only saving it to config.
    • Draw in: -51 seconds no longer occur, now its "Draw in: Draw will occur soon"
    Version 0.4.1:

    • Fixed: Not saving config after updating extraInPot.
    Version 0.4:

    • Permission support
    • Command to add extra money in pot.
    Version 0.3.1:

    • Fixed timers not closing properly. Possible memory leak! Important update!
    Version 0.3:

    • Info about pot size in /lottery
    • Choose if you want players to get time until draw message on join.
    Version 0.2.4:

    • Fixed the same problem as in last release, just properly this time.
    Version 0.2.3:

    • Changed from onPluginEnable to PluginEnableEvent.
    Version 0.2.2:

    • Option to broadcast public to the whole server when somebody buys a ticket.
    • Added colors to the lottery chat messages.
    Version 0.2.1:

    • Formatting material names. GOLD_INGOT -> Gold ingot
    Version 0.2

    • Added commands: /lottery (help, winners, claim, draw)
    • Added material support.
    • List over 10 last winners with /lottery winners
    Version 0.1

    • Lottery plugin is released.


    Video by @ValBGaming

    PS: The /lottery claim command is used when you are using material and you win, since blocks/items can only be given to online players :)


    • A set number of tickets available, and let the user choose which one to buy. If nobody had the right ticket, add money to jackpot for next drawing. (low)
    • Using configurable array of prize items instead of getting whats in the pot. (low)
    • Show time left when it's 2 hours left, 1 hour left etc. Configurable. (low)
    • Let admins give out free tickets. (normal)
  2. Offline


    I will see if I can implement this one! :)

    I'll implement something like that, yes :)

    Do you have iConomy? Thats the first and easiest explanation I find to this error. I will have to find out how to stop my plugin if iConomy is not found.

    It will apply next time the lottery is restarted. If you want to force it to restart at once, do "nextexec: 1"

    This is a but much right now, but i will add it to the todo. But perhaps as its own plugin, when the time comes, as this one is a bit simpler. :)

    So price is items and you pay with coins? Will check if I can add that too! :)

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


    yeap, dont have iconomy sorry.
    i am really noob at this.
    Thanks for your repsonse.
  4. Offline


    k /nextexec: 1 doesn't work
  5. Offline


    Great idea. I'll be checking it out soon, I'm wondering, are you planning on adding a feature to where, say a user pays for the lottery ticket, but instead of winning the money from other users, the player wins a random item (or items). Maybe have the items configurable by item ids, and then there is also a chance to win multiple of the same item? Such as, maybe the user will win 1 block of clay, or maybe he will win 24 iron pickaxes? Something like that? And just incase the inventory is full, maybe have like /lottery claim command to dump the winner's items into his/her inventory once they have made space? I know it's alot to add, but I think it would greatly improve this plugin!
  6. Offline


    If its important, change the Lottery/config.yml.

    nextexec: 1

    Then start the server. But its easiest just to wait and let it be 6 hours on next lottery round (or what you changed it to).

    This is something that will take a bit of time, but I can see if I can eventually add it in a bit :) The /lottery claim will probably be created at once, since I need it for another feature.

    Everyone got to start somewhere :) It will be easy when you get the hang of it! ;)

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


    hey dude can u atleast until u make it let players know who won last 5-10 times atleast make it so in the file it says winner's name?so i can tell my players xD
  8. Offline


    thanks man that worked I was typing the command didn't know I had to put it in the config lol.
  9. Offline

    Binder News

    After taking a look at your code, I have a few small suggestions.
    1: Move the LotteryDraw class to it's own file. It makes it more organized.
    2: Move the unnamed CommandExecutor to it's own file. For the same reason.

    Other than that, it looks good. Great for a first project.
    (My first project ever was so messy I couldn't even fix a simple bug, I just dropped it at that point).
    Erbros likes this.
  10. Offline


    I'll try to add that, yes. :)

    Good thing its working :)

    Thank you so much for the feedback! :) I'll try to follow your suggestions to clean the code up a bit! :)
  11. Offline

    Binder News

    Welcome. :) As a guideline, unless it is something stupid like a listener that has one method and does one thing ex:
    new WindowAdapter(){
      public void onWindowClosing(WindowEvent e){System.exit(0);}
    put it in it's own file. That way, you don't have to scroll through 100+ lines of one class just to get to the one you wanted to work on. [​IMG]
  12. Offline


    I've soon finished coding the alternative to iConomy payment, but I haven't bugtested it yet. Something tells me I won't be able to release a 0.2 until tomorrow.

    Yeah, I noticed now that it's starting to get annoying scrolling up and down all the time. Not sure how to devide them though, I don't want 10 files. Will have to think about organizing so I can easily recall what's in which file. Appreciate the feedback :)
  13. Offline

    Binder News

    Use an IDE (Integrated Development Environment). NetBeans and Eclipse are two good ones.
    Here is a link to a plugin I'm working on but haven't released yet. You'll see I have like 13 source files.
    With an IDE, it's much easier to keep track of what's what. It also helps if you have appropriately-named files.
  14. Offline


    thank you for this i will be adding it to my server tomorow when i upgrade it to 531 :)
  15. Offline


    Thank you for the tips. :) I am already using Eclipse and finding it very satisfying :)

    Your code is really amazing, and even tho I understand most of it when I see it written, it ain't natural for me to write code object orientated. It will probably take some time until I can write something at that level :p
  16. Offline

    Binder News

    Thanks! :)

    Am I right that you know another programming language then? What is it?
  17. Offline


    do u have any specific permissions setup code?

  18. Offline


    I have not integrated permission support yet. Will do that as soon as I get around to it. Should be fairly simple.

    I've been coding on and off in PHP the last 5 years (mostly off :p ). Just love the simplicity of it, and on the same time you can do nearly everything with it. But its been a while since last i scripted something big in php, and now I found it to be a nice time to learn some basic java :) You interested/experienced in other languages than java?
  19. Offline

    Binder News

    Yup. I do Java, Z80 Assembly, C++, and a little C#.
    I'm learning PHP, and re-learning JavaScript.
  20. Offline


    I am so going to learn C++ (at least C#) some day! :)
  21. Offline


    two requests.

    have /lottery show the current amount of money you can win.

    Have it announce when someone wins by displaying there name and saying how much they one.
  22. Offline


    The first I will add, the second is already implemented! :)
  23. Offline


    Thanks, that would be awesome :)
  24. Offline

    Josh Harwood

    can this support realshop's accounts?
  25. Offline


    Not at the moment, no. As far as I can see, the realshop developer has not released an api for other plugin developers to support his own economy. If you want to use this, you'll either have to wait for 0.2 (coming today) and use materials instead of money, or install iConomy. :)
  26. Offline


    For some reason the lottery time for the drawing has gone negitive. now drawing a winner 0n -44 seconds and its still going. any idea
  27. Offline


    Server dont detect the plugin at all
    Output from server.
  28. Offline


    I've experienced the same problem earlier, but not sure what the problem is... I will check it out! You have changed your config? Hours is not default? Did you restart server after the change?

    Did you get any info when you started the server? You are sure the download was correct?
  29. Offline


    i posted it and i downloaded the link at the top
  30. Offline


    As it seems it can't find the main class, and find no errors in the Lottery.class file, I think the problem must be that the plugin has not been downloaded correctly. I can't find any other reason, sorry. ;/
  31. Offline


    ok il redownload

Share This Page