GiftOfTheDay
Summary
This plugin allows players to receive a "semi-random" reward on first login of the day. Items, stack and rate can be changed simply by editing the gifts.yml located in plugin/GiftOfTheDay. Originally developped in order to rewards players of my server (for being so great ! :D), I decided to share it with the minecraft community :).
gift.yml structure
- Gifts:
- 'rollChance':
- 'item id':
- amount: How many items you want to give
- distribution: Either 'linear' or 'exponential' or 'normal'. Everything else will be considered as 'linear'
You can have a full example here
About distribution methods
- linear: Regular distribution. You have as many chances to get the object as the amount you specified
- normal: "Gaussian" distribution. Most of the time, you'll receive an amount close to the one you specified. But from time to time you might receive a very different quantity.
- exponential: You receive at least the specified amount. You can also receive more.
- invertexponential: Very often, you'll receive the specified amount. You can also receive more but chance decrease.
Permissions
- gotd.admin: Allow to use both resegift and regift command
- gotd.receive: Allow to receive the gift (doesn't work for the moment)
Commands
- /regift <player>: Give another gift to specified player
- /resegift <player>: Reset the last gift date for specified player
Planned features
- None for the moments
Known issues
- Exponential distribution can be improved in my opinion.
When I start my server it says this:
Could not load 'plugins/GiftOfTheDay.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException java.lang.NoClassDefFoundError org/bukkit/event/player/PlayerListener
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153)
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)
at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:222)
at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:565)
at org.bukkit.Bukkit.reload(Bukkit.java:183)
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:21)
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:168)
at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:492)
at org.bukkit.craftbukkit.CraftServer.dispatchServerCommand(CraftServer.java:488)
at net.minecraft.server.DedicatedServer.ah(DedicatedServer.java:248)
at net.minecraft.server.DedicatedServer.q(DedicatedServer.java:213)
at net.minecraft.server.MinecraftServer.p(MinecraftServer.java:476)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:408)
at net.minecraft.server.ThreadServerApplication.run(SourceFile:539)
Caused by: java.lang.NoClassDefFoundError org/bukkit/event/player/PlayerListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:41)
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:29)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at hathor.giftoftheday.GiftOfTheDay.<init>(GiftOfTheDay.java:30)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:149)
... 14 more
Caused by: java.lang.ClassNotFoundException org.bukkit.event.player.PlayerListener
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:41)
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:29)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 33 more
Nice :D
Fixed !
You can now have only one item in the gift list. That was something I've never tested.
Please update it for 1337 !
When a player join :
2011-10-26 12:49:41 [SEVERE] Could not pass event PLAYER_JOIN to GiftOfTheDay java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 at java.util.ArrayList.RangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at hathor.giftoftheday.GiftOfTheDay.GetItemId(GiftOfTheDay.java:285) at hathor.giftoftheday.GiftOfTheDay.givePlayerGift(GiftOfTheDay.java:244) at hathor.giftoftheday.GiftOfTheDay.onPlayerJoin(GiftOfTheDay.java:182) at hathor.giftoftheday.GOTDPlayerListener.onPlayerJoin(GOTDPlayerListener.java:20) at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:260) at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58) at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:339) at net.minecraft.server.ServerConfigurationManager.c(ServerConfigurationManager.java:129) at net.minecraft.server.NetLoginHandler.b(NetLoginHandler.java:121) at net.minecraft.server.NetLoginHandler.a(NetLoginHandler.java:39) at net.minecraft.server.NetworkListenThread.a(SourceFile:94) at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:471) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:374) at net.minecraft.server.ThreadServerApplication.run(SourceFile:417)