1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Updating outdated plugins:

Discussion in 'Plugin Help' started by minijaham, May 20, 2020.

  1. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    PHP:
    <?php

    namespace Alias;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\Player;
    use 
    pocketmine\Iplayer;
    use 
    pocketmine\OfflinePlayer;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\Config;

    class 
    MainClass extends PluginBase implements Listener{
       
        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            if(!
    is_dir($this->getDataFolder()."players/lastip")){
                @
    mkdir($this->getDataFolder()."players/lastip"0777true);
            }
            if(!
    is_dir($this->getDataFolder()."players/ip")){
                @
    mkdir($this->getDataFolder()."players/ip"0777true);
            }
        }
        public function 
    onDisable(){}
        public function 
    onJoin(PlayerJoinEvent $event){
            
    $name $event->getPlayer()->getDisplayName();
            
    $ip $event->getPlayer()->getAddress();
            if(
    is_file($this->getDataFolder()."players/lastip/".$name[0]."/".$name.".yml")){
                
    unlink($this->getDataFolder()."players/lastip/".$name[0]."/".$name.".yml");
                
    $name $event->getPlayer()->getDisplayName();
                
    $ip $event->getPlayer()->getAddress();
                @
    mkdir($this->getDataFolder()."players/lastip/".$name[0].""0777true);
                
    $lastip = new Config($this->getDataFolder()."players/lastip/".$name[0]."/".$name.".yml"CONFIG::YAML, array(
                    
    "lastip" => "".$ip."",
                ));
                
    $lastip->save();
                @
    mkdir($this->getDataFolder()."players/ip/".$ip[0].""0777true);
                
    $ipfile = new Config($this->getDataFolder()."players/ip/".$ip[0]."/".$ip.".txt"CONFIG::ENUM);
                
    $ipfile->set($name);
                
    $ipfile->save();
            }else{
                
    $name $event->getPlayer()->getDisplayName();
                
    $ip $event->getPlayer()->getAddress();
                @
    mkdir($this->getDataFolder()."players/lastip/".$name[0].""0777true);
                
    $lastip = new Config($this->getDataFolder()."players/lastip/".$name[0]."/".$name.".yml"CONFIG::YAML, array(
                    
    "lastip" => "".$ip."",
            ));
                
    $lastip->save();
                @
    mkdir($this->getDataFolder()."players/ip/".$ip[0].""0777true);
                
    $ipfile = new Config($this->getDataFolder()."players/ip/".$ip[0]."/".$ip.".txt"CONFIG::ENUM);
                
    $ipfile->set($name);
                
    $ipfile->save();
            }
        }
        public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
            switch(
    $command->getName()){
                case 
    "alias":
                    if(!isset(
    $args[0])){
                        
    $sender->sendMessage("§7(§c!§7)§c Usage: ".$command->getUsage()."");
                        return 
    true;
                    }
                    
    $name strtolower($args[0]);
                    
    $player $this->getServer()->getPlayer($name);
                    if(
    $player instanceOf Player){
                        
    $ip $player->getPlayer()->getAddress();
                        
    $file = new Config($this->getDataFolder()."players/ip/".$ip[0]."/".$ip.".txt");
                        
    $names $file->getAll(true);
                        
    $names implode(', '$names);
                        
    $sender->sendMessage("§7(§a!§7)§a Showing alias of ".$name."...");
                        
    $sender->sendMessage("§7(§a!§7)§a ".$names."");
                        return 
    true;
                    }else{
                        if(!
    is_file($this->getDataFolder()."players/lastip/".$name[0]."/".$name.".yml")){
                            
    $sender->sendMessage("§7(§c!§7)§c Player does not exist!");
                            return 
    true;
                        }else{
                            
    $lastip = new Config($this->getDataFolder()."players/lastip/".$name[0]."/".$name.".yml");
                            
    $ip $lastip->get("lastip");
                            
    $file = new Config($this->getDataFolder()."players/ip/".$ip[0]."/".$ip.".txt");
                            
    $names $file->getAll(true);
                            if(
    $names == null){
                                
    $sender->sendMessage("§7(§c!§7)§c Player does not exist!");
                                break;
                            }else{
                                
    $names implode(', '$names);
                                
    $sender->sendMessage("§7(§a!§7)§a Showing alias of ".$name."...");
                                
    $sender->sendMessage("§7(§a!§7)§a ".$names."");
                                return 
    true;
                            }
                        }
                    }
                    return 
    true;
            }
        }
    }

    Couldn't contact the original owner of "Alias" plugin .-.

    Can anyone teach me how to update outdated plugins :)
     
  2. folosinod71962

    folosinod71962 Silverfish

    Messages:
    23
    Kinda Simple, First go To plugin.yml and change the api version to [3.0.0].

    DEBBUGING
    I would reccomend to make a free server to have it like test enviroment. Start your server(make sure you have alias installed) and press CTRL+F (if on google chrome) and search alias, if u see like any error try going on forums (pmmp forums/stack overflow etc) and asking or resolving them by yourself.
     
  3. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Well, simply "updating" or injecting the API probably won't solve the problem which it didn't, as the plugin is not coded simply.
    I should've added on that I wanted to know what parts of the code were wrong(doesn't go with the current PMMP)
     
  4. archie426

    archie426 Baby Zombie

    Messages:
    130
    GitHub:
    archie426
    Use PhpStorm to check for symbol changes (or a different ide whatever)
     
  5. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    I did .-. and I tried fixing them but the plugin internal server errors. I'm just gonna leave it here for now. Thanks for your help!
     
  6. Primus

    Primus Zombie Pigman

    Messages:
    749
    Could you explain why Google Chrome is involved into this discussion?
     
  7. folosinod71962

    folosinod71962 Silverfish

    Messages:
    23
    Idk lol, its the most common browser.
     
  8. archie426

    archie426 Baby Zombie

    Messages:
    130
    GitHub:
    archie426
    What’s a browser got to do with updating a plugin
     
    Primus likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.