mirror of
https://github.com/Matthww/PlayerInfo.git
synced 2025-04-18 21:05:26 +00:00
Update 2.1.5: Support PMMP 5.0.0 and being able to see players Port and UUID, also saving them to the file (#27)
* modified: plugin.yml modified: resources/config.yml modified: resources/models.yml modified: src/Matthww/PlayerInfo/PlayerInfo.php modified: src/Matthww/PlayerInfo/Tasks/FetchModelsTask.php modified: src/Matthww/PlayerInfo/Tasks/LoadTask.php modified: src/Matthww/PlayerInfo/Tasks/SaveTask.php modified: src/Matthww/PlayerInfo/Tasks/FetchModelsTask.php * modified: src/Matthww/PlayerInfo/Tasks/FetchModelsTask.php * Update plugin.yml * Update README.md * modified: src/Matthww/PlayerInfo/PlayerInfo.php * modified: src/Matthww/PlayerInfo/PlayerInfo.php * modified: src/Matthww/PlayerInfo/PlayerInfo.php * modified: src/Matthww/PlayerInfo/PlayerInfo.php * Create .poggit.yml Poggit-CI is enabled for this repo by @mukeenanyafiq Visit the Poggit-CI page for this repo at https://poggit.pmmp.io/ci/mukeenanyafiq/PlayerInfo * Update PlayerInfo.php * modified: src/Matthww/PlayerInfo/Tasks/FetchModelsTask.php * modified: src/Matthww/PlayerInfo/Tasks/FetchModelsTask.php * modified: src/Matthww/PlayerInfo/Tasks/FetchModelsTask.php * modified: src/Matthww/PlayerInfo/Tasks/FetchModelsTask.php * Update README.md * Update plugin.yml --------- Co-authored-by: poggit-bot <poggitbot@gmail.com>
This commit is contained in:
parent
ad4d1f7834
commit
68941bd668
14
README.md
14
README.md
@ -1,5 +1,5 @@
|
||||
# PlayerInfo
|
||||
Shows info about a certain player!
|
||||
Shows information about a certain player!
|
||||
|
||||
#### Command Usage:
|
||||
`/playerinfo <player>`
|
||||
@ -8,17 +8,19 @@ We also have a shorter command:\
|
||||
`/pinfo <player>`
|
||||
|
||||
#### Permission:
|
||||
`playerinfo.use` - Allows the player to use the command `/playerinfo`
|
||||
`playerinfo.use` - Allows the user/player to use the command `/playerinfo`
|
||||
|
||||
#### Example:
|
||||
|
||||
Name: Steve\
|
||||
IP: 127.0.0.1\
|
||||
Ping: 46ms\
|
||||
OS: iOS\
|
||||
Model: iPhone\
|
||||
OS: iOS\
|
||||
IP: 127.0.0.1\
|
||||
Port: 37379\
|
||||
Ping: 46ms\
|
||||
UI: Classic UI\
|
||||
GUI Scale: Maximum\
|
||||
Controls: Touch\
|
||||
Health: 19HP\
|
||||
UUID: a4b63016-7243-3010-8cf7-22915a4b77d5\
|
||||
Health: 19 HP\
|
||||
Position: X: 132, Y: 78, Z: -963
|
||||
|
18
plugin.yml
18
plugin.yml
@ -1,20 +1,18 @@
|
||||
name: PlayerInfo
|
||||
version: 2.1.4
|
||||
version: 2.1.5
|
||||
author: Matthww
|
||||
api: [3.0.0]
|
||||
description: Shows info about a certain player!
|
||||
api: 5.0.0
|
||||
description: Shows information about a certain player!
|
||||
main: Matthww\PlayerInfo\PlayerInfo
|
||||
|
||||
commands:
|
||||
playerinfo:
|
||||
description: Show info about a certain player!
|
||||
description: Show information about a certain player!
|
||||
usage: "/playerinfo <player>"
|
||||
permission: playerinfo.use
|
||||
aliases: ['pinfo']
|
||||
|
||||
permissions:
|
||||
playerinfo:
|
||||
default: false
|
||||
children:
|
||||
playerinfo.use:
|
||||
default: op
|
||||
description: "Allows the user to run the playerinfo command"
|
||||
playerinfo.use:
|
||||
default: op
|
||||
description: "Allows the user/player to execute the playerinfo command"
|
||||
|
@ -3,24 +3,27 @@
|
||||
# True = enabled
|
||||
# False = disabled
|
||||
|
||||
#Save playerdata
|
||||
# Save player data
|
||||
Save: true
|
||||
|
||||
# Show players name
|
||||
Name: true
|
||||
|
||||
# Show players IP
|
||||
# Show players IP address
|
||||
IP: true
|
||||
|
||||
# Show players port
|
||||
Port: true
|
||||
|
||||
# Show players ping
|
||||
Ping: true
|
||||
|
||||
# Show players Device OS
|
||||
# (Android, iOS etc.)
|
||||
# (Android, iOS, etc.)
|
||||
OS: true
|
||||
|
||||
# Show players Device Model
|
||||
# (iPhone 7 etc.)
|
||||
# (iPhone 7, etc.)
|
||||
Model: true
|
||||
|
||||
# Show players UI settings
|
||||
@ -34,6 +37,9 @@ GUI: true
|
||||
# (Touch, Mouse or Controller)
|
||||
Controls: true
|
||||
|
||||
# Show players Unique ID (UUID)
|
||||
UUID: true
|
||||
|
||||
# Show players health
|
||||
Health: true
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#Device models
|
||||
# Device models
|
||||
|
||||
iPhone4,1: iPhone 4s
|
||||
iPhone5,1: iPhone 5
|
||||
@ -67,6 +67,8 @@ iPad7,4: iPad Pro (10.5-inch)
|
||||
|
||||
SAMSUNG SM-J327T1: Samsung Galaxy J3 Prime Black
|
||||
|
||||
SAMSUNG SM-A107F: Samsung Galaxy A10s (2019)
|
||||
|
||||
SAMSUNG SM-A530x: Samsung Galaxy A8 (2018)
|
||||
SAMSUNG SM-A730x: Samsung Galaxy A8+ (2018)
|
||||
SAMSUNG SM-A810x: Samsung Galaxy A8 (2016)
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Matthww\PlayerInfo;
|
||||
namespace Matthww\PlayerInfo;
|
||||
|
||||
use Matthww\PlayerInfo\Tasks\FetchModelsTask;
|
||||
use Matthww\PlayerInfo\Tasks\LoadTask;
|
||||
@ -9,21 +9,17 @@ use pocketmine\command\Command;
|
||||
use pocketmine\command\CommandSender;
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\event\player\PlayerJoinEvent;
|
||||
use pocketmine\event\server\DataPacketReceiveEvent;
|
||||
use pocketmine\network\mcpe\protocol\LoginPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\plugin\PluginBase;
|
||||
use pocketmine\utils\TextFormat as TF;
|
||||
|
||||
class PlayerInfo extends PluginBase implements Listener {
|
||||
|
||||
protected $DeviceOS;
|
||||
protected $DeviceModel;
|
||||
protected $UIProfile;
|
||||
protected $PlayerData;
|
||||
protected $config;
|
||||
|
||||
public function onEnable() {
|
||||
public function onEnable(): void {
|
||||
$this->getServer()->getPluginManager()->registerEvents($this, $this);
|
||||
|
||||
if(!is_dir($this->getDataFolder())) {
|
||||
@ -40,27 +36,18 @@ class PlayerInfo extends PluginBase implements Listener {
|
||||
|
||||
}
|
||||
|
||||
public function onPacketReceived(DataPacketReceiveEvent $receiveEvent) {
|
||||
$pk = $receiveEvent->getPacket();
|
||||
if($pk instanceof LoginPacket) {
|
||||
$this->PlayerData[$pk->username] = $pk->clientData;
|
||||
}
|
||||
}
|
||||
|
||||
public function onJoin(PlayerJoinEvent $joinEvent) {
|
||||
if($this->getConfig()->get("Save") == true) {
|
||||
$player = $joinEvent->getPlayer();
|
||||
if(!is_dir($this->getDataFolder() . "players/".$player->getName())) {
|
||||
$this->getLogger()->info(TF::YELLOW."[PLAYERINFODB] > User not found in db... adding.");
|
||||
$this->getLogger()->info(TF::YELLOW."[PLAYERINFODB] > User not found in db... adding one.");
|
||||
mkdir($this->getDataFolder() . "players/".$player->getName());
|
||||
}
|
||||
$this->getLogger()->info(TF::GREEN.'[PLAYERINFO] > Adding user session '.$player->getName()." to history");
|
||||
date_default_timezone_set("Europe/Warsaw");
|
||||
$this->getLogger()->info(TF::GREEN.'[PLAYERINFO] > Adding user session '.$player->getName().' to history');
|
||||
date_default_timezone_set("UTC");
|
||||
$date = date('m-d-Y_h-i-s_a', time()); // save date and time (Hours need to being separated with "-" too for windows system because it is crazy....)
|
||||
|
||||
|
||||
|
||||
$cdata = $this->PlayerData[$player->getName()];
|
||||
|
||||
$cdata = $player->getNetworkSession()->getPlayerInfo()->getExtraData();
|
||||
$os = ["Unknown", "Android", "iOS", "macOS", "FireOS", "GearVR", "HoloLens", "Windows 10", "Windows", "Dedicated", "Orbis", "Playstation 4", "Nintento Switch", "Xbox One"];
|
||||
$UI = ["Classic UI", "Pocket UI"];
|
||||
$Controls = ["Unknown", "Mouse", "Touch", "Controller"];
|
||||
@ -70,14 +57,16 @@ class PlayerInfo extends PluginBase implements Listener {
|
||||
$this,
|
||||
$date,
|
||||
$player->getName(),
|
||||
$this->getModel($cdata["DeviceModel"]),
|
||||
$os[$cdata["DeviceOS"]],
|
||||
$player->getAddress(),
|
||||
$UI[$cdata["UIProfile"]],
|
||||
$GUI[$cdata["GuiScale"]],
|
||||
$Controls[$cdata["CurrentInputMode"]]
|
||||
|
||||
|
||||
$this->getModel($cdata["DeviceModel"] ?? -1),
|
||||
$os[$cdata["DeviceOS"] ?? -1],
|
||||
$player->getNetworkSession()->getIp(),
|
||||
$player->getNetworkSession()->getPort(),
|
||||
$UI[$cdata["UIProfile"] ?? -1],
|
||||
$GUI[$cdata["GuiScale"] ?? -1],
|
||||
$Controls[$cdata["CurrentInputMode"] ?? -1],
|
||||
$player->getUniqueId(),
|
||||
$player->getHealth(). " HP",
|
||||
"X: " . $player->getPosition()->getFloorX() . ", Y: " . $player->getPosition()->getFloorY() . ", Z: " . $player->getPosition()->getFloorZ()
|
||||
));
|
||||
|
||||
}
|
||||
@ -94,65 +83,70 @@ class PlayerInfo extends PluginBase implements Listener {
|
||||
|
||||
public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool {
|
||||
if(strtolower($command->getName()) == "playerinfo" or strtolower($command->getName()) == "pinfo") {
|
||||
|
||||
$os = ["Unknown", "Android", "iOS", "macOS", "FireOS", "GearVR", "HoloLens", "Windows 10", "Windows", "Dedicated", "Orbis", "NX"];
|
||||
$os = ["Unknown", "Android", "iOS", "macOS", "FireOS", "GearVR", "HoloLens", "Windows 10", "Windows", "Dedicated", "Orbis", "Playstation 4", "Nintento Switch", "Xbox One"];
|
||||
$UI = ["Classic UI", "Pocket UI"];
|
||||
$Controls = ["Unknown", "Mouse", "Touch", "Controller"];
|
||||
$GUI = [-2 => "Minimum", -1 => "Medium", 0 => "Maximum"];
|
||||
|
||||
if(!$sender->hasPermission("playerinfo.use")) {
|
||||
$sender->sendMessage(TF::RED . "[PlayerInfo] No permission");
|
||||
$sender->sendMessage(TF::RED . "[PlayerInfo] You don't have permission to use this command!");
|
||||
return false;
|
||||
}
|
||||
if(!isset($args[0])) {
|
||||
$sender->sendMessage(TF::RED . "[PlayerInfo] Please specify a player");
|
||||
return false;
|
||||
}
|
||||
$target = $this->getServer()->getPlayer($args[0]);
|
||||
$target = $this->getServer()->getPlayerExact($args[0]);
|
||||
|
||||
if(!$target instanceof Player) {
|
||||
if($this->getConfig()->get("Save") == true) {
|
||||
$this->getScheduler()->scheduleTask(new LoadTask($this, $sender, $args[0]));
|
||||
return true;
|
||||
} else {
|
||||
$sender->sendMessage(TF::RED . "[PlayerInfo] Player is not online");
|
||||
$sender->sendMessage(TF::RED . "[PlayerInfo] Player " .TF::WHITE. $args[0]. TF::RED. " is not online or does not exist!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if($target instanceof Player) {
|
||||
$cdata = $this->PlayerData[$target->getName()];
|
||||
$sender->sendMessage(TF::GREEN . TF::BOLD . "===" . TF::GREEN . "PlayerInfo" . TF::GREEN . TF::BOLD . "===");
|
||||
$cdata = $target->getNetworkSession()->getPlayerInfo()->getExtraData();
|
||||
$sender->sendMessage(TF::GREEN . TF::BOLD . "=== " . TF::GREEN . "PlayerInfo" . TF::GREEN . TF::BOLD . " ===");
|
||||
if($this->getConfig()->get("Name") == true) {
|
||||
$sender->sendMessage(TF::AQUA . "Name: " . TF::RED . $target->getDisplayName());
|
||||
}
|
||||
if($this->getConfig()->get("IP") == true) {
|
||||
$sender->sendMessage(TF::AQUA . "IP: " . TF::RED . $target->getAddress());
|
||||
}
|
||||
if($this->getConfig()->get("Ping") == true) {
|
||||
$sender->sendMessage(TF::AQUA . "Ping: " . TF::RED . $target->getPing() . "ms");
|
||||
if($this->getConfig()->get("Model") == true) {
|
||||
$sender->sendMessage(TF::AQUA . "Model: " . TF::RED . $this->getModel($cdata["DeviceModel"] ?? -1));
|
||||
}
|
||||
if($this->getConfig()->get("OS") == true) {
|
||||
$sender->sendMessage(TF::AQUA . "OS: " . TF::RED . $os[$cdata["DeviceOS"]]);
|
||||
$sender->sendMessage(TF::AQUA . "OS: " . TF::RED . $os[$cdata["DeviceOS"] ?? -1]);
|
||||
}
|
||||
if($this->getConfig()->get("Model") == true) {
|
||||
$sender->sendMessage(TF::AQUA . "Model: " . TF::RED . $this->getModel($cdata["DeviceModel"]));
|
||||
if($this->getConfig()->get("IP") == true) {
|
||||
$sender->sendMessage(TF::AQUA . "IP: " . TF::RED . $target->getNetworkSession()->getIp());
|
||||
}
|
||||
if($this->getConfig()->get("Port") == true) {
|
||||
$sender->sendMessage(TF::AQUA . "Port: " . TF::RED . $target->getNetworkSession()->getPort());
|
||||
}
|
||||
if($this->getConfig()->get("Ping") == true) {
|
||||
$sender->sendMessage(TF::AQUA . "Ping: " . TF::RED . $target->getNetworkSession()->getPing() . "ms");
|
||||
}
|
||||
if($this->getConfig()->get("UI") == true) {
|
||||
$sender->sendMessage(TF::AQUA . "UI: " . TF::RED . $UI[$cdata["UIProfile"]]);
|
||||
$sender->sendMessage(TF::AQUA . "UI: " . TF::RED . $UI[$cdata["UIProfile"] ?? -1]);
|
||||
}
|
||||
if($this->getConfig()->get("GUI") == true) {
|
||||
$sender->sendMessage(TF::AQUA . "GUI Scale: " . TF::RED . $GUI[$cdata["GuiScale"]]);
|
||||
$sender->sendMessage(TF::AQUA . "GUI Scale: " . TF::RED . $GUI[$cdata["GuiScale"] ?? -1]);
|
||||
}
|
||||
if($this->getConfig()->get("Controls") == true) {
|
||||
$sender->sendMessage(TF::AQUA . "Controls: " . TF::RED . $Controls[$cdata["CurrentInputMode"]]);
|
||||
$sender->sendMessage(TF::AQUA . "Controls: " . TF::RED . $Controls[$cdata["CurrentInputMode"] ?? -1]);
|
||||
}
|
||||
if($this->getConfig()->get("UUID") == true) {
|
||||
$sender->sendMessage(TF::AQUA . "UUID: " . TF::RED . $target->getUniqueId());
|
||||
}
|
||||
if($this->getConfig()->get("Health") == true) {
|
||||
$sender->sendMessage(TF::AQUA . "Health: " . TF::RED . $target->getHealth() . "HP");
|
||||
$sender->sendMessage(TF::AQUA . "Health: " . TF::RED . $target->getHealth() . " HP");
|
||||
}
|
||||
if($this->getConfig()->get("Position") == true) {
|
||||
$sender->sendMessage(TF::AQUA . "Position: " . TF::RED . "X: " . $target->getFloorX() . ", Y: " . $target->getFloorY() . ", Z: " . $target->getFloorZ());
|
||||
$sender->sendMessage(TF::AQUA . "Position: " . TF::RED . "X: " . $target->getPosition()->getFloorX() . ", Y: " . $target->getPosition()->getFloorY() . ", Z: " . $target->getPosition()->getFloorZ());
|
||||
}
|
||||
$sender->sendMessage(TF::GREEN . TF::BOLD . "================");
|
||||
$sender->sendMessage(TF::GREEN . TF::BOLD . "==================");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -6,22 +6,22 @@ use pocketmine\utils\Internet;
|
||||
|
||||
class FetchModelsTask extends AsyncTask {
|
||||
|
||||
private $path;
|
||||
private $version;
|
||||
protected $path;
|
||||
protected $version;
|
||||
|
||||
public function __construct(string $path, string $version) {
|
||||
$this->path = $path;
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
public function onRun() {
|
||||
print($this->version);
|
||||
$result = Internet::getURL("https://playerinfo.hillcraft.net/models.yml?v=" . $this->version);
|
||||
public function onRun(): void {
|
||||
$result = Internet::getURL("https://raw.githubusercontent.com/Matthww/PlayerInfo/master/resources/models.yml")->getBody();
|
||||
if(!is_string($result)) {
|
||||
$this->setResult(false);
|
||||
return;
|
||||
}
|
||||
file_put_contents($this->path . "models.yml", $result);
|
||||
|
||||
file_put_contents($this->path. "models.yml", $result);
|
||||
$this->setResult(true);
|
||||
}
|
||||
}
|
||||
|
@ -23,19 +23,23 @@ class LoadTask extends Task {
|
||||
return $this->plugin;
|
||||
}
|
||||
|
||||
public function onRun(int $tick) {
|
||||
public function onRun(): void {
|
||||
if(!file_exists($this->getPlugin()->getDataFolder() . "players/" . strtolower($this->target) . ".json")) {
|
||||
$this->sender->sendMessage(TF::colorize("&c[PlayerInfo] Player &f". $this->target . " &cwas not found!"));
|
||||
$this->sender->sendMessage(TF::colorize("&c[PlayerInfo] Player &f". $this->target . " &cis not online or does not exist!"));
|
||||
} else {
|
||||
$data = new Config($this->getPlugin()->getDataFolder() . "players/" . strtolower($this->target) . ".json", Config::JSON);
|
||||
$this->sender->sendMessage(TF::colorize("&a&l=== &r&aPlayerInfo &a&l==="));
|
||||
$this->sender->sendMessage(TF::colorize("&bName: &c" . $data->get("Name")));
|
||||
$this->sender->sendMessage(TF::colorize("&bIP: &c" . $data->get("IP")));
|
||||
$this->sender->sendMessage(TF::colorize("&bOS: &c" . $data->get("OS")));
|
||||
$this->sender->sendMessage(TF::colorize("&bModel: &c" . $data->get("Model")));
|
||||
$this->sender->sendMessage(TF::colorize("&bOS: &c" . $data->get("OS")));
|
||||
$this->sender->sendMessage(TF::colorize("&bIP: &c" . $data->get("IP")));
|
||||
$this->sender->sendMessage(TF::colorize("&bPort: &c" . $data->get("Port")));
|
||||
$this->sender->sendMessage(TF::colorize("&bUI: &c" . $data->get("UI")));
|
||||
$this->sender->sendMessage(TF::colorize("&bGUI Scale: &c" . $data->get("GUI")));
|
||||
$this->sender->sendMessage(TF::colorize("&bControls: &c" . $data->get("Controls")));
|
||||
$this->sender->sendMessage(TF::colorize("&UUID: &c" . $data->get("UUID")));
|
||||
$this->sender->sendMessage(TF::colorize("&Health: &c" . $data->get("Health")));
|
||||
$this->sender->sendMessage(TF::colorize("&Position: &c" . $data->get("Position")));
|
||||
$this->sender->sendMessage(TF::colorize("&a&l================"));
|
||||
}
|
||||
}
|
||||
|
@ -14,36 +14,48 @@ class SaveTask extends Task {
|
||||
protected $model;
|
||||
protected $os;
|
||||
protected $ip;
|
||||
protected $port;
|
||||
protected $UI;
|
||||
protected $GUI;
|
||||
protected $controls;
|
||||
protected $uuid;
|
||||
protected $health;
|
||||
protected $position;
|
||||
|
||||
public function __construct($plugin, string $date, string $player, string $model, string $os, string $ip, string $UI, string $GUI, string $controls) {
|
||||
public function __construct($plugin, string $date, string $player, string $model, string $os, string $ip, string $port, string $UI, string $GUI, string $controls, string $uuid, string $health, string $position) {
|
||||
$this->plugin = $plugin;
|
||||
$this->date = $date;
|
||||
$this->player = $player;
|
||||
$this->model = $model;
|
||||
$this->os = $os;
|
||||
$this->ip = $ip;
|
||||
$this->port = $port;
|
||||
$this->UI = $UI;
|
||||
$this->GUI = $GUI;
|
||||
$this->controls = $controls;
|
||||
$this->uuid = $uuid;
|
||||
$this->health = $health;
|
||||
$this->position = $position;
|
||||
}
|
||||
|
||||
public function getPlugin() {
|
||||
return $this->plugin;
|
||||
}
|
||||
|
||||
public function onRun(int $tick) {
|
||||
public function onRun(): void {
|
||||
$data = new Config($this->getPlugin()->getDataFolder() . "players/" .$this->player."/". strtolower($this->player)."-".$this->date. ".json", Config::JSON);
|
||||
$data->set("Date", $this->date);
|
||||
$data->set("Name", $this->player);
|
||||
$data->set("Model", $this->model);
|
||||
$data->set("OS", $this->os);
|
||||
$data->set("IP", $this->ip);
|
||||
$data->set("Port", $this->port);
|
||||
$data->set("UI", $this->UI);
|
||||
$data->set("GUI", $this->GUI);
|
||||
$data->set("Controls", $this->controls);
|
||||
$data->set("UUID", $this->uuid);
|
||||
$data->set("Health", $this->health);
|
||||
$data->set("Position", $this->position);
|
||||
$data->save();
|
||||
$data->reload();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user