Whats the proble of my Plugin

Discussion in 'Development' started by MrJamesAndrewMC, Nov 13, 2016.

  1. MrJamesAndrewMC

    MrJamesAndrewMC Spider Jockey

    Messages:
    36
    The Problem Of My Plugin is PvP is Not Enabling After the Countdown start

    can anyone help me??

    CyberOn.php

    PHP:
    namespace MrjamesAndrewMC\Purges\Purge;

    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\Server;
    use 
    pocketmine\Player;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\level\Level;
    use 
    MrJamesAndrewMC\Purges\Main;
    use 
    MrJamesAndrewMc\Purges\Purge\CyberOff;


    class 
    CyberOn extends PluginTask {
     
        public 
    $main;
     
        public function 
    __construct(Main $main) {
            
    $this->main $main;
            
    parent::__construct $main );
        }
     
        public function 
    onRun($t) {
           
    $this->main->getServer()->broadcastMessage("§4[PURGE]§2 PURGE STARTING NOW!!!!!!!!");
           
    $this->main->purge true;
           foreach (
    $this->main->getServer()->getOnlinePlayers() as $p){
               
    $p->setHealth("50");
           }
           
    $this->main->getServer()->getScheduler()->scheduleDelayedTask(new PurgeOff($this->main) , 20*60);
           
    //Schedule Purge Off
       
        
    }
    }
    CyberOff.php

    PHP:
    namespace MrJamesandrewMC\Purges\Purge;

    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\Server;
    use 
    pocketmine\Player;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\level\Level;
    use 
    MrJamesAndrewMC\Purges\Main;
    use 
    MrJamesAndrewMc\Purges\Purge\StartPurge;

    class 
    CyberOff extends PluginTask {
     
        private 
    $main;
     
        public function 
    __construct(Main $main) {
            
    $this->main $main;
            
    parent::__construct $main );
        }
     
        public function 
    onRun($t) {
            
    $this->main->purge false;
            
    $this->main->getServer()->broadcastMessage("§4[PURGE]§e The PURGE is Over! \n§4[PURGE]§f We Hope You Did Not Kill By Other Players");
        
        }
        
    //put your code here
    }
    StartPurge.php

    PHP:
    namespace MrJamesAndrewMC\Purges\Purge;

    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\Server;
    use 
    pocketmine\Player;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\level\Level;
    use 
    MrJamesAndrewMC\Purges\Main;
    use 
    MrJamesAndrewMc\Purges\Purge\CyberOn;


    class 
    StartPurge extends PluginTask {
     
        public 
    $main;
        private 
    $time;
     
        public function 
    __construct(Main $main$time null) {
            
    $this->main $main;
            
    $this->time $time;
            
    parent::__construct $main );
        }
     
        public function 
    onRun($t) {
            if (
    $this->time !== null && $this->time 0){
                
    $this->WarningSecs($this->time);
            }
            if (
    $this->time == -1){
                 
    $this->main->getServer()->getScheduler()->scheduleTask(new CyberOn($this->main));
            }
            if (
    $this->time == null){
                
    $this->main->getServer()->broadcastMessage("§4[PURGE]§c WARNING!!!!\n§4[PURGE]§d The Purge gonna start in 1 Minute!\n§4[PURGE]§dPVP WILL ACTIVE ANYWHERE");
                
    $this->main->getServer()->getScheduler()->scheduleDelayedTask(new StartPurge($this->main30) , 20*30);
                
    $this->main->getServer()->getScheduler()->scheduleDelayedTask(new StartPurge($this->main15) , 20*45);
                
    $this->main->getServer()->getScheduler()->scheduleDelayedTask(new StartPurge($this->main10) , 20*50);
                
    $this->main->getServer()->getScheduler()->scheduleDelayedTask(new StartPurge($this->main5) , 20*55);
                
    $this->main->getServer()->getScheduler()->scheduleDelayedTask(new StartPurge($this->main3) , 20*57);
                
    $this->main->getServer()->getScheduler()->scheduleDelayedTask(new StartPurge($this->main2) , 20*58);
                
    $this->main->getServer()->getScheduler()->scheduleDelayedTask(new StartPurge($this->main1) , 20*59);
                
    $this->main->getServer()->getScheduler()->scheduleDelayedTask(new StartPurge($this->main, -1) , 20*60);
            }
        
      
        }
     
        public function 
    WarningSecs($time) {
            
    $this->main->getServer()->broadcastMessage("§4[PURGE]§d ".$time." Secs will start");
        }
     
        public function 
    StartPurge() {
        
        }
     
        public function 
    StopPurge() {
        
        }
        
    //put your code here
    }[/PHP

    Main
    .php

    [PHP]

    namespace 
    MrJamesAndrewMC\Purges;


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

    use 
    pocketmine\event\player\PlayerQuitEvent;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\event\entity\EntityDamageEvent;
    use 
    pocketmine\event\player\PlayerBucketEmptyEvent;
    use 
    pocketmine\event\player\PlayerBucketEvent;
    use 
    pocketmine\event\player\PlayerBucketFillEvent;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\level\Position;
    use 
    MrJamesAndrewMC\Purges\Purge\StartPurge;
    use 
    pocketmine\event\player\PlayerDeathEvent;
    use 
    pocketmine\event\player\PlayerMoveEvent;

    class 
    Main extends PluginBase implements Listener{
     
        public 
    $purge;
     
        private 
    $api;
     
     
     
     
        public function 
    onEnable() {
            @
    mkdir($this->getDataFolder());
        
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        
            
    $this->faction $this->getServer()->getPluginManager()->getPlugin("CyberPurge");
        
            
    $this->getLogger()->info("LOADED");
            
    $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new StartPurge($this), 20 60 220 60 20);

            
    //30 Mins
        
    }
     
        public function 
    onDisable() {
            
    $this->SaveYML();
            
    $this->getLogger()->warning("DISABLED");
        }
     
        public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
        
    $player $this->getServer()->getPlayerExact($sender->getName());
        switch(
    $command->getName()){
                            case 
    "purge":
                                if (
    $this->purge == false){
                                
    $this->getServer()->getScheduler()->scheduleTask(new StartPurge($this));
                                }
                               }}
                        
                        
                        
        public function 
    onMove(PlayerMoveEvent $event){
            if(
    $event->getPlayer() instanceof Player and !$event->getPlayer()->isOp()){
                
    $player $event->getPlayer();                 
                
    $block $event->getPlayer()->getLevel()->getBlock(new Vector3($player->getX(),$player->getY()-1,$player->getZ()));
                if(
    $block->getID() == 0){
                    if(!isset(
    $this->flyers[$player->getName()])) $this->flyers[$player->getName()] = 0;
                    
    $this->flyers[$player->getName()]++;
                    if(
    $this->flyers[$player->getName()] >= 180){ $this->AddTempBan($player->getName(), 15 0);$this->flyers[$player->getName()] = 0;}
                }else{
                    
    $this->flyers[$player->getName()] = 0;
                }
                }
                }
     
     
     
        public function 
    OnPlayerDeath(PlayerDeathEvent $event) {
            
    $this->api->addMoney($event->getEntity()->getName(), "500");
        }
        public function 
    OnBlockBreak(BlockBreakEvent $block) {
            
    $player $block->getPlayer();
            if (
    $player->isOp()){
                return 
    true;
            }else{
                if (
    $this->CheckIfProtechted($player->getX(), $player->getZ(), "edit")){
                    
    $block->setCancelled();
                    return 
    true;
                }else{
                    return 
    true;
                }
            }
        }
     
        public function 
    OnBlockPlace(BlockPlaceEvent $block) {
               
    $player $block->getPlayer();
            if (
    $player->isOp()){
                return 
    true;
            }else{
                if (
    $this->CheckIfProtechted($player->getX(), $player->getZ(), "edit")){
                    
    $block->setCancelled();
                }else{
                    return 
    true;
                }
            }
        }
     
        public function 
    PlayerDamage(EntityDamageEvent $event) {
            if(
    $event->getEntity() instanceof Player){
                
    $player $event->getEntity();
                if (
    $this->CheckIfProtechted($player->getX(), $player->getZ(), "pvp") && $this->purge == false){
                    
    $event->setCancelled();
                }
            }
        }
     
        public function 
    CheckIfProtechted($x,$z,$damage) {
            if (!isset(
    $this->yml['Areas'])){
                return 
    false;
            }
            foreach(
    $this->yml['Areas'] as $a){
                if ((
    min($a['x1'],$a['x2']) <= $x) && (max($a['x1'],$a['x2']) >= $x)){
                    if ((
    min($a['z1'],$a['z2']) <= $z) && (max($a['z1'],$a['z2']) >= $z)){
                        if (
    $a[$damage] == "false"){
                            return 
    TRUE;
                        }else{
                            return 
    false;
                        }
                    }
                }
            }
        }
        }
    Can u guys help me fix this
     
    Last edited: Nov 13, 2016
  2. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    The image isn't quite showing, your code is really hard to be red by the way, I'm not even sure if you can use ; if it's not the end of the line. Second, in your last code block you use
    case "purge";
    but it has to be:
    case "purge":
     
  3. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    actually, you've tons of ";". I would suggest you to use
    ```
    $this->getLogger()->warning("Disabled");
    or
    $this->getServer() = $server;
    ```
    try to use "->" more to allow us to spot easily :)
     
    Last edited: Nov 13, 2016
    MrJamesAndrewMC likes this.
  4. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Is it a bug? > is showing as weird symboles
     
    MrJamesAndrewMC likes this.
  5. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    maybe, hopefully he didnt do it intentionally. Well, mine changed too :(
     
    MrJamesAndrewMC likes this.
  6. MrJamesAndrewMC

    MrJamesAndrewMC Spider Jockey

    Messages:
    36
    oh ok my mistakes☺
     
  7. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    its fine, next time make sure u alter them :)
     
  8. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    the
    Code:
     thingy is kinda messy rn
    can you re post them on pastebin / ghostbin.com
    and re upload the image or crash log on pastebin / ghostbin.com?
     
    MrJamesAndrewMC likes this.
  9. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    if he could that would be much easier for us to interpret & see his codes for flaws...
     
    MrJamesAndrewMC likes this.
  10. MrJamesAndrewMC

    MrJamesAndrewMC Spider Jockey

    Messages:
    36
    Screenshot_2016-11-13-18-53-26.png Screenshot_2016-11-13-18-53-35.png
    should i change the
    pvp=off to pvp=on?? in server.properties??

    Code:
    #Properties Config file
    #Sun Nov 13 18:47:36 CST 2016
    motd=§l§bPlugin Testing
    server-port=19132
    white-list=off
    announce-player-achievements=on
    spawn-protection=10
    max-players=20
    allow-flight=off
    spawn-animals=on
    spawn-mobs=on
    gamemode=0
    force-gamemode=off
    hardcore=off
    pvp=
    difficulty=1
    generator-settings=
    level-name=world
    level-seed=
    level-type=DEFAULT
    enable-query=on
    enable-rcon=off
    rcon.password=
    auto-save=on
    online-mode=off
    
     
  11. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Does your plugin work? Is there a problem with PVP with the plugin in-game?
     
  12. MrJamesAndrewMC

    MrJamesAndrewMC Spider Jockey

    Messages:
    36
    ok thx
     
  13. MrJamesAndrewMC

    MrJamesAndrewMC Spider Jockey

    Messages:
    36
    Yes Screenshot_2016-11-13-17-33-04.png
     
  14. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Ok, I can't see anything wrong at the code, as there's couple issues with this site. Try turning on PVP in server.prop
     
    MrJamesAndrewMC likes this.
  15. MrJamesAndrewMC

    MrJamesAndrewMC Spider Jockey

    Messages:
    36
    my plugin description is:
    if the Purge Start the PvP will Allowed on any Protected area like spawn and then if Purge finish the pvp will disable and back to normal
     
  16. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Ok
     
  17. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Could you provide some screenshots of the place where you write your code? The code doesn't display correctly here. @dktapps, @Intyre, @SOFe, or someone else might want to look at this. (and try to fix it if possible) Or just share the code in a different way so we can properly look through the code.
     
  18. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Exactly! His plugin started without Syntax error. I guess it's fine as his not back yet
     
  19. MrJamesAndrewMC

    MrJamesAndrewMC Spider Jockey

    Messages:
    36
     
  20. MrJamesAndrewMC

    MrJamesAndrewMC Spider Jockey

    Messages:
    36
    DM me ill send u the code
     

Share This Page

  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.