Skip to content

Commit

Permalink
Big update !
Browse files Browse the repository at this point in the history
- Updating headers,
- Adding first setting, deleteBiomes, wiki comming soon
  • Loading branch information
Ad5001 committed May 10, 2017
1 parent acd3273 commit b73d3c9
Show file tree
Hide file tree
Showing 37 changed files with 534 additions and 275 deletions.
20 changes: 17 additions & 3 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
---
# Base generated with ImagicalPlugCreator by Ad5001 (C) 2017 for Ad5001
# link: https://ad5001.eu
# ____ __ __ ____
# /\ _`\ /\ \__ /\ \__ /\ _`\
# \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
# \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
# \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
# \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
# \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
# Tommorow's pocketmine generator.
# @author Ad5001
# @link https://github.com/Ad5001/BetterGen
name: BetterGen
author: Ad5001
main: Ad5001\BetterGen\Main
version: 1.0
version: 1.1
api: [3.0.1, 3.0.0-ALPHA3]
commands:
createworld:
description: Generates a new world.
usage: "/createworld <name> [generator = betternormal] [seed = rand()] [options (json)]"
permission: bettergen.cmd.createworld
worldtp:
description: Teleports you to an another world
usage: "/worldtp <world name>"
permission: bettergen.cmd.worldtp
permissions:
bettergen.cmd.createworld:
default: op
bettergen.cmd.worldtp:
default: op
...
31 changes: 19 additions & 12 deletions src/Ad5001/BetterGen/Main.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<?php

/*
* Main from BetterGen
* Copyright(C) Ad5001 2017
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory
* @author ad5001
/**
* ____ __ __ ____
* /\ _`\ /\ \__ /\ \__ /\ _`\
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/

namespace Ad5001\BetterGen;
Expand Down Expand Up @@ -112,6 +117,7 @@ public function onCommand(\pocketmine\command\CommandSender $sender, \pocketmine
return true;
}
$generatorName = strtolower($args [1]);
if($args[2] == "rand") $args[2] = $this->generateRandomSeed();
if(preg_match("[^\d]", $args [2]) !== false) {
$parts = str_split($args [2]);
foreach($parts as $key => $str) {
Expand All @@ -123,12 +129,17 @@ public function onCommand(\pocketmine\command\CommandSender $sender, \pocketmine
}
unset($args [0], $args [1], $args [2]);
$options = json_decode($args [3], true);
if(! is_array($json)) {
if(! is_array($options)) {
$sender->sendMessage(Main::PREFIX . "§4Invalid JSON for options.");
return true;
}
break;
}
$options["preset"] = json_encode($options);
if((int) $seed == 0/*String*/){
$seed = $this->generateRandomSeed();
echo "Rechoosen seed";
}
$this->getServer()->broadcastMessage(Main::PREFIX . "§aGenerating level $name with generator $generatorName and seed $seed..");
$this->getServer()->generateLevel($name, $seed, $generator, $options);
$this->getServer()->loadLevel($name);
Expand Down Expand Up @@ -161,10 +172,6 @@ public function registerForest(string $name, string $treeClass, array $infos): b
* @return void
*/
public static function registerBiome(int $id, Biome $biome) {
$reflection = new \ReflectionClass('pocketmine\\level\\generator\\biome\\Biome');
$register = $reflection->getMethod('register');
$register->setAccessible(true);
$register->invoke(null, $id, $biome);
BetterNormal::registerBiome($biome);
}

