From 2b174682449c5d76731120da23223babc34c8a0f Mon Sep 17 00:00:00 2001 From: Jonas Friedmann Date: Wed, 27 Mar 2013 07:11:27 +0100 Subject: [PATCH] new Statistician and Ultrabans (SQL) plugins --- plugins/minecraft/jsonapi/mcsqls2killshostile | 151 ++++++++++++++++++ plugins/minecraft/jsonapi/mcsqls2killsneutral | 79 +++++++++ plugins/minecraft/jsonapi/mcsqls2killspassive | 119 ++++++++++++++ plugins/minecraft/jsonapi/mcsqls2players | 55 +++++++ plugins/minecraft/jsonapi/mcsqlubshame | 129 +++++++++++++++ 5 files changed, 533 insertions(+) create mode 100644 plugins/minecraft/jsonapi/mcsqls2killshostile create mode 100644 plugins/minecraft/jsonapi/mcsqls2killsneutral create mode 100644 plugins/minecraft/jsonapi/mcsqls2killspassive create mode 100644 plugins/minecraft/jsonapi/mcsqls2players create mode 100644 plugins/minecraft/jsonapi/mcsqlubshame diff --git a/plugins/minecraft/jsonapi/mcsqls2killshostile b/plugins/minecraft/jsonapi/mcsqls2killshostile new file mode 100644 index 00000000..c81e36f0 --- /dev/null +++ b/plugins/minecraft/jsonapi/mcsqls2killshostile @@ -0,0 +1,151 @@ +#!/usr/bin/php + 1) && ($argv[1] == 'config')) +{ +print("graph_title Bukkit / Statistician - hostile mob kills per day +graph_category bukkit_sql_kills +graph_vlabel hostile mob kills per day +graph_args --base 1000 -l 0 +blaze.type GAUGE +blaze.label killed blazes +spider.type GAUGE +spider.label killed spiders +creeper.type GAUGE +creeper.label killed creepers +ghast.type GAUGE +ghast.label killed ghasts +magmacube.type GAUGE +magmacube.label killed magma cubes +silverfish.type GAUGE +silverfish.label killed silverfish +skeleton.type GAUGE +skeleton.label killed skeletons +slime.type GAUGE +slime.label killed slimes +witch.type GAUGE +witch.label killed witches +zombie.type GAUGE +zombie.label killed zombies +irongolem.type GAUGE +irongolem.label killed iron golems +enderdragon.type GAUGE +enderdragon.label killed ender dragons +wither.type GAUGE +wither.label killed withers +"); +exit(); +} + +## Construct 'minumum' timstamp +$current = mktime(); +$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current)); + +## Initiate connection +$connection = mysqli_connect($hostname, $username, $password, $database, $port); + +## Check connection +if (mysqli_connect_errno()) { + printf("Connect failed: %s\n", mysqli_connect_error()); + exit(); +} + +## Select queries for blaze kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Blaze'")) { + ## Print values + print('blaze.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for spider kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = '%Spider'")) { + ## Print values + print('spider.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for creeper kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = '%reeper%'")) { + ## Print values + print('creeper.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for ghast kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Ghast'")) { + ## Print values + print('ghast.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for magma cube kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'MagmaCube'")) { + ## Print values + print('magmacube.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for silverfish and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Silverfish'")) { + ## Print values + print('silverfish.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for skeleton kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Skeleton'")) { + ## Print values + print('skeleton.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for slime kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Slime'")) { + ## Print values + print('slime.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for witch kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Witch'")) { + ## Print values + print('witch.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for zombie kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Zombie'")) { + ## Print values + print('zombie.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for iron golem kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = '%ron%'")) { + ## Print values + print('irongolem.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for ender dragon kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'EnderDragon'")) { + ## Print values + print('enderdragon.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for wither kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Wither'")) { + ## Print values + print('wither.value ' . mysqli_num_rows($result) . "\n"); +} + +## Close connection +mysqli_close($connection); +?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcsqls2killsneutral b/plugins/minecraft/jsonapi/mcsqls2killsneutral new file mode 100644 index 00000000..d5282d0c --- /dev/null +++ b/plugins/minecraft/jsonapi/mcsqls2killsneutral @@ -0,0 +1,79 @@ +#!/usr/bin/php + 1) && ($argv[1] == 'config')) +{ +print("graph_title Bukkit / Statistician - neutral mob kills per day +graph_category bukkit_sql_kills +graph_vlabel neutral mob kills per day +graph_args --base 1000 -l 0 +enderman.type GAUGE +enderman.label killed endermen +wolf.type GAUGE +wolf.label killed wolf +zombiepigman.type GAUGE +zombiepigman.label killed zombie pigmen +snowman.type GAUGE +snowman.label killed snowmen +"); +exit(); +} + +## Construct 'minumum' timstamp +$current = mktime(); +$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current)); + +## Initiate connection +$connection = mysqli_connect($hostname, $username, $password, $database, $port); + +## Check connection +if (mysqli_connect_errno()) { + printf("Connect failed: %s\n", mysqli_connect_error()); + exit(); +} + +## Select queries for enderman and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Enderman'")) { + ## Print values + print('enderman.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for wolf kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Wolf'")) { + ## Print values + print('wolf.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for zombie pigman kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Zombie Pigman'")) { + ## Print values + print('zombiepigman.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for zombie snowman kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Snowman'")) { + ## Print values + print('snowman.value ' . mysqli_num_rows($result) . "\n"); +} + +## Close connection +mysqli_close($connection); +?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcsqls2killspassive b/plugins/minecraft/jsonapi/mcsqls2killspassive new file mode 100644 index 00000000..8dacf9e4 --- /dev/null +++ b/plugins/minecraft/jsonapi/mcsqls2killspassive @@ -0,0 +1,119 @@ +#!/usr/bin/php + 1) && ($argv[1] == 'config')) +{ +print("graph_title Bukkit / Statistician - passive mob kills per day +graph_category bukkit_sql_kills +graph_vlabel passive mob kills per day +graph_args --base 1000 -l 0 +bat.type GAUGE +bat.label killed bats +chicken.type GAUGE +chicken.label killed chickens +cow.type GAUGE +cow.label killed cows +mooshroom.type GAUGE +mooshroom.label killed mooshrooms +ocelot.type GAUGE +ocelot.label killed magma ocelots +pig.type GAUGE +pig.label killed pigs +sheep.type GAUGE +sheep.label killed sheeps +squid.type GAUGE +squid.label killed squids +villager.type GAUGE +villager.label killed villager +"); +exit(); +} + +## Construct 'minumum' timstamp +$current = mktime(); +$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current)); + +## Initiate connection +$connection = mysqli_connect($hostname, $username, $password, $database, $port); + +## Check connection +if (mysqli_connect_errno()) { + printf("Connect failed: %s\n", mysqli_connect_error()); + exit(); +} + +## Select queries for bat kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Bat'")) { + ## Print values + print('bat.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for chicken kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Chicken'")) { + ## Print values + print('chicken.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for mooshroom kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'MushroomCow'")) { + ## Print values + print('mooshroom.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for cow kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Cow'")) { + ## Print values + print('cow.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for ocelot kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Ocelot'")) { + ## Print values + print('ocelot.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for pig kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Pig'")) { + ## Print values + print('pig.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for sheep and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Sheep'")) { + ## Print values + print('sheep.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for squid kills and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Squid'")) { + ## Print values + print('squid.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for villager and return the amount of rows +if ($result = mysqli_query($connection, "SELECT id FROM killchart WHERE time > $today AND killed_creature_type = 'Villager'")) { + ## Print values + print('villager.value ' . mysqli_num_rows($result) . "\n"); +} + +## Close connection +mysqli_close($connection); +?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcsqls2players b/plugins/minecraft/jsonapi/mcsqls2players new file mode 100644 index 00000000..21682268 --- /dev/null +++ b/plugins/minecraft/jsonapi/mcsqls2players @@ -0,0 +1,55 @@ +#!/usr/bin/php + 1) && ($argv[1] == 'config')) +{ +print("graph_title Bukkit / Statistician - new players per day +graph_category bukkit_sql +graph_vlabel new players per day +graph_args --base 1000 -l 0 +players.type GAUGE +players.label new players +"); +exit(); +} + +## Construct 'minumum' timstamp +$current = mktime(); +$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current)); + +## Initiate connection +$connection = mysqli_connect($hostname, $username, $password, $database, $port); + +## Check connection +if (mysqli_connect_errno()) { + printf("Connect failed: %s\n", mysqli_connect_error()); + exit(); +} + +## Select queries return the amount of rows +if ($result = mysqli_query($connection, "SELECT player_name FROM players WHERE firstever_login > $today")) { + ## Print values + print('players.value ' . mysqli_num_rows($result) . "\n"); +} + +## Close connection +mysqli_close($connection); +?> \ No newline at end of file diff --git a/plugins/minecraft/jsonapi/mcsqlubshame b/plugins/minecraft/jsonapi/mcsqlubshame new file mode 100644 index 00000000..784f9864 --- /dev/null +++ b/plugins/minecraft/jsonapi/mcsqlubshame @@ -0,0 +1,129 @@ +#!/usr/bin/php + 1) && ($argv[1] == 'config')) +{ +print("graph_title Bukkit / Ultrabans - shame per day +graph_category bukkit_sql +graph_vlabel amount of shame per day +graph_args --base 1000 -l 0 +unban.type GAUGE +unban.label unbans +kick.type GAUGE +kick.label kicks +warning.type GAUGE +warning.label warnings +ban.type GAUGE +ban.label bans +ipban.type GAUGE +ipban.label ipbans +fine.type GAUGE +fine.label fines +jail.type GAUGE +jail.label jails +permban.type GAUGE +permban.label permbans +mute.type GAUGE +mute.label mutes +"); +exit(); +} + +## Construct 'minumum' timstamp +$current = mktime(); +$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current)); + +## Initiate connection +$connection = mysqli_connect($hostname, $username, $password, $database, $port); + +## Check connection +if (mysqli_connect_errno()) { + printf("Connect failed: %s\n", mysqli_connect_error()); + exit(); +} + +## Select queries for unbans return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 5 AND time > $today")) { + ## Print values + print('unban.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for kicks return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 3 AND time > $today")) { + ## Print values + print('kick.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for warnings return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 2 AND time > $today")) { + ## Print values + print('warning.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for bans return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 0 AND time > $today")) { + ## Print values + print('ban.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for ipbans return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 1 AND time > $today")) { + ## Print values + print('ipban.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for fines return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 4 AND time > $today")) { + ## Print values + print('fine.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for jails return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 6 AND time > $today")) { + ## Print values + print('jail.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for permbans return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 9 AND time > $today")) { + ## Print values + print('permban.value ' . mysqli_num_rows($result) . "\n"); +} + +## Select queries for mutes - part 1 return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 7 AND time > $today")) { + ## Store result + $tmp1 = mysqli_num_rows($result); +} + +## Select queries for mutes - part 2 return the amount of rows +if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 8 AND time > $today")) { + ## Store result + $tmp2 = mysqli_num_rows($result); +} + +$mutes = $tmp1 + $tmp2; + +print('mute.value ' . $mutes . "\n"); + +## Close connection +mysqli_close($connection); +?> \ No newline at end of file