[INACTIVE][INFO] Calendar v1.51 - Track the Days [271]

Discussion in 'Inactive/Unsupported Plugins' started by Multimac, Jan 27, 2011.

  1. Offline


    This plugin allows for players to see exactly how many days have passed since the creation of the world.

    • Server broadcasts message at the beginning of each day.
    • Use commands to get information about today.
    • Ability to customize daily message.
    • Add events for certain days (in Calendar\\events.data).
    • Change the name of each day and month (in Calendar\\calendar.data).
    • Event hooks for each new day.

    All commands are under /c
    • /c date - Gets the current day.
    • /c time - Gets the time.
    Date Format:
    There are 7 properties that can be used when customizing the date format, these are:
    • %dd - Prints the current Day.
    • %dddd - Prints the Day of the Week.
    • %wd - Prints the Day of the Week as a Number.
    • %ww - Prints the Week number.
    • %md - Prints the Day of the Month.
    • %mm - Prints the current Month.
    • %yyyy - Prints the Year number.
    Here are some example formats:
    Show Spoiler

    Example: %dddd, %md of %mm, %yyyy
    Prints: Saturday, 15 of June, 2

    Example: Day %wd, Week %ww
    Prints: Day 4, Week 14

    Example: %md/%mm/%yyyy
    Prints: 15/June/2

    Example: Good Morning, Today is day %dd
    Prints: Good Morning, Today is day 103

    Example: Today is day %md of the month of %mm, year %yyyy
    Prints: Today is day 15 of the month of June, year 2

    Event Hooks:
    To use the hooks in this plugin, simple create a class which extends the CalendarListener class, and call AddCalendarListener, passing it your CalendarListener.
    When this event is fired, it passes a CalendarEvent. The CalendarEvent contains the total number of days which have passed (as a long), and the current day of the week (as a String).

    To Do:

    • Add commands to get date and time of day.
    • Add the ability to set events on certain days and at certain times.
    • Add event hooks for other plugins.
    • Change to allow for specific dates (ie. 23rd June, 2013).
    • Add in any extra features suggested

    1) Extract the Calendar.zip and copy the Calendar.jar and Calendar folder into your plugin directory.
    2) Run your server.
    3) Open the calendar.data in the plugin\Calendar directory.
    4) Edit any of the properties, or just leave them as they are.

    Show Spoiler

    • Fixed bug with /c date command.
    • Added event hooks for other plugins.
    • Added customizable events (in Calendar\\events.data)
    • Added ability to customize the format of the daily message (DateFormat in calendar.data)
    • Added the CustomDate property. Leave false to use a default 'earth' date, or set to true if you want a custom date.

    • Forgot to change some parameters i use for debugging (should only be a problem with v1.2 and v1.21), all fixed now.
    • Removed code leftover from attempted custom events.

    • Updated to work with latest build of Craftbukkit (build 271).

    • Fixed bugs in creating the date.
    • Changed calendar.data to include 4 new properties (showdayname, showweek, showmonth, showyear).

    • Fixed null pointer exception when getting date.

    • Fixed an error in the new version of bukkit in getting the time.

    • Fixed command bug.

    • Fixed date not being in correct format when using /c date.

    • Changed path location, hopefully fixing error on Linux.

    • Implemented customisable days and months.

    • Fixed a couple of numbers.
    • Implemented commands.

    • Initial release.

    Attached Files:

    Riot and mezzamorta like this.
  2. Offline


    Helpfull tip: If java has a var++ function: You could easily implement tracking (if your not using ++ it could messy your code a bit). Also, just simply call the day variable on command to reveal the day. I dont know java but heres what this plugin would look like.
    int day
    day= day++
    if (day == 1) cout >> "Happy new Year!"
    if( Player_Command == "/getday") cout >> day
  3. Offline


    day=day++ should be replaced with just ++day (also with c++ as you code looks like, good ol' cout)
    1) because ++(both prefix and postfix) actually change the variables state
    2) prefix is inherently faster than postfix (postfix generates a new local integer whereas prefix doesn't)

    also are you using the Gregorian Calender, if so there is a certain year that the leap year changes from just every forth year to every forth year, except centuries unless it is a multiple of 400, though i don't know if you are being that specific
  4. Offline


    just a question how does this handle the /time day-/time night commands? is a day added? skipped? just curious.
  5. Offline


    Ok, good points. I was just mindlessly rambling possibilities. I didn't think that speed was an issue, however, Since you loose only milliseconds. Although, a good developer has good program gears (I am not a good developer). No I wasn't being that specific.
  6. Offline


    well, i do low level code on embedded devices from time to time so every little bit helps IMO and this holds to servers running minecraft as sometimes that little code (++var instead of var++) happens a lot which can add up, hence why i usually point it out.

    Also would only say i am a mediocre developer as i am still in school (Junior in CS) and haven't worked in the field yet
  7. Offline


    Good question. Since I do not know how it actually calculates the time, I do not know. However, I will make an assumption. Assuming the code is:
    int sunrise=x (in minutes)
    int day=0
    if (time == sunrise) day++
    then if you set the time to day, at say day 1, then time is pushed back to morning at sunrise (I believe) and that would register day 2. Durning night, if you set the time to raw data, say to what ever variable midday is, then Calendar would still be on day 1. However, I do not have the code to make any actual insight.
    --- merged: Jan 28, 2011 4:13 PM ---
    Still, your absolutely right about the prefix-suffix. Although, I still don't think I will remember about it. I am also still in school and much younger than you.
  8. Offline


    The way this calculates time is by getting the time from the server (which is between 0 and 24000, where 0 is just after sunrise) and checks if the previous time is greater than the current time (ie. if the server time just went from 23990 to 10). I haven't tried messing with the time with this enabled, but my assumption would be that so long as you don't go back in time, or go to the next day, nothing will happen (but i don't know how the time changing works), however if you do change days/go back, then only 1 day will be added.

    As for the plugins that stop time all together, they would not interfere at all with this.
    --- merged: Jan 29, 2011 2:28 AM ---
    Currently there is no specific dates implemented, however this would be a great idea. Right now it only tracks the number of days that have passed. I'll have a look into making it give out actual specific dates (ie. 23rd June, 2013).

    Oh, and thanks for the pointer about the prefix-suffix thing, i'll change that now.
  9. Offline


    might be better to just make the months and such configuable. Maybe i would like my July to be called, Flamerule, and december to be called Frostmourn. just a suggestion :D
  10. Offline


    How about Oblivion time?
    Months in order (Morningstar, Sun's Dawn, First Seed, Rain's hand, Second Seed, Midyear, Sun's hight, Last Seed, Heartfire, Frostfall, Sun's Dusk, Evening Star)
    Days in order (Sundas (Sunday) Morndas (Monday) Tirdas (Tuesday) Middas (Wednesday) Turdas (Thursday) Freedas (Friday) Loredas (Saturday) )

    string month
    int day
    if day == 31 && month == "Morningstar"
    month="Sun's Dawn"
    if day == 31 && month == "Sun's Dawn"
    month="First Seed"
  11. Offline


    Thanks for the suggestion axebyte, just put that in now. In the calendar.data file there are 4 new properties (daynames, weeklength, monthnames, monthlengths).

    *NOTE* if you have anything in the daynames field, then the weeklength field will be ignored.
  12. Offline


    That was quick. Text input is something I seriously am bad at doing. Nice work! This will be a nice plugin. I'll download soon, but I fully support you. Now to do custom events :) may I request this please? Like
    if [ day == 1 && month = Morningstar ]
        cout << "Happy New Year!"
  13. Offline


    I suspect you have windows specific file paths in there. The created calendar.data on my linux box appears as a file named Calendar\calendar.data, not in the also created folder.

    If I recall correctly, Java has build in methods for handling paths system independent. (A brief google gave me http://download.oracle.com/javase/1.4.2/docs/api/java/io/File.html, which seems to have some details. There is a system property file.separator)
  14. Offline


    Hopefully the new version has fixed the problem with the windows specific paths, thanks for the tip about the file.separator.

    I will add in custom events tomorrow.
  15. Offline


    I am wondering about the format for names. I'll have to play around a bit i guess.
    --- merged: Jan 29, 2011 11:49 PM ---
    Also, Monthname does not appear upon calling the date.
  16. Offline


    Fixed that bug about date not showing correctly. Hopefully custom events will be up in a couple of hours.
  17. Offline


    Calander v1.01 collides with LWC's /cprivate (v1,47)
    Show Spoiler

    2011-01-30 22:46:06 [INFO] Anoniempje issued server command: lwc
    2011-01-30 22:46:06 [INFO] Unknown console command. Type "help" for help.
    30-jan-2011 22:46:21 org.bukkit.plugin.SimplePluginManager callEvent
    SEVERE: Could not pass event PLAYER_COMMAND to Calendar
    java.lang.ArrayIndexOutOfBoundsException: 1
    at com.bukkit.Multimac.Calendar.CalendarPlayerListener.onPlayerCommand(C
    at org.bukkit.plugin.java.JavaPluginLoader$3.execute(JavaPluginLoader.ja
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    at net.minecraft.server.NetServerHandler.c(NetServerHandler.java:584)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:557)
    at net.minecraft.server.Packet3Chat.a(SourceFile:24)
    at net.minecraft.server.NetworkManager.a(SourceFile:232)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:70)
    at net.minecraft.server.NetworkListenThread.a(SourceFile:104)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:276)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:202)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:512)
    2011-01-30 22:46:21 [WARNING] Can't keep up! Did the system time change, or is t
    he server overloaded?
  18. Offline


    are you sure your not just running a compatible build? I see
    SEVERE: Could not pass event PLAYER_COMMAND to Calendar
  19. Offline


  20. Offline


    What because the plugin is missing a little bukkit build number in brackets?
  21. Offline


    It'd be nice to see how the day/month names should be formatted.
  22. Offline


    Its kinda hard to explain, but its based on what you have in the calendar.data file.

    If you have defined months and days, then it will print out the day like this 'Saturday, 15 June 2'
    If you only have months defined then it is '15 June 2'
    If you only have days defined then it is 'Saturday, Week 22'
    If you don't have any days defined, but have a week length defined, then it is '6, Week 22'
    If you don't have anything defined then it is 'Day 913'
  23. Offline

    Nick Stevens

    I think he meant how should the datafile should be formatted when entering day/month names. I would also dearly love to know as I already have a set made up in my head but everything I've tried entering so far hasn't worked.
  24. Offline


    Oddly, It doesn't. I get a print of "Sundas, Week 30"
  25. Offline

    Benjamin Groves

    I am in a similar boat as Nick - Can anyone please provide an example calender.data file? Maybe one that provides the normal "Saturday, February 5" style of formatting?

    I would greatly appreciate - Much thanks.
  26. Offline


    I agree, I've tried entering a few things, and I haven't gotten it to work yet. An example of the normal "Earth" format would be great.
  27. Offline


    ...except for the fact that he obviously did, and in multiple posts. (The topic isn't even over a page long and you STILL didn't bother to read the whole thing?) This is really just hateful bashing and as polite as you tried to guise it, it does nothing constructive for anyone.
    And if you're honestly not sure how this is used, or you think it's underdeveloped, you could bookmark it and just, you know, wait for him to add stuff, change stuff, or improve things to your taste (which he'll likely do if you ask nicely.)

    Moving on...
    I definitely think I'll try this mod on my server, but I have a question first- does it check when the map was first created or something, or does it go from when the mod is first installed (or whenever you edit the date to)? I'm referring to the "Day 19" format. It'd be a little weird if the amount of days it said was actually off by a few, especially since my map is relatively new.
  28. Offline


    Currently it goes by how long this mod has been installed, as there is no way of getting exactly how long it has been since the world's creation (time is reset each time the server is stopped).
    I think there are a couple bugs in the latest version to do with getting the actual date, i'll try and have a update out shortly (including a template calendar.data file).
    --- merged: Feb 7, 2011 11:39 PM ---
    Ok, a new version is up. Hopefully this clears up some of the confusion about how the date is generated.
    Now you must have some days, months and month lengths defined, but you control what is printed with the show___ properties.
  29. Offline


    I like the idea of this plugin, so I am trying to impliment it now, thanks for the plugin :D

    Could you possibly have a setting like
    ##The following will not be used if CustomDates is false##

    So that it will be a regular earth calander? Monday - Sunday, 12 months, all month names, and the reason I ask, those wierd months that are 30 days long, 31 days, 29 days, and 28 days?

    The reason I ask is just to be more realistic I suppose.
    It also opens the door for a possible seasons plugin >.> <,<

    As well, could you add a file that will excecute certain triggers when something happens?
    I'm sure somebody else could find cooler requests for this (Like have another mod do something..)
    but I really just meant:
    OnDay= say "Good Morning! The day is %d " etc...

    So basically i'm just asking for custom text triggers upon Day, Month, Year, Specific dates.. etc...

    Let me know, and thanks!

    Also, any idea why i'm getting this error?
    2011-02-07 19:01:07 [INFO] [BackupPlugin] (com.mysticx.bukkit.backupplugin.Backu
    pPlugin) BackupPlugin version 0.8.5 is enabled!
    Feb 7, 2011 7:01:07 PM org.bukkit.craftbukkit.CraftServer loadPlugins
    SEVERE: org.bukkit.Server.getWorlds()[Lorg/bukkit/World; (Is it up to date?)
    java.lang.NoSuchMethodError: org.bukkit.Server.getWorlds()[Lorg/bukkit/World;
            at com.bukkit.Multimac.Calendar.TimeWatcher.start(TimeWatcher.java:27)
            at com.bukkit.Multimac.Calendar.Calendar.onEnable(Calendar.java:58)
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:135)
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManage
            at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:69)
            at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:50)
            at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:167)
            at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:154)
            at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:106)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:202)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:512)
    2011-02-07 19:01:07 [INFO] Done! For help, type "help" or "?"
  30. Offline

    Nick Stevens

    Tried the new version and I just got the days ticking up constantly every few seconds, also no matter what I set the currentday value to it ignored it and started at about 25. :(

Share This Page