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

How to fix?

Discussion in 'Development' started by MSG100PM, Jul 4, 2018.

  1. MSG100PM

    MSG100PM Slime

    Messages:
    95
    GitHub:
    MSG100TC
    Hello, I'm using a plugin called "Top Players" that can show top kills, deaths, break, block place...etc in a floating text particle, but I keep getting this error and I am unable to fix it:

    [16:02:42] [Server thread/CRITICAL]: Error: "Class 'Syams255\aTopPlayersListener' not found" (EXCEPTION) in "TopPlayers-master/src/Syams255/TopPlayers" at line 30
    [16:02:42] [Server thread/DEBUG]: #0 src/pocketmine/plugin/PluginBase(90): Syams255\TopPlayers->onEnable()
    [16:02:42] [Server thread/DEBUG]: #1 PocketMine-DevTools.phar/src/FolderPluginLoader/FolderPluginLoader(131): pocketmine\plugin\PluginBase->setEnabled(boolean 1)
    [16:02:42] [Server thread/DEBUG]: #2 src/pocketmine/plugin/PluginManager(576): FolderPluginLoader\FolderPluginLoader->enablePlugin(Syams255\TopPlayers object)
    [16:02:42] [Server thread/DEBUG]: #3 src/pocketmine/Server(1919): pocketmine\plugin\PluginManager->enablePlugin(Syams255\TopPlayers object)
    [16:02:42] [Server thread/DEBUG]: #4 src/pocketmine/Server(1905): pocketmine\Server->enablePlugin(Syams255\TopPlayers object)
    [16:02:42] [Server thread/DEBUG]: #5 src/pocketmine/Server(1699): pocketmine\Server->enablePlugins(integer 1)
    [16:02:42] [Server thread/DEBUG]: #6 src/pocketmine/PocketMine(305): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string C:\Users\pc\Desktop\PocketMine-MP\, string C:\Users\pc\Desktop\PocketMine-MP\plugins\)
    [16:02:42] [Server thread/DEBUG]: #7 C:/Users/pc\Desktop/PocketMine-MP/PocketMine-MP.phar(1): require(string phar://C:/Users/pc/Desktop/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/PocketMine.php)

    Here's the code:
    PHP:
    <?php
        
    namespace Syams255;
        use 
    pocketmine\plugin\PluginBase;
        use 
    pocketmine\utils\Config;
        use 
    pocketmine\math\Vector3;
        use 
    pocketmine\level\particle\FloatingTextParticle;
        use 
    pocketmine\command\Command;
        use 
    pocketmine\command\CommandSender;
        use 
    pocketmine\event\Listener;
        use 
    pocketmine\Player;
        use 
    pocketmine\Server;
        class 
    TopPlayers extends PluginBase implements Listener {
            public 
    $config$users$particles;
            public function 
    onEnable() {
                
    $folder $this->getDataFolder();
                if(!
    is_dir($folder))
                    @
    mkdir($folder);
                
    $this->saveResource('config.yml');
                
    $this->config = (new Config($folder.'config.yml'Config::YAML))->getAll();
                
    $this->users = new \SQLite3($folder.'statistics.db');
                
    $this->users->exec("CREATE TABLE IF NOT EXISTS users(
                                                            nickname TEXT PRIMARY KEY NOT NULL,
                                                            kill INTEGER default 0 NOT NULL,
                                                            death INTEGER default 0 NOT NULL,
                                                            place INTEGER default 0 NOT NULL,
                                                            break INTEGER default 0 NOT NULL
                                                        );
                                                    "
    );
                unset(
    $folder);
                
    $this->getServer()->getPluginManager()->registerEvents(new aTopPlayersListener($this), $this);
            }
            public function 
    onCommand(CommandSender $senderCommand $command$label, array $args):bool {
                if(
    $sender instanceof Player) {
                    if(
    strtolower($command->getName()) == 'top') {
                        if(
    count($args) == || count($args) == 2) {
                            
    $action strtolower($args[0]);
                            if(
    $action == 'kill' || $action == 'death' || $action == 'break' || $action == 'place') {
                                
    $data = [
                                    
    'type' => $action,
                                    
    'x' => round($sender->getX()),
                                    
    'y' => round($sender->getY()),
                                    
    'z' => round($sender->getZ()),
                                    
    'level' => strtolower($sender->getLevel()->getName())
                                ];
                                
    $this->save($data);
                                
    $this->create($action);
                                return 
    true;
                            }
                            
    $user $this->users->query("SELECT * FROM `users` WHERE `nickname` = '$action'")->fetchArray(SQLITE3_ASSOC);
                            if(
    $user !== false)
                                
    $sender->sendMessage(str_replace('{player}'$action$this->config['titleStat'])."\n§aУбил: §d".$user['kill']."\n§aУмер: §d".$user['death']."\n§aСломано: §d".$user['break']."\n§aПоставил: §d".$user['place']);
                            else 
    $sender->sendMessage($this->config['userNotExist']);
                        }
                        else 
    $sender->sendMessage('§eUsing: /top <kill/death/break/place> [player]');
                    }
                }
            }
            public function 
    addParticle() {
                if(
    count($this->config['coords']) > 0)
                    foreach(
    $this->config['coords'] as $type => $stat)
                        
    $this->create($type);
            }
            
    /**
             * @param string $type
             */
            
    private function create($type) {
                
    $coords $this->config['coords'][$type];
                
    $vector3 = new Vector3($coords['x'], $coords['y'], $coords['z']);
                
    $list $this->sort($type);
                
    $this->particles[$type] = new FloatingTextParticle($vector3$list$this->config[$type.'Title']);
                
    $this->getServer()->getLevelByName($this->config['coords'][$type]['level'])->addParticle($this->particles[$type]);
            }
            
    /**
             * @param string  $type
             * @return string $list
             */
            
    public function sort($type) {
                
    $limit $this->config[$type.'Count'];
                
    $top $this->users->query("SELECT nickname,$type FROM `users` ORDER BY $type DESC LIMIT $limit");
                
    $list "";
                while(
    $element $top->fetchArray(SQLITE3_ASSOC))
                    
    $list .= str_replace(['{player}''{value}'], [$element['nickname'], $element[$type]], $this->config[$type.'Element'])."\n";
                return 
    $list;
            }
            
    /**
             * @param array $write
             */
            
    private function save($write false) {
                if(
    $write !== false) {
                    
    $this->config['coords'][$write['type']] = [
                        
    'x' => $write['x'],
                        
    'y' => $write['y'] + 2.5,
                        
    'z' => $write['z'],
                        
    'level' => $write['level']
                    ];
                }
                
    $cfg = new Config($this->getDataFolder().'config.yml'Config::YAML);
                
    $cfg->setAll($this->config);
                
    $cfg->save();
                unset(
    $cfg);
            }
        }
    ?>
     
  2. MSG100PM

    MSG100PM Slime

    Messages:
    95
    GitHub:
    MSG100TC
    Thanks, I can't find other free plugin that can show a list of top kills with floating text.
     
  3. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    If you are using https://github.com/Syams225/TopPlayers/tree/master/src/Syams255
    that plugin hasn't been updated since October last year, and a quick look at the code shows that it never worked anyway. To start with, his listener is called 'TopPlayersListener', not 'aTopPlayersListener', but I don't think fixing that will be the last of your problems. Best ask the developer to fix and update.
     
    corytortoise likes this.
  4. MSG100PM

    MSG100PM Slime

    Messages:
    95
    GitHub:
    MSG100TC
    Hello, thanks for your reply!
    But I am really in need of a leader board plugin like that, and I've been searching for hours, and hours and hours but no luck of finding a working version. This is the only one that I found. If you are able to, can you do a quick rewrite of the plugin? I really need a leaderboard feature on my server, thanks.
     
  5. MSG100PM

    MSG100PM Slime

    Messages:
    95
    GitHub:
    MSG100TC
  6. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    This seems like something I could do. Would you want this plugin only like you asked, or would you use it with a level system, along with tracking a bunch of other stuff, like deaths, kdr, etc.? I have this plugin already. Just let me know what you'd prefer.
     
    MSG100PM likes this.
  7. MSG100PM

    MSG100PM Slime

    Messages:
    95
    GitHub:
    MSG100TC
    Hello!
    I am already using your PvPLevels plugin for a while and I love it a lot! And yeah, it will be awesome if the leaderboard can work with the levels plugin since I have 100 levels configured. Thank you for helping me!
     
    Last edited: Jul 5, 2018
  8. MSG100PM

    MSG100PM Slime

    Messages:
    95
    GitHub:
    MSG100TC
    Hello, when will the Top PvP floating text be finished ?
     
  9. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Maybe in a day or two. I have most of it done, just need to finish up and test it.
     
    MSG100PM likes this.
  10. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    I've finished the request here, if anyone is interested.
     
  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.