Skip to content
This repository has been archived by the owner on Feb 6, 2022. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
WeekThor authored Jan 29, 2021
1 parent d869504 commit 5e07695
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 34 deletions.
10 changes: 5 additions & 5 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: "BanInfo"
name: "BanInfo"
main: TSt\BanInfo\Loader
api: 3.0.1
version: 1.14.0
authors: [TableStudio Team (TSt), "WeekThor"]
description: "Information about ban and player's ban history"
version: 1.14.1
author: "WeekThor"
description: "Information about banned player or IP and player's ban history"
permissions:
baninfo.commands.baninfo:
description: 'Acceess to command /bi'
Expand All @@ -19,4 +19,4 @@ permissions:
default: op
baninfo.commands.bans2history:
description: 'Acceess to command /bans2history'
default: op
default: op
38 changes: 38 additions & 0 deletions resources/locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"baninfo.player.description": "Information about player's active ban",
"baninfo.player.usage": "\u00A7c\u00A7lUsage: \u00A7r\u00A77/baninfo <player>",
"baninfo.player.not_banned": "\u00A74[BanInfo] \u00A7cPlayer not banned",
"baninfo.ip.description": "Information about IP adress active ban",
"baninfo.ip.usage": "\u00A7c\u00A7lUsage: \u00A7r\u00A77/baninfo-ip <IP>",
"baninfo.ip.not_banned": "\u00A74[BanInfo] \u00A7cIP adress not banned",
"baninfo.history.item": "\u00A77 - \u00A7c{0}\u00A77: admin: \u00A7c{1}\u00A77. Reason: \u00A7c{2}",
"baninfo.history.not_found": "\u00A74[BanInfo] \u00A7cPlayer's history not found",
"baninfo.history.footer": "\u00A77Page \u00A7c{0} \u00A77of \u00A7c{1}",
"baninfo.history.usage": "\u00A7c\u00A7lUsage: \u00A7r\u00A77/pbans <player> \u00A78[page]",
"baninfo.history.page_not_found": "\u00A74[BanInfo] \u00A7cPage {0} not found",
"baninfo.history.total_count": "\u00A77Total bans count: \u00A7c{0}",
"baninfo.history.clear.usage": "\u00A7c\u00A7lUsage: \u00A7r\u00A77/clearhistory <player> \u00A78[days]",
"baninfo.history.clear.complete": "\u00A7c\u00A7l[BanInfo]\u00A7r\u00A77 Deleted \u00A7c{0}\u00A77 records of \u00A7c{1}\u00A77's ban history",
"baninfo.history.older_than": "older than \u00A7c{0}\u00A77 day(s)",
"baninfo.export.start": "\u00A7c\u00A7l[BanInfo] \u00A7r\u00A77Copying banlist to player's histories...",
"baninfo.export.end": "\u00A7c\u00A7l[BanInfo] \u00A7r\u00A77Copying completed! Was found \u00A7c{0}\u00A77 banned players",
"baninfo.never": "never",
"baninfo.reason.not_specified": "\u00A77\u00A7o(not specified)",
"baninfo.info_message": "\u00A76---=== \u00A7c{0} \u00A76===---\n\u00A76Banned: \u00A7c{1}\n\u00A76Banned by: \u00A7c{2}\n\u00A76Ban until: \u00A7c{3}\n\u00A76Ban reason: \u00A7c{4}",
"baninfo.no_perminssions": "\u00A7c\u00A7lError: \u00A7r\u00A77You don't have permissions to use this command!'",
"baninfo.active": "\u00A7a[Active]",
"month": [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
}
38 changes: 38 additions & 0 deletions resources/locales/ru.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"baninfo.player.description": "\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F \u043E \u0431\u0430\u043D\u0435 \u0438\u0433\u0440\u043E\u043A\u0430",
"baninfo.player.usage": "\u00A7c\u00A7l\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435: \u00A7r\u00A77/baninfo <\u0438\u0433\u0440\u043E\u043A>",
"baninfo.player.not_banned": "\u00A74[BanInfo] \u00A7c\u0414\u0430\u043D\u043D\u044B\u0439 \u0438\u0433\u0440\u043E\u043A \u043D\u0435 \u0437\u0430\u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u0430\u043D",
"baninfo.ip.description": "\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F \u043E \u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u043A\u0435 IP \u0430\u0434\u0440\u0435\u0441\u0430",
"baninfo.ip.usage": "\u00A7c\u00A7l\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435: \u00A7r\u00A77/baninfo-ip <IP>",
"baninfo.ip.not_banned": "\u00A74[BanInfo] \u00A7c\u0414\u0430\u043D\u043D\u044B\u0439 IP \u043D\u0435 \u0437\u0430\u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u0430\u043D",
"baninfo.history.item": "\u00A77 - \u00A7c{0}\u00A77: \u0430\u0434\u043C\u0438\u043D: \u00A7c{1}\u00A77. \u041F\u0440\u0438\u0447\u0438\u043D\u0430: \u00A7c{2}",
"baninfo.history.not_found": "\u00A74[BanInfo] \u00A7c\u0418\u0441\u0442\u043E\u0440\u0438\u044F \u0438\u0433\u0440\u043E\u043A\u0430 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430",
"baninfo.history.footer": "\u00A77\u0421\u0442\u0440\u0430\u043D\u0438\u0446\u0430 \u00A7c{0} \u00A77\u0438\u0437 \u00A7c{1}",
"baninfo.history.usage": "\u00A7c\u00A7l\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435: \u00A7r\u00A77/pbans <\u0438\u0433\u0440\u043E\u043A> \u00A78[\u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430]",
"baninfo.history.page_not_found": "\u00A74[BanInfo] \u00A7c\u0421\u0442\u0440\u0430\u043D\u0438\u0446\u0430 {0} \u043D\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442",
"baninfo.history.total_count": "\u00A77\u041E\u0431\u0449\u0435\u0435 \u0447\u0438\u0441\u043B\u043E \u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u043E\u043A: \u00A7c{0}",
"baninfo.history.clear.usage": "\u00A7c\u00A7l\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435: \u00A7r\u00A77/clearhistory <\u0438\u0433\u0440\u043E\u043A> \u00A78[\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0434\u043D\u0435\u0439]",
"baninfo.history.clear.complete": "\u00A7c\u00A7l[BanInfo]\u00A7r\u00A77 \u041E\u0447\u0438\u0449\u0435\u043D\u043E \u00A7c{0}\u00A77 \u0437\u0430\u043F\u0438\u0441\u0435\u0439 \u0432 \u0438\u0441\u0442\u043E\u0440\u0438\u0438 \u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u043E\u043A \u0438\u0433\u0440\u043E\u043A\u0430 \u00A7c{1}",
"baninfo.history.older_than": "\u0441\u0442\u0430\u0440\u0448\u0435 \u00A7c{0}\u00A77 \u0434\u043D\u044F(\u0435\u0439)",
"baninfo.export.start": "\u00A7c\u00A7l[BanInfo] \u00A7r\u00A77\u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u0431\u0430\u043D-\u043B\u0438\u0441\u0442\u0430 \u0432 \u0438\u0441\u0442\u043E\u0440\u0438\u044E \u0438\u0433\u0440\u043E\u043A\u043E\u0432...",
"baninfo.export.end": "\u00A7c\u00A7l[BanInfo] \u00A7r\u00A77\u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043D\u043E! \u0411\u044B\u043B\u043E \u043E\u0431\u043D\u0430\u0440\u0443\u0436\u0435\u043D\u043E \u00A7c{0}\u00A77 \u0437\u0430\u0431\u043B\u043E\u043A\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0445 \u0438\u0433\u0440\u043E\u043A\u043E\u0432",
"baninfo.never": "\u041D\u0438\u043A\u043E\u0433\u0434\u0430",
"baninfo.reason.not_specified": "\u00A77\u00A7o(\u043D\u0435 \u0443\u043A\u0430\u0437\u0430\u043D\u0430)",
"baninfo.info_message": "\u00A76---=== \u00A7c{0} \u00A76===---\n\u00A76\u0417\u0430\u0431\u0430\u043D\u0435\u043D: \u00A7c{1}\n\u00A76\u0417\u0430\u0431\u0430\u043D\u0438\u043B: \u00A7c{2}\n\u00A76\u041E\u043A\u043E\u043D\u0447\u0430\u043D\u0438\u0435: \u00A7c{3}\n\u00A76\u041F\u0440\u0438\u0447\u0438\u043D\u0430 \u0431\u0430\u043D\u0430: \u00A7c{4}",
"baninfo.no_perminssions": "\u00A7c\u00A7l\u041E\u0448\u0438\u0431\u043A\u0430: \u00A7r\u00A77\u0423 \u0432\u0430\u0441 \u043D\u0435\u0442 \u043F\u0440\u0430\u0432 \u0434\u043B\u044F \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u044F \u0434\u0430\u043D\u043D\u043E\u0439 \u043A\u043E\u043C\u0430\u043D\u0434\u044B!",
"baninfo.active": "\u00A7a[\u0422\u0435\u043A\u0443\u0449\u0438\u0439]",
"month": [
"\u044F\u043D\u0432\u0430\u0440\u044F",
"\u0444\u0435\u0432\u0440\u0430\u043B\u044F",
"\u043C\u0430\u0440\u0442\u0430",
"\u0430\u043F\u0440\u0435\u043B\u044F",
"\u043C\u0430\u044F",
"\u0438\u044E\u043D\u044F",
"\u0438\u044E\u043B\u044F",
"\u0430\u0432\u0433\u0443\u0441\u0442\u0430",
"\u0441\u0435\u043D\u0442\u044F\u0431\u0440\u044F",
"\u043E\u043A\u0442\u044F\u0431\u0440\u044F",
"\u043D\u043E\u044F\u0431\u0440\u044F",
"\u0434\u0435\u043A\u0430\u0431\u0440\u044F"
]
}
38 changes: 38 additions & 0 deletions resources/locales/uk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"baninfo.player.description": "\u0406\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0456\u044F \u043F\u0440\u043E \u0431\u043B\u043E\u043A\u0443\u0432\u0430\u043D\u043D\u044F \u0433\u0440\u0430\u0432\u0446\u044F",
"baninfo.player.usage": "\u00A7c\u00A7l\u0412\u0438\u043A\u043E\u0440\u0438\u0441\u0442\u0430\u043D\u043D\u044F: \u00A7r\u00A77/baninfo <\u0433\u0440\u0430\u0432\u0435\u0446\u044C>",
"baninfo.player.not_banned": "\u00A74[BanInfo] \u00A7c\u0414\u0430\u043D\u0438\u0439 \u0433\u0440\u0430\u0432\u0435\u0446\u044C \u043D\u0435 \u0437\u0430\u0431\u043B\u043E\u043A\u043E\u0432\u0430\u043D\u0438\u0439",
"baninfo.ip.description": "\u0406\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0456\u044F \u043F\u0440\u043E \u0431\u043B\u043E\u043A\u0443\u0432\u0430\u043D\u043D\u044F IP \u0430\u0434\u0440\u0435\u0441\u0438",
"baninfo.ip.usage": "\u00A7c\u00A7l\u0412\u0438\u043A\u043E\u0440\u0438\u0441\u0442\u0430\u043D\u043D\u044F: \u00A7r\u00A77/baninfo-ip <IP>",
"baninfo.ip.not_banned": "\u00A74[BanInfo] \u00A7c\u0414\u0430\u043D\u0438\u0439 IP \u043D\u0435 \u0437\u0430\u0431\u043B\u043E\u043A\u043E\u0432\u0430\u043D\u0438\u0439",
"baninfo.history.item": "\u00A77 - \u00A7c{0}\u00A77: \u0430\u0434\u043C\u0456\u043D: \u00A7c{1}\u00A77. \u041F\u0440\u0438\u0447\u0438\u043D\u0430: \u00A7c{2}",
"baninfo.history.not_found": "\u00A74[BanInfo] \u00A7c\u0406\u0441\u0442\u043E\u0440\u0456\u044F \u0431\u043B\u043E\u043A\u0443\u0432\u0430\u043D\u044C \u0433\u0440\u0430\u0432\u0446\u044F \u043D\u0435 \u0437\u043D\u0430\u0439\u0434\u0435\u043D\u043E",
"baninfo.history.footer": "\u00A77\u0421\u0442\u043E\u0440\u0456\u043D\u043A\u0430 \u00A7c{0} \u00A77\u0437 \u00A7c{1}",
"baninfo.history.usage": "\u00A7c\u00A7l\u0412\u0438\u043A\u043E\u0440\u0438\u0441\u0442\u0430\u043D\u043D\u044F: \u00A7r\u00A77/pbans <\u0433\u0440\u0430\u0432\u0435\u0446\u044C> \u00A78[\u0441\u0442\u043E\u0440\u0456\u043D\u043A\u0430]",
"baninfo.history.page_not_found": "\u00A74[BanInfo] \u00A7c\u0421\u0442\u043E\u0440\u0456\u043D\u043A\u0430 {0} \u043D\u0435 \u0456\u0441\u043D\u0443\u0454",
"baninfo.history.total_count": "\u00A77\u0417\u0430\u0433\u0430\u043B\u044C\u043D\u0430 \u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C \u0431\u043B\u043E\u043A\u0443\u0432\u0430\u043D\u044C: \u00A7c{0}",
"baninfo.history.clear.usage": "\u00A7c\u00A7l\u0412\u0438\u043A\u043E\u0440\u0438\u0441\u0442\u0430\u043D\u043D\u044F: \u00A7r\u00A77/clearhistory <\u0433\u0440\u0430\u0432\u0435\u0446\u044C> \u00A78[\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C \u0434\u043D\u0456\u0432]",
"baninfo.history.clear.complete": "\u00A7c\u00A7l[BanInfo]\u00A7r\u00A77 \u041E\u0447\u0438\u0449\u0435\u043D\u043E \u00A7c{0}\u00A77 \u0430\u043F\u0438\u0441\u0456\u0432 \u0432 \u0456\u0441\u0442\u043E\u0440\u0456\u0457 \u0431\u043B\u043E\u043A\u0443\u0432\u0430\u043D\u044C \u0433\u0440\u0430\u0432\u0446\u044F \u00A7c{1}",
"baninfo.history.older_than": "\u0441\u0442\u0430\u0440\u0448\u0435 \u00A7c{0}\u00A77 \u0434\u043D\u044F(\u0456\u0432)",
"baninfo.export.start": "\u00A7c\u00A7l[BanInfo] \u00A7r\u00A77\u041A\u043E\u043F\u0456\u044E\u0432\u0430\u043D\u043D\u044F \u0431\u0430\u043D-\u043B\u0438\u0441\u0442\u0430 \u0432 \u0456\u0441\u0442\u043E\u0440\u0456\u044E \u0433\u0440\u0430\u0432\u0446\u0456\u0432...",
"baninfo.export.end": "\u00A7c\u00A7l[BanInfo] \u00A7r\u00A77\u041A\u043E\u043F\u0456\u044E\u0432\u0430\u043D\u043D\u044F \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043D\u043E! \u0411\u0443\u043B\u043E \u0432\u0438\u044F\u0432\u043B\u0435\u043D\u043E \u00A7c{0}\u00A77 \u0437\u0430\u0431\u043B\u043E\u043A\u043E\u0432\u0430\u043D\u0438\u0445 \u0433\u0440\u0430\u0432\u0446\u0456\u0432",
"baninfo.never": "\u041D\u0456\u043A\u043E\u043B\u0438",
"baninfo.reason.not_specified": "\u00A77\u00A7o(\u043D\u0435 \u0432\u043A\u0430\u0437\u0430\u043D\u0430)",
"baninfo.info_message": "\u00A76---=== \u00A7c{0} \u00A76===---\n\u00A76\u0417\u0430\u0431\u043B\u043E\u043A\u043E\u0432\u0430\u043D\u0438\u0439: \u00A7c{1}\n\u00A76\u0417\u0430\u0431\u043B\u043E\u043A\u0443\u0432\u0430\u0432: \u00A7c{2}\n\u00A76\u0417\u0430\u043A\u0456\u043D\u0447\u0435\u043D\u043D\u044F: \u00A7c{3}\n\u00A76\u041F\u0440\u0438\u0447\u0438\u043D\u0430: \u00A7c{4}",
"baninfo.no_perminssions": "\u00A7c\u00A7l\u041F\u043E\u043C\u0438\u043B\u043A\u0430: \u00A7r\u00A77\u0423 \u0432\u0430\u0441 \u043D\u0435\u043C\u0430\u0454 \u043F\u0440\u0430\u0432 \u0434\u043B\u044F \u0432\u0438\u043A\u043E\u043D\u0430\u043D\u043D\u044F \u0434\u0430\u043D\u043E\u0457 \u043A\u043E\u043C\u0430\u043D\u0434\u0438!",
"baninfo.active": "\u00A7a[\u041F\u043E\u0442\u043E\u0447\u043D\u0430]",
"month": [
"\u0441\u0456\u0447\u043D\u044F",
"\u043B\u044E\u0442\u043E\u0433\u043E",
"\u0431\u0435\u0440\u0435\u0437\u043D\u044F",
"\u043A\u0432\u0456\u0442\u043D\u044F",
"\u0442\u0440\u0430\u0432\u043D\u044F",
"\u0447\u0435\u0440\u0432\u043D\u044F",
"\u043B\u0438\u043F\u043D\u044F",
"\u0430\u0432\u0433\u0443\u0441\u0442\u0430",
"\u0441\u0435\u0440\u043F\u043D\u044F",
"\u0436\u043E\u0432\u0442\u043D\u044F",
"\u043B\u0438\u0441\u0442\u043E\u043F\u0430\u0434\u0430",
"\u0433\u0440\u0443\u0434\u043D\u044F"
]
}
3 changes: 1 addition & 2 deletions src/TSt/BanInfo/APIs/BanInfoClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace TSt\BanInfo\APIs;

