Compatibility with 3.0.0-ALPHA7

Added support for 3.0.0-ALPHA7 dropped support for lower api versions.
Added HP and coords
This commit is contained in:
Matthew 2017-08-14 16:51:02 +02:00
parent 4489f8072c
commit 51f5fc0aa2
4 changed files with 69 additions and 68 deletions

View File

@ -1,7 +1,7 @@
name: PlayerInfo name: PlayerInfo
version: 1.2.3 version: 1.3.0
author: Matthww author: Matthww
api: [3.0.0-ALPHA1, 3.0.0-ALPHA2, 3.0.0-ALPHA3, 3.0.0-ALPHA4, 3.0.0-ALPHA5, 3.0.0-ALPHA6] api: [3.0.0-ALPHA7]
description: Shows info about a certain player! description: Shows info about a certain player!
main: Matthww\PlayerInfo\PlayerInfo main: Matthww\PlayerInfo\PlayerInfo

View File

@ -1,28 +1,36 @@
--- ---
# Configuration for PlayerInfo # Configuration for PlayerInfo
# True = enabled
# False = disabled
# Show player's name # Show players name
Name: true Name: true
# Show player's IP # Show players IP
IP: true IP: true
# Show Device OS # Show players Device OS
# (Android, iOS etc.) # (Android, iOS etc.)
OS: true OS: true
# Show Device Model # Show players Device Model
# (iPhone 7 etc.) # (iPhone 7 etc.)
Model: true Model: true
# Show player's UI settings # Show players UI settings
# (Classic UI or Pocket UI) # (Classic UI or Pocket UI)
UI: true UI: true
# Show player's GUI scale settings # Show players GUI scale settings
GUI: true GUI: true
# Show player's controls # Show players controls
# (Touch, Mouse or Controller) # (Touch, Mouse or Controller)
Controls: true Controls: true
# Show players health
Health: true
# Show players position
Position: true
... ...

View File

