Giter Site home page Giter Site logo

mcstats2's Introduction

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< O V E R V I E W >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

MCStats is a statistics plugin for the bukkit Minecraft server environment. MCStats
periodically generates xml, json, js, and html files containing server statistics. Optionally,
MCStats can also serve these files using an embedded web server.

Using the embedded web server, the html stats report can be served directly from your
Minecraft server. No need for messy apache installs.

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< I N S T A L L A T I O N >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

To use MCStats, place MCStats.jar in the bukkit plugin directory.

When first run, MCStats will create the config.yml file and a statscache
file. Statscache is the default repository for server statistics. Deleting this
file will reset all statistics.

<<<<<<<<<<<<<<<<<<<<<<<<< P U R G I N G   O L D   P L A Y E R S >>>>>>>>>>>>>>>>>>>>>>>

To purge an inactive or unwanted player from the statistics cache, add their name to
the playersToPurge attribute in the config.yml file. More than one player name
can be added by separating them by spaces. After saving the properties file, reload
MCStats from the server console to execute the purge. You will be notified that the
players were removed when the module reloads. Once the selected players have been
successfully purged from the statistics cache, the playersToPurge property will be
cleared.

MCStats can be configured to ignore players without a group assignment. When 
ignoreGrouplessPlayers is set to true in the config, only players with group assignments
will be added to the statistics cache. This feature can be useful for separating your
recurring players from guests of your server.

If you only want to reset all the player playtimes to zero, set the resetPlaytime flag
to true in the config and reload MCStats. When MCStats reloads, all playtimes will be
reset and the flag will be cleared in the config file.

<<<<<<<<<<<<<<<<<<<<<<<<<<<<< C O N F I G U R A T I O N >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

The following items can be configured in the MCStats.config file.
* statsCacheFile        
- The name of the peristent stats storage file that stores the raw statistics data.

* statsBaseResource     
- The file name (minus extension) to use when saving/serving stats report files.

* resourceSaveDirectory 
- The directory to save stats reports into. For web server integration, set this directory 
  to you web server's wwwroot directory.

* secondsBetweenSaves   
- The number of seconds to wait between saving stats reports and the statscache.

* secondsBetweenPageRefreshes 
- The number of seconds to wait before automatically refreshing the html report in the browser.

* webserverEnabled      
- Enables or dissables the embedded web server.

* httpServerContextRoot 
- The path part of the embedded web server's url. Must begin and end with a slash (/). 

  Example: /foo/bar/ => http://host.com/foo/bar/mcstats.html
  Note: This property only controls the middle part of the url.
        Not the file name or the server name.

* overwriteHtmlReport
- Default True. Sets or disables the automatic overwriting of the HTML report file. Useful for
  modding the HTML report without installing a complete web server. When set to False, the internal
  web server will continue to serve the generated HTML report, even if it is modified (for a mod,
  for example).

* httpBacklog           
- The number of http requests to queue before dropping requests.

* httpPort              
- The port the embedded web server listens on.

* resetPlaytime
- Default False. If set to true, all player playtimes will be reset to zero.

* ignoreGroups
- Default empty. A list of Permissions groups that MCStats will ignore, separated by spaces.
  Note: If you will still need to purge players who were created before this setting was set.
  
* ignoreGrouplessPlayers
- Default false. When true, players with no explicit groups remaining after removing any
  configured in ignoreGroups will be ignored. This setting also ignores all players
  in the default group when true.
  
* playersToPurge        
- A list of player names to remove from the stats cache, separated by spaces.

* httpPostUrl
- Default empty. When set to a URL, MCStats will attempt to post its json data to that url
  every time the stats are committed to disk.
  
* httpPostConnectTimeout
- Default 300. The number of milliseconds to wait before giving up on an http post.

* enableSerializerCache
- Default True. When true, stats served up by the internal web server will only be regenerated every
  [secondsBetweenSaves] seconds. If false, stats are generated in real-time. Setting this to false
  could have a negative affect on server performance.
                          
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< M O D D I N G >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

======= Styling the HTML Report =======
The MCStats html report can be easily modded to incorporate the theme of your website.
To begin, start the plugin and wait for it to generate the default report. If the
statsBaseResource and resourceSaveDirectory properties have been left as their defaults,
this file will be stats/mcstats.html in the bukkit plugin directory. Once the default html 
file has been generated, set the overwriteHtmlReport option in the plugin.yml file to true
so that your changes are not overwritten my MCStats.

The following css styles are useful for changing the visual theme of the html report:
* #online
- The ID of the table of online players

* #stats
- The ID of the table of player statistics

* .pName
- The style for player names in the stats table

* .pOnline
- The style for player names in the players online list

* th.header
- The style for unsorted stats table headers

* th.headerSortDown
- The style for stats table headers sorted in ascending order

* th.headerSortUp
- The style for stats table headers sorted in descending order

* .Ops, .Mods, .Vip
- Styles for identifying the standard bukkit roles in the user lists.
  MCStats assigns each user's div tag a css class with the name of each role they are
  assigned. Even custom ones.
  
