Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Commit

Permalink
Release v1.0.0-Beta1
Browse files Browse the repository at this point in the history
  • Loading branch information
JaxkDev committed Apr 13, 2019
1 parent 43a17e1 commit 18d2a08
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 29 deletions.
8 changes: 8 additions & 0 deletions .poggit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--- # Poggit-CI Manifest. Open the CI at https://poggit.pmmp.io/ci/jackthehack21/JukeBox-pmmp
branches:
- master
projects:
KOTH:
path: ""
icon: "icon.png"
...
53 changes: 52 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,53 @@
# K.O.T.H
King Of The Hill, Pocketmine-MP Plugin.
King Of The Hill mini-game, Pocketmine-MP Plugin by Jackthehack21.

## NOTICE:
**This plugin is in BETA, so please dont spam out comments/issues with broken things or things that you expect there and are not.**


### Features:
- Multiple Arena's
- Custom spawn & hill points.
- Supports Arena's in different worlds.
- Custom player amount, and game time.
- Block break/place disabled during in-game (todo config)
- Changing gamemode during a game is cancelled (todo config)

### Soon to come:
- 'King' to display under/above player name.
- Messages to be in config.
- Default arena values to be in config.
- Override old values of arena positions.
- Something extra for when winner is announced ***wink***

### Known Bugs:
- NA