use TSt\BanInfo\Loader;
use TSt\BanInfo\APIs\BannedPlayer;

class BanInfoClass{
private $bans;
Expand All @@ -17,7 +16,7 @@ public function __construct(Loader $plugin, bool $IPList = false) {
/**
* Get banned player information or null if not banned
* Now PMMP api.............
* @param string $name
* @param string $name player name
* @return BannedPlayer|NULL
*/
public function get($name) : ? BannedPlayer{
Expand Down
6 changes: 3 additions & 3 deletions src/TSt/BanInfo/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ private function registerCommands(){
*/
public function getBanInfo($file = 'banned-players.txt') : BanInfoClass {
if($file == 'banned-ips.txt'){
return new BanInfoClass($this, true);
return new BanInfoClass($this, true);
}else{
return new BanInfoClass($this);
return new BanInfoClass($this);
}
}

Expand Down Expand Up @@ -143,4 +143,4 @@ public function updateHistory(BannedPlayer $info) {
}


}
}
41 changes: 18 additions & 23 deletions src/TSt/BanInfo/TranslateClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@

class TranslateClass{
private $lang;
private $lang_list = ["ru", "en"];
private $default_lang = "en";
private $plugin;

public function __construct(Loader $plugin, string $lang = "en") {
if(!in_array($lang, $this->lang_list)){
$lang = $this->default_lang;
}
$this->lang = $lang;
$this->plugin = $plugin;
}
Expand All @@ -24,18 +20,17 @@ public function __construct(Loader $plugin, string $lang = "en") {
*/
public function getTranslation(string $message_name, array $placeholders =[]) {
$plugin = $this->plugin;
$recources = $plugin->getResources();
try{
$locales = json_decode(file_get_contents($recources['locales.json']->getPath().'/locales.json'), true);
$message = $locales[$this->lang][$message_name];
for($k = 0; $k <count($placeholders); $k++){
$message = str_replace('{'.$k.'}', $placeholders[$k], $message);
}
return $message;
}catch (\Exception $e){
return $e->getMessage();
//$plugin->getServer()->getLogger()->error($e->getMessage());
$resourse = $plugin->getResource('locales/'.$this->lang.'.json');
if($resourse === null){
$resourse = $plugin->getResource('locales/'.$this->default_lang.'.json');
}
$stat = fstat($resourse);
$locale = json_decode(fread($resourse, $stat['size']), true);
$message = $locale[$message_name];
for($k = 0; $k <count($placeholders); $k++){
$message = str_replace('{'.$k.'}', $placeholders[$k], $message);
}
return $message;
}


Expand All @@ -47,13 +42,13 @@ public function getTranslation(string $message_name, array $placeholders =[]) {
*/
public function getTranslatedMonth(int $month) {
$plugin = $this->plugin;
$recources = $plugin->getResources();
try{
$locales = json_decode(file_get_contents($recources['locales.json']->getPath().'/locales.json'), true);
return $locales[$this->lang]['month'][$month-1];
}catch (\Exception $e){
return $e->getMessage();
//$this->plugin->getServer()->getLogger()->error($e->getMessage());
$resourse = $plugin->getResource('locales/'.$this->lang.'.json');
if($resourse === null){
$resourse = $plugin->getResource('locales/'.$this->default_lang.'.json');
}
$stat = fstat($resourse);
$locale = json_decode(fread($resourse, $stat['size']), true);
$message = $locale['month'][$month-1];
return $message;
}
}
}
1 change: 0 additions & 1 deletion src/TSt/BanInfo/commands/ClearHistoryCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

use TSt\BanInfo\Loader;
use TSt\BanInfo\APIs\API;
use TSt\BanInfo\APIs\BanInfoClass;
use TSt\BanInfo\TranslateClass;

use pocketmine\command\CommandSender;
Expand Down

0 comments on commit 5e07695

Please sign in to comment.