@ -5,11 +5,13 @@ namespace Matthww\PlayerInfo;
use Matthww\PlayerInfo\utils\SpoonDetector; use Matthww\PlayerInfo\utils\SpoonDetector;
use pocketmine\command\Command; use pocketmine\command\Command;
use pocketmine\command\CommandSender; use pocketmine\command\CommandSender;
use pocketmine\command\ConsoleCommandSender;
use pocketmine\event\Listener; use pocketmine\event\Listener;
use pocketmine\event\server\DataPacketReceiveEvent; use pocketmine\event\server\DataPacketReceiveEvent;
use pocketmine\network\mcpe\protocol\LoginPacket; use pocketmine\network\mcpe\protocol\LoginPacket;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\plugin\PluginBase; use pocketmine\plugin\PluginBase;
use pocketmine\utils\TextFormat as TF;
class PlayerInfo extends PluginBase implements Listener { class PlayerInfo extends PluginBase implements Listener {
@ -22,8 +24,8 @@ class PlayerInfo extends PluginBase implements Listener {
public function onEnable() { public function onEnable() {
$this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getServer()->getPluginManager()->registerEvents($this, $this);
$this->saveDefaultConfig(); $this->saveDefaultConfig();
$this->getLogger()->notice("is enabled");
SpoonDetector::printSpoon($this, 'spoon.txt'); SpoonDetector::printSpoon($this, 'spoon.txt');
$this->getLogger()->notice("is enabled");
} }
public function onDisable() { public function onDisable() {
@ -37,77 +39,68 @@ class PlayerInfo extends PluginBase implements Listener {
} }
} }
public function onCommand(CommandSender $sender, Command $command, $label, array $args) { public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool {
if (strtolower($command->getName()) == "playerinfo" or strtolower($command->getName()) == "pinfo") { if (strtolower($command->getName()) == "playerinfo" or strtolower($command->getName()) == "pinfo") {
$os = ["Unknown", "Android", "iOS", "macOS", "FireOS", "GearVR", "HoloLens", "Windows 10", "Windows", "Dedicated"]; $os = ["Unknown", "Android", "iOS", "macOS", "FireOS", "GearVR", "HoloLens", "Windows 10", "Windows", "Dedicated", "Orbis", "NX"];
$UI = ["Classic UI", "Pocket UI"]; $UI = ["Classic UI", "Pocket UI"];
$Controls = ["Unknown", "Mouse", "Touch", "Controller"]; $Controls = ["Unknown", "Mouse", "Touch", "Controller"];
$GUI = [-2 => "Minimum", -1 => "Medium", 0 => "Maximum"]; $GUI = [-2 => "Minimum", -1 => "Medium", 0 => "Maximum"];
if ($sender->hasPermission("playerinfo.use")) { if ($sender->hasPermission("playerinfo.use")) {
if (isset($args[0])) { if ($sender instanceof ConsoleCommandSender) {
if ($this->getServer()->getPlayer($args[0])) { if (isset($args[0])) {
$target = $this->getServer()->getPlayer($args[0]); $target = $this->getServer()->getPlayer($args[0]);
$cdata = $this->PlayerData[$target->getName()];
$sender->sendMessage("§a§l===§r§aPlayer Info§a§l===");
if ($this->getConfig()->get("Name") == true) {
$sender->sendMessage("§bName: §c" . $target->getDisplayName());
}
if ($this->getConfig()->get("IP") == true) {
$sender->sendMessage("§bIP: §c" . $target->getAddress());
}
if ($this->getConfig()->get("OS") == true) {
$sender->sendMessage("§bOS: §c" . $os[$cdata["DeviceOS"]]);
}
if ($this->getConfig()->get("Model") == true) {
$sender->sendMessage("§bModel: §c" . $cdata["DeviceModel"]);
}
if ($this->getConfig()->get("UI") == true) {
$sender->sendMessage("§bUI: §c" . $UI[$cdata["UIProfile"]]);
}
if ($this->getConfig()->get("GUI") == true) {
$sender->sendMessage("§bGUI Scale: §c" . $GUI[$cdata["GuiScale"]]);
}
if ($this->getConfig()->get("Controls") == true) {
$sender->sendMessage("§bControls: §c" . $Controls[$cdata["CurrentInputMode"]]);
}
$sender->sendMessage("§a§l==============");
return true;
} else { } else {
$sender->sendMessage("§c[Error] Player not found"); $sender->sendMessage(TF::RED . "[Error] Please specify a player");
return false;
} }
} else { } else {
if ($sender instanceof Player) { if ($sender instanceof Player and !isset($args[0])) {
$cdata = $this->PlayerData[$sender->getName()]; $target = $sender->getPlayer();
$sender->sendMessage("§a§l===§r§aPlayer Info§a§l===");
if ($this->getConfig()->get("Name") == true) {
$sender->sendMessage("§bName: §c" . $sender->getDisplayName());
}
if ($this->getConfig()->get("IP") == true) {
$sender->sendMessage("§bIP: §c" . $sender->getAddress());
}
if ($this->getConfig()->get("OS") == true) {
$sender->sendMessage("§bOS: §c" . $os[$cdata["DeviceOS"]]);
}
if ($this->getConfig()->get("Model") == true) {
$sender->sendMessage("§bModel: §c" . $cdata["DeviceModel"]);
}
if ($this->getConfig()->get("UI") == true) {
$sender->sendMessage("§bUI: §c" . $UI[$cdata["UIProfile"]]);
}
if ($this->getConfig()->get("GUI") == true) {
$sender->sendMessage("§bGUI Scale: §c" . $GUI[$cdata["GuiScale"]]);
}
if ($this->getConfig()->get("Controls") == true) {
$sender->sendMessage("§bControls: §c" . $Controls[$cdata["CurrentInputMode"]]);
}
$sender->sendMessage("§a§l==============");
return true;
} else { } else {
$sender->sendMessage("§c[Error] Please specify a player"); $target = $this->getServer()->getPlayer($args[0]);
} }
} }
} else {
$sender->sendMessage(TF::RED . "[Error] No permission");
return false;
}
if ($target instanceof Player) {
$cdata = $this->PlayerData[$target->getName()];
$sender->sendMessage(TF::GREEN . TF::BOLD . "===" . TF::GREEN . "Player Info" . 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("OS") == true) {
$sender->sendMessage(TF::AQUA . "OS: " . TF::RED . $os[$cdata["DeviceOS"]]);
}
if ($this->getConfig()->get("Model") == true) {
$sender->sendMessage(TF::AQUA . "Model: " . TF::RED . $cdata["DeviceModel"]);
}
if ($this->getConfig()->get("UI") == true) {
$sender->sendMessage(TF::AQUA . "UI: " . TF::RED . $UI[$cdata["UIProfile"]]);
}
if ($this->getConfig()->get("GUI") == true) {
$sender->sendMessage(TF::AQUA . "GUI Scale: " . TF::RED . $GUI[$cdata["GuiScale"]]);
}
if ($this->getConfig()->get("Controls") == true) {
$sender->sendMessage(TF::AQUA . "Controls: " . TF::RED . $Controls[$cdata["CurrentInputMode"]]);
}
if ($this->getConfig()->get("Health") == true) {
$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::GREEN . TF::BOLD . "================");
return true;
} else {
$sender->sendMessage(TF::RED . "[Error] Player is not online");
return false;
} }
} }
return true; return true;

View File

@ -28,7 +28,7 @@ class SpoonDetector {
In order to begin using this plugin you must understand that you will be offered no support. 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. 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)?"; Have you read and understood the above (type 'yes' after the question mark)?";