To report bugs please make a issue over on [github](https://github.com/jackthehack21/koth/issues/new) and please follow the guidelines.

### Credits:
_Developer:_ Jackthehack21 (aka JaxkDev)

*Idea generator:* GOLDVAGE (GOLDVAGE#2712)


### License:
KOTH - King of the hill
Copyright (C) 2019 Jackthehack21 (Jack Honour/Jackthehaxk21/JaxkDev)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

Twitter :: @JaxkDev
Discord :: Jackthehaxk21#8860
Email :: [email protected]
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: KOTH
author: Jackthehaxk21
author: Jackthehack21
version: 1.0.0-Beta1
api:
- 3.7.0
Expand Down
12 changes: 5 additions & 7 deletions src/Jack/KOTH/Arena.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function broadcastMessage(string $msg) : void{

public function broadcastWinner(string $player) : void{
//todo get config.
$this->broadcastMessage($this->plugin->prefix.$player."Has won the game !");
$this->broadcastMessage($this->plugin->prefix.$player." Has won the game !");
}

public function broadcastQuit(Player $player, string $reason) : void{
Expand Down Expand Up @@ -164,7 +164,7 @@ public function spawnPlayer(Player $player, $random = false) : void{
if(!$this->plugin->getServer()->isLevelGenerated($this->world)) {
//todo config msg.
//world does not exist
$player->sendMessage("This arena is corrupt.");
$player->sendMessage($this->plugin->prefix.C::RED."This arena is corrupt.");
return;
}
if(!$this->plugin->getServer()->isLevelLoaded($this->world)) {
Expand Down Expand Up @@ -204,10 +204,8 @@ public function startGame() : void{
$this->timerTask->cancel();
$this->started = true;
$this->checkStatus();
$this->broadcastMessage("Game started");
$this->timerTask = $this->plugin->getScheduler()->scheduleRepeatingTask(new Gametimer($this->plugin, $this),20);
//start next timer task.
//broadcast the games started, start task to keep track of king.
$this->broadcastMessage($this->plugin->prefix.C::GOLD."Game On !");
$this->timerTask = $this->plugin->getScheduler()->scheduleRepeatingTask(new Gametimer($this->plugin, $this),10);
}

public function reset() : void{
Expand Down Expand Up @@ -272,7 +270,7 @@ public function playersInBox() : array{

foreach($this->players as $playerName){
$player = $this->plugin->getServer()->getPlayerExact($playerName);
if(($minX <= $player->getFloorX() && $player->getFloorX() <= $maxX && $minZ <= $player->getFloorZ() && $player->getFloorZ() <= $maxZ)){
if(($minX <= $player->x && $player->x <= $maxX && $minZ <= $player->z && $player->z <= $maxZ)){
$list[] = $playerName;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Jack/KOTH/CommandHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function handleCommand(CommandSender $sender, Command $cmd, string $label
return true;
}
$pos = $sender->getPosition();
$point = [$pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ()]; //get first to avoid split second movement *shrug*
$point = [$pos->x, $pos->y, $pos->z]; //get first to avoid split second movement *shrug*
if(count($args) !== 2){
$sender->sendMessage($this->prefix.C::RED."No arena specified, /koth setpos1 (arenaName)");
return true;
Expand All @@ -177,7 +177,7 @@ public function handleCommand(CommandSender $sender, Command $cmd, string $label
return true;
}
$pos = $sender->getPosition();
$point = [$pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ()]; //get first to avoid split second movement *shrug*
$point = [$pos->x, $pos->y, $pos->z]; //get first to avoid split second movement *shrug*
if(count($args) !== 2){
$sender->sendMessage($this->prefix.C::RED."No arena specified, /koth setpos2 (arenaName)");
return true;
Expand Down Expand Up @@ -208,7 +208,7 @@ public function handleCommand(CommandSender $sender, Command $cmd, string $label
return true;
}
$pos = $sender->getPosition();
$point = [$pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ()]; //get first to avoid split second movement *shrug*
$point = [$pos->x, $pos->y, $pos->z]; //get first to avoid split second movement *shrug*
if(count($args) !== 2){
$sender->sendMessage($this->prefix.C::RED."No arena specified, /koth setspawn (arenaName)");
return true;
Expand Down
25 changes: 14 additions & 11 deletions src/Jack/KOTH/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class Main extends PluginBase implements Listener{
private $arenas;
private $CommandHandler;
private $EventHandler;
private $configC;
//private $configC;
private $arenaC;
private $arenaSaves;

public $config;
//public $config;
public $prefix;

private function init() : void{
Expand All @@ -66,31 +66,34 @@ private function init() : void{
}

private function initResources() : void{
$this->saveResource("config.yml");
/*$this->saveResource("config.yml");
$this->configC = new Config($this->getDataFolder() . "config.yml", Config::YAML);
$this->config = $this->configC->getAll();
$this->config = $this->configC->getAll();*/
$this->arenaC = new Config($this->getDataFolder() . "arena.yml", Config::YAML, ["version" => 1, "arena_list" => []]);
$this->arenaSaves = $this->arenaC->getAll();
$this->arenaSaves = $this->arenaC->getAll();
}

private function loadArenas() : void{
if(count($this->arenaSaves["arena_list"]) === 0) return;
if(count($this->arenaSaves["arena_list"]) === 0){
$this->getLogger()->debug("0 Arena(s) loaded.");
return;
}
foreach($this->arenaSaves["arena_list"] as $arenaC){
$arena = new Arena($this, $arenaC["name"], $arenaC["min_players"], $arenaC["max_players"], $arenaC["play_time"], $arenaC["start_countdown"], $arenaC["hill"], $arenaC["spawns"], $arenaC["world"]);
$this->arenas[] = $arena;
}
$this->getLogger()->debug(count($this->arenas)." Arena(s) loaded.");
}

public function onDisable()
{
$this->saveArena();
$this->saveConfig();
//$this->saveConfig();
}

public function onEnable() : void{
$this->initResources(); //first to enable Debug.
$this->init();
$this->getLogger()->info(C::GREEN."Plugin Enabled.");
}

public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args): bool{
Expand All @@ -116,19 +119,19 @@ public function saveArena(array $data = null) : void{
"world" => $arena->world
];
}
$this->getLogger()->debug("Saving Arena data.");
//$this->getLogger()->debug("Saving Arena data.");
$this->arenaC->set("arena_list", $save);
$this->arenaC->save(); //<-- took a hour to figure out why it wasn't saving :/
}

public function saveConfig(array $data = null) : void{
/*public function saveConfig(array $data = null) : void{
if($data !== null){
$this->configC->setAll($data);
return;
}
$this->configC->setAll($this->config);
$this->configC->save(); //<-- took a hour to figure out why it wasn't saving :/
}
}*/

public function inGame(string $name) : bool{
return $this->getArenaByPlayer($name) !== null;
Expand Down
5 changes: 1 addition & 4 deletions src/Jack/KOTH/Tasks/Gametimer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class Gametimer extends Task{
private $arena;

public $secondsPlayed = 0;
public $startTick = 0;


public function __construct(Main $plugin, Arena $arena){
Expand All @@ -52,8 +51,7 @@ public function __construct(Main $plugin, Arena $arena){
}

public function onRun(int $tick){
if($this->startTick === 0) $this->startTick = $tick;
$this->secondsPlayed = floor(($tick-$this->startTick)/20);
$this->secondsPlayed += 0.5;
$inBox = $this->arena->playersInBox();
if($this->arena->king === null){
$this->arena->checkNewKing();
Expand All @@ -66,7 +64,6 @@ public function onRun(int $tick){

if($this->secondsPlayed >= $this->arena->time){
$this->arena->endGame();
//task then cancelled.
}
}
}
4 changes: 2 additions & 2 deletions src/Jack/KOTH/Tasks/Prestart.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
namespace Jack\KOTH\Tasks;

use pocketmine\scheduler\Task;
use pocketmine\utils\TextFormat as C;

use Jack\KOTH\Main;
use Jack\KOTH\Arena;
Expand All @@ -53,9 +54,8 @@ public function onRun(int $tick){
if($this->countDown === 0){
$this->arena->startGame();
return;
//task should be cancelled before next 20ticks.
}
$this->arena->broadcastMessage($this->plugin->prefix.$this->countDown." Seconds...");
$this->arena->broadcastMessage($this->plugin->prefix.C::RED."[COUNTDOWN] : ".$this->countDown);
$this->countDown--;
}
}

0 comments on commit 18d2a08

Please sign in to comment.