To remove a column from the html report, you must first remove the column's <th> tag
from the html markup and then remove the corresponding javascript that generates the
column's content. Find the block of code that defines a var with the right name and
delete the entire block of code. 

======= Consuming MCStats data in other programs =======
In addition to generating an HTML report, MCStats exports its data in xml, json, and
javascript format. These data feeds are ready for consumption by other programs using
whatever parser your language provides. For your convenience, here are the xml and json
data formats.

Additionally, MCStats can be configured to POST json data to a url, allowing MCStats
to push stats data into your app.

* MCStats.xml *
<mcStats>
	<playersOnline>
		<player>
			<playerName>STRING</playerName>
			<groups>SPACE DELIMITED STRING LIST</groups>
		</player>
	</playersOnline>
	<playerStats>
		<player>
			<blocksDestroyed>INTEGER</blocksDestroyed>
			<blocksPlaced>INTEGER</blocksPlaced>
			<isOnline>BOOLEAN</isOnline>
			<itemsDropped>INTEGER</itemsDropped>
			<lastLogin>STRING ENCODED UNIX EPOCH TIMESTAMP</lastLogin>
			<metersTraveled>INTEGER</metersTraveled>
			<playerName>STRING</playerName>
			<playerSince>STRING ENCODED UNIX EPOCH TIMESTAMP</playerSince>
			<sessionPlaytime>STRING, EMPTY IF NOT ONLINE</sessionPlaytime>
			<sessionPlaytimeSeconds>INTEGER, -1 IF NOT ONLINE</sessionPlaytimeSeconds>
			<totalPlaytime>STRING</totalPlaytime>
			<totalPlaytimeSeconds>INTEGER</totalPlaytimeSeconds>
		</player>
	</playerStats>
</mcStats>

* MCStats.json *
{
	{
    "playerStats": [
        {
            "blocksDestroyed": 11,
            "blocksDestroyedDetails": {			// map between block id and
                "50": 1,						// total destroyed
                "2": 6,
                "18": 3,
                "12": 1
            },
            "blocksPlaced": 41,
            "blocksPlacedDetails": {			// map between block id and
                "50": 41						// total placed
            },
            "isOnline": true,
            "itemsDropped": 1,
            "itemsDroppedDetails": {			// map between item id and
                "50": 1							// total dropped
            },
            "lastLogin": "1290671856505",		// string encoded unix epoch time
            "metersTraveled": 955,
            "playerGroups": [
                "mods"							// array of player's groups
            ],
            "playerName": "deltahat",
            "playerSince": "1290476814776",		// string encoded unix epoch time
            "sessionPlaytime": "0.03 hours",
            "sessionPlaytimeSeconds": "174",
            "totalPlaytime": "3.63 hours",
            "totalPlaytimeSeconds": "13088"
        }
    ],
    "playersOnline": [
        {
            "groups": [							// array of player's groups
                "mods"
            ],
            "playerName": "deltahat"
        }
    ]
}

* MCStats.js *
var mcStatsRawData = {...json data...};

======= Notes on Web Servers =======
Assuming you are using the default value for statsBaseResource, you can simply rename 
your mcstats.html file to stats.html and then edit the copy. This will require the 
use of some other web server technology to serve your new file as the embedded 
server only serves mcstats.html.

If you are using the internal web server, MCStats will overwrite any customized html 
report unless you set overwriteHtmlReport to false in the config file. While setting 
this to false will allow the internal web server to serve a customized html file, 
your html file will no longer get any updates with future versions of MCStats since 
MCStats is now ignoring the file.

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< C O N T A C T >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

MCStats is written by Ryan Michela ([email protected])

Additional code by:
Jason Morris    - JSONEncoder.java
Christian Bach  - tablesorter.js

mcstats2's People

Contributors

rmichela avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

krakdustten

mcstats2's Issues

Exception when using GroupManager instead of Permissions.

[SCHWERWIEGEND] Could not pass event PLAYER_MOVE to MCStats2
java.lang.NoSuchMethodError: com.nijiko.permissions.PermissionHandler.inSingleGroup(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
at com.ryanmichela.MCStats2.service.GroupService.getGroups(GroupService.java:55)
at com.ryanmichela.MCStats2.controller.StatsController.ignorePlayer(StatsController.java:165)
at com.ryanmichela.MCStats2.controller.StatsController.travelAMeter(StatsController.java:71)
at com.ryanmichela.MCStats2.controller.StatsPlayerListener.onPlayerMove(StatsPlayerListener.java:53)
at org.bukkit.plugin.java.JavaPluginLoader$7.execute(JavaPluginLoader.java:192)
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:59)
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:255)
at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:124)
at net.minecraft.server.Packet10Flying.a(SourceFile:126)
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)

Fix multiworld support

Multiworld support, i can't run this plugin because we have a Nether world, and if anybody goes to the nether it lags the server out and dumps a HUGE amount of exceptions to the console, too much, too fast to even read!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.