From ced3a536c0d7888ba144bd0653fbc995a346f29a Mon Sep 17 00:00:00 2001 From: Matthww Date: Mon, 5 Feb 2018 11:04:00 +0100 Subject: [PATCH] Add models Make models more easier to read. I don't even know why I'm doing this. --- resources/models.yml | 75 +++++++++++++++++++++++++++ src/Matthww/PlayerInfo/PlayerInfo.php | 28 ++++++++-- 2 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 resources/models.yml diff --git a/resources/models.yml b/resources/models.yml new file mode 100644 index 0000000..5cc6656 --- /dev/null +++ b/resources/models.yml @@ -0,0 +1,75 @@ +#Device models + +iPhone4,1: iPhone 4s +iPhone5,1: iPhone 5 +iPhone5,2: iPhone 5 +iPhone5,3: iPhone 5c +iPhone5,4: iPhone 5c +iPhone6,1: iPhone 5s +iPhone6,2: iPhone 5s +iPhone7,2: iPhone 6 +iPhone7,1: iPhone 6 Plus +iPhone8,1: iPhone 6s +iPhone8,2: iPhone 6s Plus +iPhone8,4: iPhone SE +iPhone9,1: iPhone 7 +iPhone9,3: iPhone 7 +iPhone9,2: iPhone 7 Plus +iPhone9,4: iPhone 7 Plus +iPhone10,1: iPhone 8 +iPhone10,4: iPhone 8 +iPhone10,2: iPhone 8 Plus +iPhone10,5: iPhone 8 Plus +iPhone10,3: iPhone X +iPhone10,6: iPhone X + + +SAMSUNG SM-A530x: Samsung Galaxy A8 (2018) +SAMSUNG SM-A730x: Samsung Galaxy A8+ (2018) +SAMSUNG SM-A810x: Samsung Galaxy A8 (2016) + +SAMSUNG SM-A7100: Samsung Galaxy A7 (2016) +SAMSUNG SM-A710F: Samsung Galaxy A7 (2016) +SAMSUNG SM-A710FD: Samsung Galaxy A7 (2016) +SAMSUNG SM-A710M: Samsung Galaxy A7 (2016) +SAMSUNG SM-A710Y: Samsung Galaxy A7 (2016) + +SAMSUNG SM-A5100: Samsung Galaxy A5 (2016) +SAMSUNG SM-A510F: Samsung Galaxy A5 (2016) +SAMSUNG SM-A510FD: Samsung Galaxy A5 (2016) +SAMSUNG SM-A510M: Samsung Galaxy A5 (2016) +SAMSUNG SM-A510Y: Samsung Galaxy A5 (2016) + +SAMSUNG SM-A310F: Samsung Galaxy A3 (2016) +SAMSUNG SM-A310M: Samsung Galaxy A3 (2016) + +SAMSUNG SM-G930F: Samsung Galaxy S7 +SAMSUNG SM-G930FD: Samsung Galaxy S7 +SAMSUNG SM-G9300: Samsung Galaxy S7 +SAMSUNG SM-G930A: Samsung Galaxy S7 +SAMSUNG SM-G930V: Samsung Galaxy S7 +SAMSUNG SM-G930AZ: Samsung Galaxy S7 +SAMSUNG SM-G930S: Samsung Galaxy S7 +SAMSUNG SM-G930K: Samsung Galaxy S7 +SAMSUNG SM-G930W8: Samsung Galaxy S7 + +SAMSUNG SM-G935F: Samsung Galaxy S7 Edge +SAMSUNG SM-G935FD: Samsung Galaxy S7 Edge +SAMSUNG SM-G9350: Samsung Galaxy S7 Edge +SAMSUNG SM-G935A: Samsung Galaxy S7 Edge +SAMSUNG SM-G935V: Samsung Galaxy S7 Edge +SAMSUNG SM-G935U: Samsung Galaxy S7 Edge +SAMSUNG SM-G935S: Samsung Galaxy S7 Edge +SAMSUNG SM-G935K: Samsung Galaxy S7 Edge +SAMSUNG SM-G935W8: Samsung Galaxy S7 Edge +SAMSUNG SC-02H: Samsung Galaxy S7 Edge + +SAMSUNG SM-N950x: Samsung Galaxy Note 8 +SAMSUNG SM-G950x: Samsung Galaxy S8 +SAMSUNG SM-G955x: Samsung Galaxy S8+ + + + +LGE LG-V495: LG V495 + +AMAZON KFDOWI: Amazon Fire HD 8 Tablet \ No newline at end of file diff --git a/src/Matthww/PlayerInfo/PlayerInfo.php b/src/Matthww/PlayerInfo/PlayerInfo.php index 9250a21..a2ee55d 100644 --- a/src/Matthww/PlayerInfo/PlayerInfo.php +++ b/src/Matthww/PlayerInfo/PlayerInfo.php @@ -23,15 +23,27 @@ class PlayerInfo extends PluginBase implements Listener { public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); - $this->saveDefaultConfig(); + + if(!is_dir($this->getDataFolder())) { + mkdir($this->getDataFolder()); + } + if(!file_exists($this->getDataFolder() . "config.yml")) { + $this->saveDefaultConfig(); + } + + if(!file_exists($this->getDataFolder() . "models.yml")) { + $this->saveResource("models.yml", false); + } + SpoonDetector::printSpoon($this, 'spoon.txt'); $this->getLogger()->notice("is enabled"); + } public function onDisable() { $this->getLogger()->notice("is disabled!"); } - + public function onPacketReceived(DataPacketReceiveEvent $receiveEvent) { $pk = $receiveEvent->getPacket(); if($pk instanceof LoginPacket) { @@ -39,6 +51,16 @@ class PlayerInfo extends PluginBase implements Listener { } } + public function DeviceModel(string $model) { + $models = yaml_parse_file($this->getDataFolder() . "models.yml"); + + if(isset($models[$model])) { + return $models[$model]; + } else { + return $model; + } + } + public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool { if(strtolower($command->getName()) == "playerinfo" or strtolower($command->getName()) == "pinfo") { @@ -82,7 +104,7 @@ class PlayerInfo extends PluginBase implements Listener { $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"]); + $sender->sendMessage(TF::AQUA . "Model: " . TF::RED . $this->DeviceModel($cdata["DeviceModel"])); } if($this->getConfig()->get("UI") == true) { $sender->sendMessage(TF::AQUA . "UI: " . TF::RED . $UI[$cdata["UIProfile"]]);