From bd5d658f0156ec2c4589aef0e5453d907f96f7f3 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sat, 27 May 2017 16:01:28 +0200 Subject: [PATCH] Upload --- README.md | 10 +++ plugin.yml | 20 +++++ src/Matthww/PlayerInfo/PlayerInfo.php | 85 +++++++++++++++++++ .../PlayerInfo/utils/SpoonDetector.php | 57 +++++++++++++ 4 files changed, 172 insertions(+) create mode 100644 README.md create mode 100644 plugin.yml create mode 100644 src/Matthww/PlayerInfo/PlayerInfo.php create mode 100644 src/Matthww/PlayerInfo/utils/SpoonDetector.php diff --git a/README.md b/README.md new file mode 100644 index 0000000..4223456 --- /dev/null +++ b/README.md @@ -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 diff --git a/plugin.yml b/plugin.yml new file mode 100644 index 0000000..91c9a63 --- /dev/null +++ b/plugin.yml @@ -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 " + permission: playerinfo.command.use + pinfo: + description: Show info about a certain player! + usage: "/pinfo " + permission: playerinfo.command.use +permissions: + playerinfo.command.use: + description: "Allows the user to run the playerinfo command" + default: op diff --git a/src/Matthww/PlayerInfo/PlayerInfo.php b/src/Matthww/PlayerInfo/PlayerInfo.php new file mode 100644 index 0000000..7d109ca --- /dev/null +++ b/src/Matthww/PlayerInfo/PlayerInfo.php @@ -0,0 +1,85 @@ +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; + } +} diff --git a/src/Matthww/PlayerInfo/utils/SpoonDetector.php b/src/Matthww/PlayerInfo/utils/SpoonDetector.php new file mode 100644 index 0000000..a2c7774 --- /dev/null +++ b/src/Matthww/PlayerInfo/utils/SpoonDetector.php @@ -0,0 +1,57 @@ +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); + } + } + } +} \ No newline at end of file