Expand All @@ -173,7 +180,7 @@ public static function registerBiome(int $id, Biome $biome) {
* @return int
*/
public function generateRandomSeed(): int {
return(int) round(time() * rand(0, time()) / memory_get_usage());
return (int) round(rand(0, round(time()) / memory_get_usage(true)) * (int) str_shuffle("127469453645108") / (int) str_shuffle("12746945364"));
}

// Listener
Expand Down
19 changes: 12 additions & 7 deletions src/Ad5001/BetterGen/biome/BetterDesert.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<?php

/*
* BetterDesert from BetterGen
* Copyright (C) Ad5001 2017
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory
* @author ad5001
/**
* ____ __ __ ____
* /\ _`\ /\ \__ /\ \__ /\ _`\
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/
namespace Ad5001\BetterGen\biome;

Expand Down Expand Up @@ -67,7 +72,7 @@ public function __construct() {
]);
}
public function getName(): string {
return "Better Desert";
return "BetterDesert";
}

/*
Expand Down
19 changes: 13 additions & 6 deletions src/Ad5001/BetterGen/biome/BetterForest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
<?php

/*
* BetterForest from BetterGen
* Copyright (C) Ad5001 2017
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory
* @author ad5001
/**
* ____ __ __ ____
* /\ _`\ /\ \__ /\ \__ /\ _`\
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/

namespace Ad5001\BetterGen\biome;

use pocketmine\level\generator\normal\biome\ForestBiome;
Expand Down Expand Up @@ -49,7 +56,7 @@ public function __construct($type = 0, array $infos = [0.6, 0.5]) {
$this->rainfall = $infos [1];
}
public function getName() {
return self::$types [$this->type];
return str_ireplace(" ", "", self::$types[$this->type]);
}

/*
Expand Down
19 changes: 12 additions & 7 deletions src/Ad5001/BetterGen/biome/BetterIcePlains.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<?php

/*
* BetterIcePlains from BetterGen
* Copyright (C) Ad5001 2017
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory
* @author ad5001
/**
* ____ __ __ ____
* /\ _`\ /\ \__ /\ \__ /\ _`\
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/

namespace Ad5001\BetterGen\biome;
Expand Down Expand Up @@ -38,7 +43,7 @@ public function __construct() {
$this->rainfall = 0.8;
}
public function getName() {
return "Better Ice Plains";
return "BetterIcePlains";
}

/*
Expand Down
19 changes: 12 additions & 7 deletions src/Ad5001/BetterGen/biome/BetterMesa.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<?php

/*
* BetterMesa from BetterGen
* Copyright (C) Ad5001 2017
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory
* @author ad5001
/**
* ____ __ __ ____
* /\ _`\ /\ \__ /\ \__ /\ _`\
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/

namespace Ad5001\BetterGen\biome;
Expand Down Expand Up @@ -102,7 +107,7 @@ public function __construct() {
]);
}
public function getName(): string {
return "Better Mesa";
return "BetterMesa";
}

/*
Expand Down
20 changes: 13 additions & 7 deletions src/Ad5001/BetterGen/biome/BetterMesaPlains.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?php

/*
* BetterMesaPlains from BetterGen
* Copyright (C) Ad5001 2017
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory
* @author ad5001
/**
* ____ __ __ ____
* /\ _`\ /\ \__ /\ \__ /\ _`\
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/

namespace Ad5001\BetterGen\biome;

use pocketmine\level\generator\normal\biome\SandyBiome;
Expand Down Expand Up @@ -96,7 +102,7 @@ public function __construct() {
]);
}
public function getName(): string {
return "Better Mesa Plains";
return "BetterMesaPlains";
}

/*
Expand Down
19 changes: 12 additions & 7 deletions src/Ad5001/BetterGen/biome/BetterRiver.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<?php

/*
* BetterRiver from BetterGen
* Copyright (C) Ad5001 2017
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory
* @author ad5001
/**
* ____ __ __ ____
* /\ _`\ /\ \__ /\ \__ /\ _`\
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/

namespace Ad5001\BetterGen\biome;
Expand Down Expand Up @@ -36,7 +41,7 @@ public function __construct() {
$this->rainfall = 0.7;
}
public function getName() {
return "Better River";
return "BetterRiver";
}

/*
Expand Down
17 changes: 11 additions & 6 deletions src/Ad5001/BetterGen/biome/Mountainable.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<?php

/*
* Mountainable from BetterGen
* Copyright (C) Ad5001 2017
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory
* @author ad5001
/**
* ____ __ __ ____
* /\ _`\ /\ \__ /\ \__ /\ _`\
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/

namespace Ad5001\BetterGen\biome;
Expand Down
20 changes: 12 additions & 8 deletions src/Ad5001/BetterGen/generator/BetterBiomeSelector.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<?php

/*
* BetterBiomeSelector from BetterGen
* Copyright (C) Ad5001 2017
* Licensed under the BoxOfDevs Public General LICENSE which can be found in the file LICENSE in the root directory
* @author ad5001
*/
/**
* ____ __ __ ____
* /\ _`\ /\ \__ /\ \__ /\ _`\
* \ \ \L\ \ __ \ \ ,_\\ \ ,_\ __ _ __ \ \ \L\_\ __ ___
* \ \ _ <' /'__`\\ \ \/ \ \ \/ /'__`\/\`'__\\ \ \L_L /'__`\ /' _ `\
* \ \ \L\ \/\ __/ \ \ \_ \ \ \_ /\ __/\ \ \/ \ \ \/, \/\ __/ /\ \/\ \
* \ \____/\ \____\ \ \__\ \ \__\\ \____\\ \_\ \ \____/\ \____\\ \_\ \_\
* \/___/ \/____/ \/__/ \/__/ \/____/ \/_/ \/___/ \/____/ \/_/\/_/
* Tommorow's pocketmine generator.
* @author Ad5001
* @link https://github.com/Ad5001/BetterGen
*/
namespace Ad5001\BetterGen\generator;

use pocketmine\level\generator\biome\BiomeSelector;
Expand Down Expand Up @@ -59,7 +64,6 @@ public function pickBiome($x, $z) {
$rainfall = ($this->getRainfall($x, $z ));

$biomeId = BetterNormal::getBiome($temperature, $rainfall);
// $biomeId = new \Ad5001\BetterGen\biome\BetterDesert();
$b = (($biomeId instanceof Biome) ? $biomeId : ($this->biomes [$biomeId] ?? $this->fallback));
return $b;
}
Expand Down
Loading

0 comments on commit b73d3c9

Please sign in to comment.