mirror of
https://github.com/Matthww/PlayerInfo.git
synced 2025-05-17 10:18:36 +00:00
Upload
This commit is contained in:
parent
61cd7d85ed
commit
bd5d658f01
10
README.md
Normal file
10
README.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# PlayerInfo
|
||||||
|
Shows info about a certain player!
|
||||||
|
|
||||||
|
#### Example:
|
||||||
|
|
||||||
|
Name: Steve\
|
||||||
|
IP: 127.0.0.1\
|
||||||
|
OS: iOS\
|
||||||
|
Model: iPhone\
|
||||||
|
UI: Classic UI
|
20
plugin.yml
Normal file
20
plugin.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
name: PlayerInfo
|
||||||
|
version: 1.0.0
|
||||||
|
author: Matthww
|
||||||
|
api: [3.0.0-ALPHA1, 3.0.0-ALPHA2, 3.0.0-ALPHA3, 3.0.0-ALPHA4, 3.0.0-ALPHA5]
|
||||||
|
description: Shows info about a certain player!
|
||||||
|
main: Matthww\PlayerInfo\PlayerInfo
|
||||||
|
|
||||||
|
commands:
|
||||||
|
playerinfo:
|
||||||
|
description: Show info about a certain player!
|
||||||
|
usage: "/playerinfo <player>"
|
||||||
|
permission: playerinfo.command.use
|
||||||
|
pinfo:
|
||||||
|
description: Show info about a certain player!
|
||||||
|
usage: "/pinfo <player>"
|
||||||
|
permission: playerinfo.command.use
|
||||||
|
permissions:
|
||||||
|
playerinfo.command.use:
|
||||||
|
description: "Allows the user to run the playerinfo command"
|
||||||
|
default: op
|
85
src/Matthww/PlayerInfo/PlayerInfo.php
Normal file
85
src/Matthww/PlayerInfo/PlayerInfo.php
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Matthww\PlayerInfo;
|
||||||
|
|
||||||
|
use Matthww\PlayerInfo\Utils\SpoonDetector;
|
||||||
|
use pocketmine\command\Command;
|
||||||
|
use pocketmine\command\CommandSender;
|
||||||
|
use pocketmine\event\Listener;
|
||||||
|
use pocketmine\event\server\DataPacketReceiveEvent;
|
||||||
|
use pocketmine\network\mcpe\protocol\LoginPacket;
|
||||||
|
use pocketmine\Player;
|
||||||
|
use pocketmine\plugin\PluginBase;
|
||||||
|
|
||||||
|
class PlayerInfo extends PluginBase implements Listener
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $DeviceOS;
|
||||||
|
protected $DeviceModel;
|
||||||
|
protected $UIProfile;
|
||||||
|
protected $PlayerData;
|
||||||
|
protected $target;
|
||||||
|
|
||||||
|
public function onEnable()
|
||||||
|
{
|
||||||
|
file_put_contents($this->getDataFolder() . ".started", "true");
|
||||||
|
SpoonDetector::printSpoon($this, 'spoon.txt');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onDisable()
|
||||||
|
{
|
||||||
|
$this->getLogger()->info("is disabled!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onPacketReceived(DataPacketReceiveEvent $receiveEvent)
|
||||||
|
{
|
||||||
|
if ($receiveEvent->getPacket() instanceof LoginPacket) {
|
||||||
|
$pk = $receiveEvent->getPacket();
|
||||||
|
$this->PlayerData[$pk->username] = $pk->clientData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
|
||||||
|
{
|
||||||
|
if (strtolower($command->getName()) == "playerinfo" or strtolower($command->getName()) == "pinfo") {
|
||||||
|
|
||||||
|
$os = ["Unknown", "Android", "iOS", "OSX", "FireOS", "GearVR", "HoloLens", "Windows 10", "Windows", "Dedicated"];
|
||||||
|
$UI = ["Classic UI", "Pocket UI"];
|
||||||
|
|
||||||
|
if ($sender instanceof Player) {
|
||||||
|
if ($sender->hasPermission("playerinfo.command.use")) {
|
||||||
|
if (!isset($args[0])) {
|
||||||
|
$cdata = $this->PlayerData[$sender->getName()];
|
||||||
|
$sender->sendMessage("§a§l===§r§aPlayer Info§a§l===");
|
||||||
|
$sender->sendMessage("§bName: §c" . $sender->getDisplayName());
|
||||||
|
$sender->sendMessage("§bIP: §c" . $sender->getAddress());
|
||||||
|
$sender->sendMessage("§bOS: §c" . $os[$cdata["DeviceOS"]]);
|
||||||
|
$sender->sendMessage("§bModel: §c" . $cdata["DeviceModel"]);
|
||||||
|
$sender->sendMessage("§bUI: §c" . $UI[$cdata["UIProfile"]]);
|
||||||
|
$sender->sendMessage("§a§l==============");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
if ($this->getServer()->getPlayer($args[0])) {
|
||||||
|
$this->target = $this->getServer()->getPlayer($args[0]);
|
||||||
|
$cdata = $this->PlayerData[$this->target->getName()];
|
||||||
|
$sender->sendMessage("§a§l===§r§aPlayer Info§a§l===");
|
||||||
|
$sender->sendMessage("§bName: §c" . $this->target->getDisplayName());
|
||||||
|
$sender->sendMessage("§bIP: §c" . $this->target->getAddress());
|
||||||
|
$sender->sendMessage("§bOS: §c" . $os[$cdata["DeviceOS"]]);
|
||||||
|
$sender->sendMessage("§bModel: §c" . $cdata["DeviceModel"]);
|
||||||
|
$sender->sendMessage("§bUI: §c" . $UI[$cdata["UIProfile"]]);
|
||||||
|
$sender->sendMessage("§a§l==============");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
$sender->sendMessage("§c[Error] Player not found");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$sender->sendMessage("§cThis command can't be executed by the console.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
57
src/Matthww/PlayerInfo/utils/SpoonDetector.php
Normal file
57
src/Matthww/PlayerInfo/utils/SpoonDetector.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) Falkirks - All Rights Reserved
|
||||||
|
* All credits go to: Falkirks
|
||||||
|
* For making this awesome SpoonDetector :)
|
||||||
|
*/
|
||||||
|
namespace Matthww\PlayerInfo\utils;
|
||||||
|
|
||||||
|
use pocketmine\plugin\PluginBase;
|
||||||
|
use pocketmine\Server;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is deliberately meant to be silly
|
||||||
|
* Class SpoonDetector
|
||||||
|
* @package Matthww\PlayerInfo\utils
|
||||||
|
*/
|
||||||
|
class SpoonDetector{
|
||||||
|
private static $subtleAsciiSpoon = "
|
||||||
|
___ _ __ ___ ___ _ __
|
||||||
|
/ __| '_ \\ / _ \\ / _ \\| '_ \\
|
||||||
|
\\__ \\ |_) | (_) | (_) | | | |
|
||||||
|
|___/ .__/ \\___/ \\___/|_| |_|
|
||||||
|
| |
|
||||||
|
|_|
|
||||||
|
";
|
||||||
|
private static $spoonTxtContent = "
|
||||||
|
The author of this plugin does not provide support for third-party builds of
|
||||||
|
PocketMine-MP (spoons). Spoons detract from the overall quality of the MCPE plugin environment, which is already
|
||||||
|
lacking in quality. They force plugin developers to waste time trying to support conflicting APIs.
|
||||||
|
|
||||||
|
In order to begin using this plugin you must understand that you will be offered no support.
|
||||||
|
|
||||||
|
Furthermore, the GitHub issue tracker for this project is targeted at vanilla PocketMine only. Any bugs you create which don't affect vanilla PocketMine, will be deleted.
|
||||||
|
|
||||||
|
Have you read and understood the above (type 'yes' after the question mark)?";
|
||||||
|
private static $thingsThatAreNotSpoons = [
|
||||||
|
'PocketMine-MP'
|
||||||
|
];
|
||||||
|
public static function isThisSpoon() : bool {
|
||||||
|
return !in_array(Server::getInstance()->getName(), self::$thingsThatAreNotSpoons);
|
||||||
|
}
|
||||||
|
private static function contentValid(string $content): bool {
|
||||||
|
return (strpos($content, self::$spoonTxtContent) > -1) && (strrpos($content, "yes") > strrpos($content, "?"));
|
||||||
|
}
|
||||||
|
public static function printSpoon(PluginBase $pluginBase, $fileToCheck){
|
||||||
|
if(self::isThisSpoon()){
|
||||||
|
if(!file_exists($pluginBase->getDataFolder() . $fileToCheck)){
|
||||||
|
file_put_contents($pluginBase->getDataFolder() . $fileToCheck, self::$spoonTxtContent);
|
||||||
|
}
|
||||||
|
if(!self::contentValid(file_get_contents($pluginBase->getDataFolder() . $fileToCheck))) {
|
||||||
|
$pluginBase->getLogger()->info(self::$subtleAsciiSpoon);
|
||||||
|
$pluginBase->getLogger()->warning("You are attempting to run " . $pluginBase->getDescription()->getName() . " on a SPOON!");
|
||||||
|
$pluginBase->getLogger()->warning("Before using the plugin you will need to open /plugins/" . $pluginBase->getDescription()->getName() . "/" . $fileToCheck . " in a text editor and agree to the terms.");
|
||||||
|
$pluginBase->getServer()->getPluginManager()->disablePlugin($pluginBase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user