Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Config my code

Comments in 'Plugin Development' started by PolskiTHEPLAYER, Feb 7, 2016.

  1. PolskiTHEPLAYER
    Offline

    PolskiTHEPLAYER New Member

    Joined:
    Apr 1, 2015
    Posts:
    55
    Minecraft User:
    Flsmers
    <?php

    namespace thebigsmileXD\SkyBlock\subcommand;

    use pocketmine\command\CommandSender;
    use pocketmine\Player;
    use pocketmine\utils\TextFormat;

    class HomeSubCommand extends SubCommand{

    public function canUse(CommandSender $sender){
    return ($sender instanceof Player) and $sender->hasPermission("skyblock.command.home");
    }

    public function getUsage(){
    return "[island number]";
    }

    public function getName(){
    return "home";
    }

    public function getDescription(){
    return "Teleport to your island home. Use island number if multiple homes";
    }

    public function getAliases(){
    return ["h"];
    }

    public function execute(CommandSender $sender, array $args){
    if(empty($args)){
    $plotNumber = 1;
    }
    elseif(count($args) === 1 and is_numeric($args[0])){
    $plotNumber = (int) $args[0];
    }
    else{
    return false;
    }
    $plots = $this->getPlugin()->getProvider()->getPlotsByOwner($sender->getName());
    if(empty($plots)){
    $sender->sendMessage(TextFormat::RED . "You don't have any islands");
    return true;
    }
    if(!isset($plots[$plotNumber - 1])){
    $sender->sendMessage(TextFormat::RED . "You don't have an island with home number $plotNumber");
    return true;
    }
    $player = $this->getPlugin()->getServer()->getPlayer($sender->getName());
    $plot = $plots[$plotNumber - 1];
    if($this->getPlugin()->teleportPlayerToPlot($player, $plot)){
    $sender->sendMessage(TextFormat::GREEN . "Teleported to " . TextFormat::WHITE . $plot);
    }
    else{
    $sender->sendMessage(TextFormat::GREEN . "Could not teleport because island world " . $plot->levelName . " is not loaded");
    }
    return true;
    }
    }

    What editi this code to teleport in multi world
  2. XxD7omGamer
    Offline

    XxD7omGamer New Member

    Joined:
    Jun 28, 2015
    Posts:
    38
    Minecraft User:
    XxD7omGamer
    Make this i can't read :/
    PHP:
    <?php

    namespace thebigsmileXD\SkyBlock\subcommand;

    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\Player;
    use 
    pocketmine\utils\TextFormat;

    class 
    HomeSubCommand extends SubCommand{

    public function 
    canUse(CommandSender $sender){
    return (
    $sender instanceof Player) and $sender->hasPermission("skyblock.command.home");
    }

    public function 
    getUsage(){
    return 
    "[island number]";
    }

    public function 
    getName(){
    return 
    "home";
    }

    public function 
    getDescription(){
    return 
    "Teleport to your island home. Use island number if multiple homes";
    }

    public function 
    getAliases(){
    return [
    "h"];
    }

    public function 
    execute(CommandSender $sender, array $args){
    if(empty(
    $args)){
    $plotNumber 1;
    }
    elseif(
    count($args) === and is_numeric($args[0])){
    $plotNumber = (int) $args[0];
    }
    else{
    return 
    false;
    }
    $plots $this->getPlugin()->getProvider()->getPlotsByOwner($sender->getName());
    if(empty(
    $plots)){
    $sender->sendMessage(TextFormat::RED "You don't have any islands");
    return 
    true;
    }
    if(!isset(
    $plots[$plotNumber 1])){
    $sender->sendMessage(TextFormat::RED "You don't have an island with home number $plotNumber");
    return 
    true;
    }
    $player $this->getPlugin()->getServer()->getPlayer($sender->getName());
    $plot $plots[$plotNumber 1];
    if(
    $this->getPlugin()->teleportPlayerToPlot($player$plot)){
    $sender->sendMessage(TextFormat::GREEN "Teleported to " TextFormat::WHITE $plot);
    }
    else{
    $sender->sendMessage(TextFormat::GREEN "Could not teleport because island world " $plot->levelName " is not loaded");
    }
    return 
    true;
    }
    }
    Bluplayz likes this.
  3. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    We can't read your mind, if you want help, request it as well.

    Ah, and use PHP tags, please.
    Code:
    [PHP] your code [/PHP]
    
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Ugh, this looks familiar to me... Like some code used in WorldEditArt/PocketFactions? @thebigsmileXD (not blaming, just curious).

Share This Page

Advertisement