[INACTIVE][INFO] SimpleNews v0.5 - Lightweight server news and information plugin [1337]

Discussion in 'Inactive/Unsupported Plugins' started by Gr3y, Jun 9, 2011.

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

    Gr3y

    SimpleNews
    Version 0.5.2

    Announcement: Version 0.6 is in the works with a complete rewrite of the permissions code to support for PermissionsBukkit! Expect it around the new year... I hope! - Grey, 9th Dec

    SimpleNews is a very lightweight plugin that allows you to deliver news, information and announcements to your users. It is a far more elegant solution than trying to fit everything into the server MOTD!

    Features:
    • Permissions integration (Not required)
    • Color support!
    • Single or multiple named pages of news
    • News editing in-game and through files
    • No need to reload to see changes
    • Extremely lightweight and unobtrusive.
    • Auto-Updating!
    • Group news broadcasting
    • Display main news on player login (optional)
    Download
    SimpleNews v0.5.2 [Jar]

    Commands:
    Basic Commands (open)

    /news
    This command simply reads the "main" news file to the user, including a list of other news pages.
    Permissions required: simplenews.read.main
    Screenshot

    /news «entry name»
    This command will read the contents of the news page name specified.
    Permissions required: simplenews.read.<page name>
    Screenshot

    /setnews «entry name» «news content»
    This command will set the contents of the news file to whatever is specified in the content argument.

    Appending Text
    To append text to an existing page, append a "+" to the page name.
    eg, to append to the main article use:
    "/setnews main+ This is some appended text"

    Colors
    To add a color to an entry, use the "&" symbol followed by the color found here.
    eg, "/setnews main white demo &c red demo &9 blue demo &a green demo" - Screenshot

    Lines
    New lines can be added using "@" where a new line needs to be placed.
    Note: When editing the news via the files, use of "@" is not necessary. The use of "@" to denote new lines is only used when editing news in-game.

    News entries can also be edited (with no file extension) as text files from the filesystem.

    Important Note: Please refrain from using special characters, periods or spaces in page names - they are filtered for technical reasons.
    Advanced Usage & Custom Configuration (open)

    Display news on player login
    In the config.yml file (Found in the SimpleNews directory) change the following line:
    Code:
    newsonlogin: true
    Broadcast a news entry
    To broadcast a news entry to every player with read permissions for that entry (after it is updated, for instance), simply use the following command and flag:
    /news -broadcast «page name»

    The small text header displayed before the news broadcast can be changed (colors are supported using the "&" symbol) in the config.cfg file by adding the following line:
    Code:
    broadcastheader: «Your header»
    Permissions: The player must have the permissions node "SimpleNews.broadcast" in order to make a broadcast.

    Notify players of a news update
    To notify every online player (with read permissions for that entry) of a news update, use the following command and flag:
    /news -notify [entry name]
    If you do not specify an entry name, the default "main" is assumed.

    Reload SimpleNews configuration without restarting
    To make SimpleNews reload its configuration file without having to restart the server, use the following command and flag:
    /news -reload
    Permissions: The player must have the permissions node "SimpleNews.reload" in order to reload configuration.

    Explicitly define news entries
    Some users had problems with garbage files spamming their news listings.

    To fix this, you can add a list of explicit news entries to the "newsfiles" configuration line (comma delimited). Please ensure that your list is inside single quotes!

    By default it is set to "!all", which will display all (non configuration) files in the SimpleNews directory. To stop this functionality, remove the "!all" from the list.

    The /setnews command is set to append to this list automatically.

    Other flags
    SimpleNews also supports two other flags. No permissions are required to use them.
    -help : This displays some help information about the plugin.
    -version: This displays the version and author information.

    Installation:
    Installation (open)

    Simple download the jar file, place it into the plugins directory and start the server.

    The default news entry "main" will be created in the /plugins/SimpleNews directory. You should put your main news inside using the in-game commands or by editing the file manually.

    If you use Permissions, then you will need to apply the following:
    Regular Users: 'SimpleNews.read.*'
    Staff: 'SimpleNews.write'

    Permission to read individual entries can be given by applying the following Permission node:
    Selective entry permission: 'SimpleNews.read.[entry name]'

    Future Development
    Version 0.6
    • MySQL support (requested by Alfw)
    • Have an idea? Please post it! I am more than happy to help!
    Change Log:
    Version 0.5.2
    • Improved the update code to allow for release notes
    • Switched to the built-in Bukkit configuration method
    • Added functionality to define news pages explicitly
    Version 0.5.1b, 0.5.1c, 0.5.1d
    • Temporary fix: Plugin now works with Permissions plugin version 3.1.x and 2.7.x
    • Left some testing code in the plugin (oops!) - removed it.
    Version 0.5.1
    • Tidied up a lot of code
    • Changed news broadcasting to be group-aware
    • News listing now only shows pages that the player has permission to view
    Older Change Logs (open)

    Version 0.5
    • Changed the code structure significantly
    • ...made it a little messier too... :(
    • Implemented news broadcasting
    • Implemented the NewsOnLogin feature
    Version 0.4.1, 0.4.2 and 0.4.3- Minor Updates:
    • A few minor bug fixes, code restructure and cleanup
    • Improved auto-update capabilities
    • Added handler for file permission errors
    • Fixed an unhanded exception bug
    Version 0.4
    • Implemented auto-update script - courtesy of JayJay110
    • Added appending to news pages
    • Cleaned up code a little
    Version 0.3.1, 0.3.2 and 0.3.3 - Minor Updates:
    • Removed Permissions dependency bug
    • Fixed incorrect plugin.yml contents
    • Made some code corrections - courtesy of CaptainAwesome7 :)
    • Fixed a bug introduced that would duplicate news lines
    Version 0.3:
    • Public release of plugin
    • Enabled color support to news pages
    • Added automatic plugin directory setup
    Version 0.2
    • Enabled multiple news pages
    • Enabled permissions integration
    • Added error handlers in case of file read/write errors.
    Version 0.1
    • Initial release
    This plugin was based on Yet Another Rules Plugin by marvinbek, but has now been extensively modified.


    Note: The auto-updater will only function assuming that the plugin is working. If CraftBukkit is updated and the plugin breaks, you will have to update manually.

    Please, I ask that you let me know if this is even remotely useful to you! :)
     
    Undrtakr likes this.
  2. Offline

    MikeA

    I like it.
     
  3. Offline

    feildmaster

    I will definitely take a look at this plugin
     
  4. Offline

    sillyrosster

    I will definitely use this =D
     
  5. Offline

    Gr3y

    Ah, I'm glad my first plugin may be useful :)
     
  6. Offline

    feildmaster

    I would like to ask for a non-permission required plugin. If you're particular about this, I could help. (I guess it would have to default to something like... "everyone can read any page" and "only OP's can write pages"?)

    I do somewhat like the "only certain people can read certain pages" thing... but that is not completely necessary.
    -------
    another thing I'd like to ask. I've never used permissions (might add it on one of my servers...) but would simplenews.read.* work to read all pages?
     
  7. Offline

    Gr3y

    Yes, "SimpleNews.read.*" would indeed allow access to all news entries without restriction.
    Please ensure though that you use "SimpleNews" instead of "simplenews" - Permissions are case-sensitive!

    Secondly, It was actually originally designed to work with and without Permissions - unfortunately, when I tested it without Permissions it refused to work.

    I'll get to work fixing this issue - thank you for your feedback!

    I hate to double post, but I have now updated the plugin to work without Permissions installed.
    An updated download link has been provided.
    Server Ops are allowed to read and edit news, while regular users may only read (all) news.

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

    captainawesome7

    @Gr3y Please please please replace all of this:
    Code:java
    1. while ((NewsString = br.readLine()) != null) {
    2. String NewsString = NewsString.replaceAll("~a", ChatColor.GREEN);
    3. NewsString = NewsString.replaceAll("~b", ChatColor.AQUA);
    4. NewsString = NewsString.replaceAll("~c", ChatColor.RED);
    5. NewsString = NewsString.replaceAll("~d", ChatColor.LIGHT_PURPLE);
    6. NewsString = NewsString.replaceAll("~e", ChatColor.YELLOW);
    7. NewsString = NewsString.replaceAll("~f", ChatColor.WHITE);
    8. NewsString = NewsString.replaceAll("~0", ChatColor.BLACK);
    9. NewsString = NewsString.replaceAll("~1", ChatColor.DARK_BLUE);
    10. NewsString = NewsString.replaceAll("~2", ChatColor.DARK_GREEN);
    11. NewsString = NewsString.replaceAll("~3", ChatColor.DARK_AQUA);
    12. NewsString = NewsString.replaceAll("~4", ChatColor.DARK_RED);
    13. NewsString = NewsString.replaceAll("~5", ChatColor.DARK_PURPLE);
    14. NewsString = NewsString.replaceAll("~6", ChatColor.GOLD);
    15. NewsString = NewsString.replaceAll("~7", ChatColor.GRAY);
    16. NewsString = NewsString.replaceAll("~8", ChatColor.DARK_GRAY);
    17. NewsString = NewsString.replaceAll("~9", ChatColor.BLUE);
    18. sen.sendMessage(NewsString);
    19. }

    With:
    Code:java
    1. sen.sendMessage(NewsString.replaceAll("(&([a-f0-9]))", "\u00A7$2"));

    And in the file change ~ to &
     
  9. Offline

    Gr3y

    Will do - thanks for looking over it for me :)
     
  10. Offline

    captainawesome7

    For future reference, use the @ as a tag:
    @Gr3y , if I didn't spend my day on bukkit.org I wouldn't have seen your reply.
     
  11. Offline

    Gr3y

    @captainawesome7 , I have made the code changes and updated the download and the post.

    Does the rest of the code seem sane? It is my first project in Java, and needs a lot of refining and tidying I know.
     
  12. Offline

    captainawesome7

    Seems sane enough to me :)
    I would say to change this:

    Code:java
    1.  
    2. String mainDirectory = "plugins/SimpleNews";
    3. File SN_Directory = new File(mainDirectory);
    4.  

    To this:
    Code:java
    1.  
    2. File SN_Directory = this.getDataFolder();
    3.  

    But I didn't do that in my own plugins cause I'm lazy :/
     
  13. Offline

    feildmaster

    These lines:
    Code:java
    1.  
    2. public String address = "[URL]http://www.greytheory.net/minecraft/plugins/simplenews/download/SimpleNews.jar[/URL]";
    3. public String updatepath = "plugins" + File.separator + "SimpleNews.jar";

    can be made private strings under "Updater" (they aren't used anywhere else).
    --------------
    *thinks* And there could probably be a different way to check updater (by checking "version" instead of "lastupdated", something like... JarInputStream and editing the manifest... [it's a bit too much trouble])

    For simplicities sake, the way you have it should be fine. ;)
    --------------
    *edit in*
    Code:java
    1. public String VERSION = "0.4.1-testing";

    Can be changed to....
    Code:java
    1. public String PluginDescriptionFile VERSION = getDescription().getVersion();

    This way you only need to store the version in the plugin.yml *done by memory... might not work with that syntax? It should*
    -------------
    *edit 2*
    Breaking the news pages by ", " not just a space. ;)
     
  14. Offline

    Gr3y

    @feildmaster I changed the updater strings as suggested, as well as fetching the version from the plugin.yml :)

    I also verified that it worked against build 860. I know the announcement said that there was no API changes, but I thought it was worth testing.

    I could not get the following to work, but I did something similar instead. My way wasn't as nice though... so if anybody could help me out here and suggest why it doesn't work I would appreciate it.

    Code:
    public String PluginDescriptionFile VERSION = getDescription().getVersion();
    As for the auto-updater... I know it isn't very efficient, but It serves the purpose at least :) I think I'll just leave it as-is.

    Have any other ideas that you may find useful in this plugin?
     
  15. Offline

    Plague

    changelog has to be visible with two latest versions out of a spoiler
     
  16. Offline

    Gr3y

  17. Offline

    Niklas4G

  18. Offline

    feildmaster

    I'll take a look at how you made it gr3y...
    *checks*

    the way you have it is just fine. ;)
    Code:java
    1. public PluginDescriptionFile VERSION = getDescription().getVersion();


    I *think* it would work without the "string" (because it's already saved as a string) I honestly haven't worked with the PDF very much. (if you still want it to look nice)

    I'll look at your code in more detail later in order to see if it can be "enhanced" any. ;)
     
  19. Offline

    fatmarley

    This is great for me to pass information on to my mods...thanks alot.
     
  20. Offline

    wassilij

    I put it into my plugins folder .. reloaded my server, the config.cfg and main is empty .. :(
     
  21. Offline

    alfw

    Can you add MySql support?
     
  22. Offline

    Gr3y

    @wassilij This is by design. The main file is where you put your default news. It can be set using the /setnews command (See the "Basic Commands" section of the original post). No configuration in config.cfg is required, which is why it is left blank. If you do wish to make configuration changes, you can lines as you see fit.

    If you have any questions regarding the use of the plugin, ask away - I'll be more than happy to help :)

    @alfw I'm not entirely sure why you would want MySQL support for such a simple plugin... however I see no reason not to implement it so I shall add it into the task list for version 0.6. :)

    I will probably end up releasing the MySQL version as an alternative version to the main plugin, so users can chose between flat files and MySQL without too much confusion.
     
    wassilij likes this.
  23. Offline

    alfw

    When you use mysql, you can aslo make a script to a webpage to add news. So you dont need to be on the server to make them. :)
     
  24. Offline

    fatmarley

    Im curious about the broadcast and the use of permissions.

    If i set my mod team as the persons who can read it, and not my default users will they get news broadcast spam?
     
  25. Offline

    feildmaster

    It will send to all. (by the way
    @Gr3y, you're "on command" function is a mess)

    Edit:
    A lightweight "version"
    Code:
    public String version; #At top
    Code:
    version = getDescription().getVersion(); #in onEnable
    then you can use "version" without calling PDF (ever)
     
  26. Offline

    Gr3y

    @fatmarley As Feildmaster said, the broadcast will notify everybody on the server, not just specific groups. I shall add an option to restrict broadcasts to their relevant groups.

    @feildmaster Yeah, I know my code is messy (even mentioned it in the change log) - I'll work on fixing it up!

    I am glad to see that this plugin is somewhat useful!
     
  27. Offline

    fatmarley

    somewhat!!!! I will wash your feet if I ever see you.

    I have a request when you make the groups, could you have two broadcasts? I would like to pass along private changes to my mods, like new commands and such, so they would read the tier 1 level and get tier 1 announcements.

    Whilst my peons would be tier2, just a basic news update saying that they can now purchase wolves in shops as an example.

    Ta.
     
  28. Offline

    Gr3y

    @fatmarley I have updated the plugin to make news broadcasts group aware. Only players that have permission to view an entry will be informed when you make a news broadcast.

    SimpleNews should update itself next time you restart your server :) Use /news -version to check what version you are running!
     
  29. Offline

    fatmarley

    it did, but it is throwing out sever errors and player unable to join spam

    ---found permissions---
     
  30. Offline

    feildmaster

    Simplenews has the following Permissions:
    Code:
    SimpleNews.read.<page>
    SimpleNews.write
    SimpleNews.reload
    SimpleNews.broadcast
    SimpleNews.update
    what are the examples you have posted? And did you do /reload after it updated?
     
Thread Status:
Not open for further replies.

Share This Page