blob: 70b58da990b48d52748ca22833b818a2a262cf11 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
class StaticsController < ApplicationController
caches_action :online, expires_in: 10.seconds, layout: false
def index
if current_user
redirect_to blogposts_path
else
redirect_to home_statics_path
end
end
def home
end
def donate
end
def online
begin
json = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/ModuleLoader/players.json"))
rescue
flash[:alert] = "The server is currently offline."
@players = {}
@count = 0
else
@players = json["players"].collect!{ |p| User.find_by(uuid: p["UUID"].tr("-", "")) or User.new(name: p["name"], ign: p["name"], uuid: p["UUID"].tr("-", ""), role: Role.get("normal"), badge: Badge.get("none"), confirmed: true) }.sort_by!(&:role).reverse!
@count = json["amount"]
end
end
end
|