-
-
Save jasonw4331/8ea725774fb11bc947e32ca347bc4ab4 to your computer and use it in GitHub Desktop.
<?php | |
declare(strict_types=1); | |
/** | |
* @name MyPlotPlotHomes | |
* @main jasonwynn10\MyPlotPlotHomes\Main | |
* @version 0.1.0 | |
* @api 3.0.0 | |
* @description A plugin script which changes the home subcommand parameters and actions | |
* @author jasonwynn10 | |
* @depend MyPlot | |
*/ | |
namespace jasonwynn10\MyPlotPlotHomes { | |
use MyPlot\Commands; | |
use MyPlot\MyPlot; | |
use MyPlot\Plot; | |
use MyPlot\subcommand\HomeSubCommand; | |
use pocketmine\command\CommandSender; | |
use pocketmine\OfflinePlayer; | |
use pocketmine\Player; | |
use pocketmine\plugin\PluginBase; | |
use pocketmine\utils\TextFormat; | |
class Main extends PluginBase { | |
/** @var self|null $instance */ | |
private static $instance = null; | |
/** | |
* @return self|null | |
*/ | |
public static function getInstance() : ?self { | |
return self::$instance; | |
} | |
public function onEnable() { | |
self::$instance = $this; | |
$command = new class(MyPlot::getInstance(), "home") extends HomeSubCommand { | |
public function getUsage() : string { | |
return "/p home [player: string] [number: int] [world: string]"; | |
} | |
/** | |
* @param Player $sender | |
* @param array $args | |
* | |
* @return bool | |
*/ | |
public function execute(CommandSender $sender, array $args) : bool { | |
$selected = null; | |
if(empty($args)) { | |
$selected = $sender; | |
$selectedName = $sender->getName(); | |
$plotNumber = 1; | |
}elseif(isset($args[0])) { | |
$selected = $this->getPlugin()->getServer()->getPlayer($args[0]) ?? $this->getPlugin()->getServer()->getOfflinePlayer($args[0]); | |
$selectedName = $selected->getName(); | |
$plotNumber = (int) ($args[1] ?? 1); | |
}else{ | |
return false; | |
} | |
if($selected instanceof OfflinePlayer and !isset($args[2])) { | |
$sender->sendMessage(TextFormat::RED . $this->translateString("home.error")); | |
return true; | |
} | |
$levelName = $args[2] ?? $selected->getLevel()->getFolderName(); | |
$plots = $this->getPlugin()->getPlotsOfPlayer($selectedName, $levelName); | |
if(empty($plots)) { | |
$sender->sendMessage(TextFormat::RED . "No plots found in world"); | |
return true; | |
} | |
if(!isset($plots[$plotNumber - 1])) { | |
$sender->sendMessage(TextFormat::RED . $this->translateString("home.notexist", [$plotNumber])); | |
return true; | |
} | |
usort($plots, function(Plot $plot1, Plot $plot2) { | |
if($plot1->levelName == $plot2->levelName) { | |
return 0; | |
} | |
return ($plot1->levelName < $plot2->levelName) ? -1 : 1; | |
}); | |
$plot = $plots[$plotNumber - 1]; | |
if($this->getPlugin()->teleportPlayerToPlot($sender, $plot)) { | |
$sender->sendMessage($this->translateString("home.success", [$plot, $plot->levelName])); | |
}else{ | |
$sender->sendMessage(TextFormat::RED . $this->translateString("home.error")); | |
} | |
return true; | |
} | |
}; | |
/** @var Commands $commands */ | |
$commands = $this->getServer()->getCommandMap()->getCommand("plot"); | |
$commands->unloadSubCommand("home"); | |
$commands->loadSubCommand($command); | |
$this->getLogger()->debug("SubCommand loaded"); | |
} | |
} | |
} |
That's no problem. He won't "fix" this, because it trys to go to 2 1. Plot
Well, nvm I've fixed it for me.
Richtig GEIL
@SchdoeNVIDIA hoe did you fixed it?
Wo muss ich die Datei hinpacken? Also in welchen Ordner auf meinem Server
The description of this script is the description from the Border script xD
The description of this script is the description from the Border script xD
shh no its not
Ich brauche ein plugin wo man/p h (spielername) machen kann es ist ein Bug das es nicht geht aber kannst du bitte so ein plugin machen bitte
Ich brauche ein plugin wo man/p h (spielername) machen kann es ist ein Bug das es nicht geht aber kannst du bitte so ein plugin machen bitte
Bro, auf GitHub und Gist schreibt an in Englisch!
I need a plugin where you can make/p h (player name) it is a bug that it does not work but can you please make such a plugin please
There is a little problem:
I can't do /p h 2 for example. it just tells me "you couldn't teleported to your plot"
But i can do /p h and /p h name