Adding plugin
This commit is contained in:
commit
fb1da2b8b0
8 changed files with 796 additions and 0 deletions
2
.vscode/settings.json
vendored
Normal file
2
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
{
|
||||||
|
}
|
113
LICENSE.md
Normal file
113
LICENSE.md
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
Not Truly Open Source License
|
||||||
|
=========================================
|
||||||
|
This license is an adaption of the Creative Commons Licenses for softwares.
|
||||||
|
Any user using and, or Distributing the Software (defined in I) exerces the Licensed Rights.
|
||||||
|
By exercising the Licenced Rights (defined below), You accept and agree to be bound by the terms and conditions of this Not Truly Open Source ("NTOS License"). To the extent the NTOS License may be interpreted as a contract, You are granted the Licenced Rights in consideration of Your acceptance of these terms and conditions, and the Author grants You such rights in consideration of benefits the Author receives from making the Software available under these terms and conditions.
|
||||||
|
|
||||||
|
I. Definitions:
|
||||||
|
- "NTOS License" refers to the legal terms of this license, described here.
|
||||||
|
- "Licensed Rights" refers the rights granted to You subject to the terms and conditions of the NTOS License, which are limited to all Copyright and Similar Rights that apply to Your use of the Software and that the Author has authority to license.
|
||||||
|
- "The Software" refers to any work, code and software binaries licensed under the NTOS License.
|
||||||
|
- "The Author" refers the orginal author of the Software, the one that licenced the Software under the NTOS License.
|
||||||
|
- "the User", "User", "You", and "Your" refers the individual or entity exercising the Licenced Rights under the NTOS License.
|
||||||
|
- "the Modification" refers to based of the Software.
|
||||||
|
- "the Modification's Author" refers to an User that Distributes the Modificaction including more than 10% of the Software's code.
|
||||||
|
- "Code" refers to any part of the code located in the Software.
|
||||||
|
- "the Based Software" refers to work other than the Software using the Code. The used Code must not be larger than 10% of the code of the Software. Otherwise, the work is a Modification.
|
||||||
|
- "the Based Software's Author" refers to an User that created the
|
||||||
|
- "The End User" refers to the individual person accessing and, or using the Software. The End User may be or not the same as the User.
|
||||||
|
- "Exceptions and Limitations" refers to the fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Software.
|
||||||
|
- "Copyright and Similar Rights" refers to the copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the Licenced Rights are labeled or categorized. For purposes of the NTOS License, the Licenced Rights specified in II(2)(a)-(b) are not Copyright and Similar Rights.
|
||||||
|
- "Distribute" refers to any way of providing The End User an access to the Software either by a downloading Platform or from any internet connected process allowing the user to access the Software content.
|
||||||
|
- "NonCommercial" means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of the NTOS License, the exchange of the Software for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
|
||||||
|
- "Sui Generis Database Rights" refers to the Licenced Rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
|
||||||
|
|
||||||
|
Section II. Scope.
|
||||||
|
|
||||||
|
1. License grant.
|
||||||
|
a. Subject to the terms and conditions of the NTOS License, the Author hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licenced Rights in the Software to:
|
||||||
|
A. reproduce and Distribute the Software, in whole or in part, for NonCommercial purposes only; and
|
||||||
|
B. produce, reproduce, and Distribute Modification for NonCommercial purposes only.
|
||||||
|
b. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, the NTOS License does not apply, and You do not need to comply with its terms and conditions.
|
||||||
|
c. Term. The term of the NTOS License is specified in Section VI(1).
|
||||||
|
d. Downstream recipients.
|
||||||
|
Offer from the Author – Software. Every recipient of the Software automatically receives an offer from the Author to exercise the Licenced Rights under the terms and conditions of the NTOS License.
|
||||||
|
Additional offer from the Author – Modification. Every recipient of Modification from You automatically receives an offer from the Author to exercise the Licenced Rights in the Modification under the conditions of the the Modification's Author's License You apply.
|
||||||
|
No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Software if doing so restricts exercise of the Licenced Rights by any recipient of the Software.
|
||||||
|
e. No endorsement. Nothing in the NTOS License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Software is, connected with, or sponsored, endorsed, or granted official status by, the Author or others designated to receive attribution as provided in Section III(1)(a)(A)(i).
|
||||||
|
2. Other rights.
|
||||||
|
a. Moral rights, such as the right of integrity, are not licensed under the NTOS License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Author waives and/or agrees not to assert any such rights held by the Author to the limited extent necessary to allow You to exercise the Licenced Rights, but not otherwise.
|
||||||
|
b. Patent and trademark rights are not licensed under the NTOS License.
|
||||||
|
c. To the extent possible, the Author waives any right to collect royalties from You for the exercise of the Licenced Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Author expressly reserves any right to collect such royalties, including when the Software is used other than for NonCommercial purposes.
|
||||||
|
|
||||||
|
Section III. License Conditions.
|
||||||
|
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
|
||||||
|
|
||||||
|
1. Attribution.
|
||||||
|
a. If You Distribute the Software (including in modified, or based form), You must:
|
||||||
|
A. retain the following if it is supplied by the Author with the Software:
|
||||||
|
i. identification of the creator(s) of the Software and any others designated to receive attribution, in any reasonable manner requested by the Author (including by pseudonym if designated);
|
||||||
|
ii. a copyright notice;
|
||||||
|
iii. a notice that refers to the NTOS License;
|
||||||
|
iv. a notice that refers to the disclaimer of warranties;
|
||||||
|
v. a URI or hyperlink to the Software to the extent reasonably practicable;
|
||||||
|
indicate if You modified the Software and retain an indication of any previous modifications; and
|
||||||
|
indicate the Software is licensed under the NTOS License, and include the text of, or the URI or hyperlink to, the NTOS License.
|
||||||
|
b. You may satisfy the conditions in Section III(1)(a) in any reasonable manner based on the medium, means, and context in which You Distribute the Software. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
|
||||||
|
c. If requested by the Author, You must remove any of the information required by Section III(1)(a)(A) to the extent reasonably practicable.
|
||||||
|
|
||||||
|
2. Distribute ALike
|
||||||
|
In addition to the conditions in Section III(1), if You Distribute the Modification You produce, the following conditions also apply.
|
||||||
|
A. The Modification Author's License You apply must be the NTOS License
|
||||||
|
B. You must include the text of, or the URI or hyperlink to, the Modification's Author's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Distribute the Modification.
|
||||||
|
C. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Modification that restrict exercise of the rights granted under the Modification's Author's License You apply.
|
||||||
|
D. You may not apply any fee to access the Modification
|
||||||
|
|
||||||
|
3. Distribution of code
|
||||||
|
In addition to the conditions in Section III(1), if You Distribute a Based Software, the following conditions also apply:
|
||||||
|
A. You must include the text of, or the URI or hyperlink to, refering to this License. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Distribute the Based Software.
|
||||||
|
B. You must also include Section III(1)(a)(A)(ii-v) in the the Based Software Code.
|
||||||
|
|
||||||
|
Section IV. Sui Generis Database Rights.
|
||||||
|
|
||||||
|
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Software:
|
||||||
|
|
||||||
|
for the avoidance of doubt, Section II(1)(a) grants You the right to extract, reuse, reproduce, and Dstribute all or a substantial portion of the contents of the database for NonCommercial purposes only;
|
||||||
|
if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is the Modification, including for purposes of Section III(2); and
|
||||||
|
You must comply with the conditions in Section III(1) if You Distribute all or a substantial portion of the contents of the database.
|
||||||
|
|
||||||
|
For the avoidance of doubt, this Section IV supplements and does not replace Your obligations under the NTOS License where the Licensed Rights include other Copyright and Similar Rights.
|
||||||
|
|
||||||
|
|
||||||
|
Section V – Disclaimer of Warranties and Limitation of Liability.
|
||||||
|
|
||||||
|
1. Unless otherwise separately undertaken by the Author, to the extent possible, the Author offers the Software as-is and as-available, and makes no representations or warranties of any kind concerning the Software, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
|
||||||
|
2. To the extent possible, in no event will the Author be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of the NTOS License or use of the Software, even if the Author has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
|
||||||
|
|
||||||
|
3. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
|
||||||
|
|
||||||
|
|
||||||
|
Section VI – Term and Termination.
|
||||||
|
|
||||||
|
The NTOS License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with the NTOS License, then Your rights under the NTOS License terminate automatically.
|
||||||
|
|
||||||
|
Where Your right to use the Software has terminated under Section 6(a), it reinstates:
|
||||||
|
automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
|
||||||
|
upon express reinstatement by the Author.
|
||||||
|
For the avoidance of doubt, this Section 6(b) does not affect any right the Author may have to seek remedies for Your violations of the NTOS License.
|
||||||
|
For the avoidance of doubt, the Author may also offer the Software under separate terms or conditions or stop distributing the Software at any time; however, doing so will not terminate the NTOS License.
|
||||||
|
Sections I, V, VI, VII, and VI survive termination of the NTOS License.
|
||||||
|
|
||||||
|
Section VII – Other Terms and Conditions.
|
||||||
|
|
||||||
|
The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
|
||||||
|
Any arrangements, understandings, or agreements regarding the Software not stated herein are separate from and independent of the terms and conditions of the NTOS License.
|
||||||
|
|
||||||
|
Section VIII – Interpretation.
|
||||||
|
|
||||||
|
For the avoidance of doubt, the NTOS License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Software that could lawfully be made without permission under the NTOS License.
|
||||||
|
To the extent possible, if any provision of the NTOS License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from the NTOS License without affecting the enforceability of the remaining terms and conditions.
|
||||||
|
No term or condition of the NTOS License will be waived and no failure to comply consented to unless expressly agreed to by the Author.
|
||||||
|
Nothing in the NTOS License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Author or You, including from the legal processes of any jurisdiction or authority.
|
||||||
|
|
||||||
|
In case of a specific issue not specified in the NTOSL, Berne Convention for the Protection of Literary and Artistic Works, which reserves all rights to the Author applies. You can find Berne Convention for the Protection of Literary and Artistic Works at http://www.wipo.int/treaties/en/text.jsp?file_id=283698.
|
7
README.md
Normal file
7
README.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# Spherable
|
||||||
|
A spheres world generator. A new survival challenge.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Discove the new challenge of Spherable, a new challenge for every player around the world.
|
||||||
|
<img src="https://github.com/Ad5001/Spherable/blob/master/brand.png">
|
BIN
brand.png
Normal file
BIN
brand.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 MiB |
31
plugin.yml
Normal file
31
plugin.yml
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
---
|
||||||
|
# ____ _ _ _
|
||||||
|
# / ___| _ __ | |__ ___ _ __ __ _ | |__ | | ___
|
||||||
|
# \___ \ | '_ \ | '_ \ / _ \| '__|/ _` || '_ \ | | / _ \
|
||||||
|
# ___) || |_) || | | || __/| | | (_| || |_) || || __/
|
||||||
|
# |____/ | .__/ |_| |_| \___||_| \__,_||_.__/ |_| \___|
|
||||||
|
# |_|
|
||||||
|
#
|
||||||
|
# Spheres world generator. A new survival challenge.
|
||||||
|
# @author Ad5001 <mail@ad5001.eu>
|
||||||
|
# @copyright (C) 2017 Ad5001
|
||||||
|
# @license NTOSL (View LICENSE.md)
|
||||||
|
# @package Spherical
|
||||||
|
# @version 1.0.0
|
||||||
|
# @link https://download.ad5001.eu/en/view.php?name=Spherable&src=github
|
||||||
|
name: Spherable
|
||||||
|
description: A spheres world generator. A new survival challenge.
|
||||||
|
author: Ad5001
|
||||||
|
version: 1.0
|
||||||
|
api: [3.0.0-ALPHA7]
|
||||||
|
main: Ad5001\Spherable\Main
|
||||||
|
website: "https://download.ad5001.eu/en/view.php?name=Spherable&src=github"
|
||||||
|
psmimplements: true
|
||||||
|
permissions:
|
||||||
|
spherable.cmd.createworld:
|
||||||
|
default: op
|
||||||
|
spherable.cmd.tp:
|
||||||
|
default: op
|
||||||
|
spherable.cmd.join:
|
||||||
|
default: true
|
||||||
|
...
|
110
src/Ad5001/Spherable/Main.php
Normal file
110
src/Ad5001/Spherable/Main.php
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/***
|
||||||
|
* ____ _ _ _
|
||||||
|
* / ___| _ __ | |__ ___ _ __ __ _ | |__ | | ___
|
||||||
|
* \___ \ | '_ \ | '_ \ / _ \| '__|/ _` || '_ \ | | / _ \
|
||||||
|
* ___) || |_) || | | || __/| | | (_| || |_) || || __/
|
||||||
|
* |____/ | .__/ |_| |_| \___||_| \__,_||_.__/ |_| \___|
|
||||||
|
* |_|
|
||||||
|
*
|
||||||
|
* Spheres world generator. A new survival challenge.
|
||||||
|
* @author Ad5001 <mail@ad5001.eu>
|
||||||
|
* @copyright (C) 2017 Ad5001
|
||||||
|
* @license NTOSL (View LICENSE.md)
|
||||||
|
* @package Spherical
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://download.ad5001.eu/en/view.php?name=Spherable&src=github
|
||||||
|
*/
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace Ad5001\Spherable;
|
||||||
|
|
||||||
|
use pocketmine\command\CommandSender;
|
||||||
|
use pocketmine\command\Command;
|
||||||
|
use pocketmine\event\Listener;
|
||||||
|
use pocketmine\plugin\PluginBase;
|
||||||
|
use pocketmine\level\generator\Generator;
|
||||||
|
use pocketmine\Server;
|
||||||
|
use pocketmine\Player;
|
||||||
|
use pocketmine\level\Position;
|
||||||
|
use pocketmine\entity\Effect;
|
||||||
|
|
||||||
|
use Ad5001\Spherable\generators\spheres\SpheresGenerator;
|
||||||
|
use Ad5001\Spherable\commands\sphgenCommand;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Main extends PluginBase implements Listener{
|
||||||
|
|
||||||
|
public $playersResist = [];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the plugin enables
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function onEnable(){
|
||||||
|
Generator::addGenerator(SpheresGenerator::class, "spheres");
|
||||||
|
$this->getServer()->getCommandMap()->register("sphgen", new sphgenCommand($this));
|
||||||
|
$this->getServer()->getPluginManager()->registerEvents($this, $this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public function onEntityLevelChange(\pocketmine\event\entity\EntityLevelChangeEvent $event){
|
||||||
|
if($event->getTarget()->getProvider()->getGenerator() == "spheres" && $event->getEntity() instanceof Player){
|
||||||
|
$event->getEntity()->setSpawn(new Position(264, 255, 264, $event->getTarget()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public function onRespawn(\pocketmine\event\player\PlayerRespawnEvent $event){
|
||||||
|
if($event->getPlayer()->getLevel()->getProvider()->getGenerator() == "spheres"){
|
||||||
|
$this->playersResist[$event->getPlayer()->getName()] = time();
|
||||||
|
$event->getPlayer()->sendMessage("You are resistant for 30 seconds. Profit to go back to your last death point.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public function onEntityDamage(\pocketmine\event\entity\EntityDamageEvent $event){
|
||||||
|
if($event->getEntity()->getLevel()->getProvider()->getGenerator() == "spheres" &&
|
||||||
|
$event->getEntity() instanceof Player &&
|
||||||
|
isset($this->playersResist[$event->getEntity()->getName()]) &&
|
||||||
|
$this->playersResist[$event->getEntity()->getName()] > time() - 30){
|
||||||
|
$event->setCancelled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public function onBlockBreak(\pocketmine\event\block\BlockBreakEvent $event){
|
||||||
|
if($event->getBlock()->getLevel()->getProvider()->getGenerator() == "spheres"){
|
||||||
|
if($event->getBlock()->getId() == 56){
|
||||||
|
$diamonds_count = 1;
|
||||||
|
foreach($event->getPlayer()->getInventory()->getContents() as $item){
|
||||||
|
$diamonds_count += $item->getCount();
|
||||||
|
}
|
||||||
|
if($diamonds_count % 64 == 0 && $this->getServer()->getPluginManager()->getPlugin("PSMCore") !== null){
|
||||||
|
\Ad5001\PSMCore\API::displayNotification("Diamonds !", $event->getPlayer()->getName() . " has mined " . ($diamonds_count / 64) . " stacks of diamond!", [], "none");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public function onJoin(\pocketmine\event\player\PlayerJoinEvent $event){
|
||||||
|
if($event->getPlayer()->getLevel()->getProvider()->getGenerator() == "spheres"){
|
||||||
|
$event->getPlayer()->setSpawn(new Position(264, 255, 264, $event->getPlayer()->getLevel()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
170
src/Ad5001/Spherable/commands/sphgenCommand.php
Normal file
170
src/Ad5001/Spherable/commands/sphgenCommand.php
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
<?php
|
||||||
|
/***
|
||||||
|
* ____ _ _ _
|
||||||
|
* / ___| _ __ | |__ ___ _ __ __ _ | |__ | | ___
|
||||||
|
* \___ \ | '_ \ | '_ \ / _ \| '__|/ _` || '_ \ | | / _ \
|
||||||
|
* ___) || |_) || | | || __/| | | (_| || |_) || || __/
|
||||||
|
* |____/ | .__/ |_| |_| \___||_| \__,_||_.__/ |_| \___|
|
||||||
|
* |_|
|
||||||
|
*
|
||||||
|
* Spheres world generator. A new survival challenge.
|
||||||
|
* @author Ad5001 <mail@ad5001.eu>
|
||||||
|
* @copyright (C) 2017 Ad5001
|
||||||
|
* @license NTOSL (View LICENSE.md)
|
||||||
|
* @package Spherical
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://download.ad5001.eu/en/view.php?name=Spherable&src=github
|
||||||
|
*/
|
||||||
|
declare(strict_types = 1);
|
||||||
|
namespace Ad5001\Spherable\commands;
|
||||||
|
|
||||||
|
use pocketmine\Server;
|
||||||
|
use pocketmine\Player;
|
||||||
|
use pocketmine\command\Command;
|
||||||
|
use pocketmine\command\CommandSender;
|
||||||
|
use pocketmine\level\Position;
|
||||||
|
use pocketmine\block\Block;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\entity\Effect;
|
||||||
|
|
||||||
|
use Ad5001\Spherable\Main;
|
||||||
|
use Ad5001\Spherable\generators\spheres\SpheresGenerator;
|
||||||
|
|
||||||
|
class sphgenCommand extends Command{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs the class
|
||||||
|
*
|
||||||
|
* @param Main $main
|
||||||
|
*/
|
||||||
|
public function __construct(Main $main){
|
||||||
|
$this->main = $main;
|
||||||
|
parent::__construct("sphgen", "Spheres games base command", "/sphgen <createworld|join|tp> <world name> [player]");
|
||||||
|
$this->setPermission("sphereable.cmd.join");
|
||||||
|
$this->setUsage("§4§o[§r§4Usage§o§4]§r§4 /sphgen <createworld|join|tp> <world name>[player]");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the command is executed
|
||||||
|
*
|
||||||
|
* @param CommandSender $sender
|
||||||
|
* @param string $commandLabel
|
||||||
|
* @param array $args
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function execute(CommandSender $sender, string $commandLabel, array $args): bool {
|
||||||
|
if(count($args) < 2){
|
||||||
|
$this->setUsage("§4§o[§r§4Usage§o§4]§r§4 /sphgen <createworld|join|tp> <world name> [player]");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
switch($args[0]){
|
||||||
|
case "createworld":
|
||||||
|
case "cw":
|
||||||
|
if(!$sender->hasPermission("sphereable.cmd.createworld")){
|
||||||
|
$sender->sendMessage("§4§o[§r§4Permission§o§4]§r§4 You don't have the permission to execute this command. If you believe this is an error, please contact the server administrator.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Server::getInstance()->generateLevel($args[1],
|
||||||
|
(int) round(rand(0, (int) (round(time() / memory_get_usage(true)) * (int) str_shuffle("127469453645108") / (int) str_shuffle("12746945364"))))
|
||||||
|
, SpheresGenerator::class , []);
|
||||||
|
Server::getInstance()->loadLevel($args[1]);
|
||||||
|
$sender->sendMessage("§a§o[§r§aSuccess§o§a]§r§a Generating world $args[1]...");
|
||||||
|
if(Server::getInstance()->getPluginManager()->getPlugin("PSMCore") !== null){
|
||||||
|
\Ad5001\PSMCore\API::addPlayerAction('Tp to challenge world "' . $args[1] . '"', "sphgen tp {$args[1]} %p");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "join":
|
||||||
|
case "j":
|
||||||
|
if(file_exists(Server::getInstance()->getDataPath() . "worlds/{$args[1]}/level.dat")){
|
||||||
|
if(Server::getInstance()->getLevelByName($args[1]) == null){
|
||||||
|
Server::getInstance()->loadLevel($args[1]);
|
||||||
|
}
|
||||||
|
if(Server::getInstance()->getLevelByName($args[1])->getProvider()->getGenerator() == "spheres"){
|
||||||
|
$sender->teleport(new Position(264, 256, 264,Server::getInstance()->getLevelByName($args[1])));
|
||||||
|
$effect = Effect::getEffectByName("resistance");
|
||||||
|
$effect->setDuration(600);
|
||||||
|
$effect->setAmplifier(99);
|
||||||
|
$effect->setVisible(false);
|
||||||
|
$sender->addEffect($effect);
|
||||||
|
$sender->sendMessage("§a§o[§r§aSuccess§o§a]§r§a Teleporting to challenge world $args[1]...");
|
||||||
|
} else {
|
||||||
|
$sender->sendMessage("§4§o[§r§4Error§o§4]§r§4 Spheres world $args[1] doesn't exist. Generate a world using /sphgen cw <world name>.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$sender->sendMessage("§4§o[§r§4Error§o§4]§r§4 Spheres world $args[1] doesn't exist. Generate a world using /sphgen cw <world name>.");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "tp":
|
||||||
|
if(!$sender->hasPermission("sphereable.cmd.tp")){
|
||||||
|
$sender->sendMessage("§4§o[§r§4Permission§o§4]§r§4 You don't have the permission to execute this command. If you believe this is an error, please contact the server administrator.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(count($args) < 3){
|
||||||
|
$sender->sendMessage("§4§o[§r§4Usage§o§4]§r§4 /sphgen $args[0] <world name> <player>");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(file_exists(Server::getInstance()->getDataPath() . "worlds/{$args[1]}/level.dat")){
|
||||||
|
if(Server::getInstance()->getLevelByName($args[1]) == null){
|
||||||
|
Server::getInstance()->loadLevel($args[1]);
|
||||||
|
}
|
||||||
|
if(Server::getInstance()->getLevelByName($args[1])->getProvider()->getGenerator() == "spheres"){
|
||||||
|
if(Server::getInstance()->getPlayer($args[2]) == null) {
|
||||||
|
$sender->sendMessage("§4§o[§r§4Error§o§4]§r§4 Player $args[2] doesn't exists or isn't connected.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$player = Server::getInstance()->getPlayer($args[2]);
|
||||||
|
$player->teleport(new Position(264, 256, 264,Server::getInstance()->getLevelByName($args[1])));
|
||||||
|
$effect = Effect::getEffectByName("resistance");
|
||||||
|
$effect->setDuration(600);
|
||||||
|
$effect->setAmplifier(99);
|
||||||
|
$effect->setVisible(false);
|
||||||
|
$player->addEffect($effect);
|
||||||
|
$player->sendMessage("§a§o[§r§aSuccess§o§a]§r§a {$sender->getName()} teleported you to to challenge world $args[1]...");
|
||||||
|
$sender->sendMessage("§a§o[§r§aSuccess§o§a]§r§a Teleporting $args[2] to challenge world $args[1]...");
|
||||||
|
} else {
|
||||||
|
$sender->sendMessage("§4§o[§r§4Error§o§4]§r§4 Spheres world $args[1] doesn't exist. Generate a world using /sphgen cw <world name>.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$sender->sendMessage("§4§o[§r§4Error§o§4]§r§4 Spheres world $args[1] doesn't exist. Generate a world using /sphgen cw <world name>.");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates custom data for command
|
||||||
|
*
|
||||||
|
* @param Player $player
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function generateCustomCommandData(Player $player): array {
|
||||||
|
$cmdData = parent::generateCustomCommandData($player);
|
||||||
|
$cmdData["permission"] = "sphereable.cmd.join";
|
||||||
|
$cmdData["aliases"] = [];
|
||||||
|
$cmdData["overloads"]["default"]["input"]["parameters"] = [
|
||||||
|
0 => [
|
||||||
|
"type" => "stringenum",
|
||||||
|
"name" => "subcmd",
|
||||||
|
"optional" => false,
|
||||||
|
"enum_values" => [
|
||||||
|
"createworld",
|
||||||
|
"cw",
|
||||||
|
"join",
|
||||||
|
"j",
|
||||||
|
]
|
||||||
|
],
|
||||||
|
1 => [
|
||||||
|
"type" => "string",
|
||||||
|
"name" => "world",
|
||||||
|
"optional" => false
|
||||||
|
],
|
||||||
|
2 => [
|
||||||
|
"type" => "string",
|
||||||
|
"name" => "player",
|
||||||
|
"optional" => true
|
||||||
|
]
|
||||||
|
];
|
||||||
|
return $cmdData;
|
||||||
|
}
|
||||||
|
}
|
363
src/Ad5001/Spherable/generators/spheres/SpheresGenerator.php
Normal file
363
src/Ad5001/Spherable/generators/spheres/SpheresGenerator.php
Normal file
|
@ -0,0 +1,363 @@
|
||||||
|
<?php
|
||||||
|
/***
|
||||||
|
* ____ _ _ _
|
||||||
|
* / ___| _ __ | |__ ___ _ __ __ _ | |__ | | ___
|
||||||
|
* \___ \ | '_ \ | '_ \ / _ \| '__|/ _` || '_ \ | | / _ \
|
||||||
|
* ___) || |_) || | | || __/| | | (_| || |_) || || __/
|
||||||
|
* |____/ | .__/ |_| |_| \___||_| \__,_||_.__/ |_| \___|
|
||||||
|
* |_|
|
||||||
|
*
|
||||||
|
* Spheres world generator. A new survival challenge.
|
||||||
|
* @author Ad5001 <mail@ad5001.eu>
|
||||||
|
* @copyright (C) 2017 Ad5001
|
||||||
|
* @license NTOSL (View LICENSE.md)
|
||||||
|
* @package Spherical
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://download.ad5001.eu/en/view.php?name=Spherable&src=github
|
||||||
|
*/
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace Ad5001\Spherable\generators\spheres;
|
||||||
|
|
||||||
|
use pocketmine\level\generator\Generator;
|
||||||
|
use pocketmine\level\generator\biome\BiomeSelector;
|
||||||
|
use pocketmine\level\generator\biome\Biome;
|
||||||
|
use pocketmine\level\generator\object\OreType;
|
||||||
|
use pocketmine\level\generator\populator\GroundCover;
|
||||||
|
use pocketmine\level\generator\populator\Ore;
|
||||||
|
use pocketmine\level\generator\populator\Populator;
|
||||||
|
use pocketmine\block\Block;
|
||||||
|
try {
|
||||||
|
if(!class_exists("pocketmine\\block\\BlockFactory")) {
|
||||||
|
class_alias("pocketmine\\block\\Block", "pocketmine\\block\\BlockFactory");
|
||||||
|
}
|
||||||
|
} catch(Throwable $e){
|
||||||
|
class_alias("pocketmine\\block\\Block", "pocketmine\\block\\BlockFactory");
|
||||||
|
}
|
||||||
|
use pocketmine\level\ChunkManager;
|
||||||
|
use pocketmine\level\Level;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
|
class SpheresGenerator extends Generator {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** @var Level */
|
||||||
|
protected $level;
|
||||||
|
|
||||||
|
|
||||||
|
/** @var Random */
|
||||||
|
protected $random;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array[]
|
||||||
|
*
|
||||||
|
* An array of planets made of different blocks.
|
||||||
|
**/
|
||||||
|
protected $spheresBlocks = [
|
||||||
|
[
|
||||||
|
[Block::IRON_ORE, 0, 25],
|
||||||
|
[Block::STONE, 0, 75],
|
||||||
|
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::COAL_ORE, 0, 25],
|
||||||
|
[Block::STONE, 0, 75],
|
||||||
|
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::GOLD_ORE, 0, 25],
|
||||||
|
[Block::STONE, 0, 75],
|
||||||
|
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 7],
|
||||||
|
[Block::LAPIS_BLOCK, 0, 93],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::REDSTONE_BLOCK, 0, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::WOOD, 12, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::WOOD, 13, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::WOOD, 14, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::WOOD, 15, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::WOOD2, 12, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::WOOD2, 13, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::PLANKS, 0, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::LEAVES, 4, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 7],
|
||||||
|
[Block::NOTEBLOCK, 0, 93],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 3],
|
||||||
|
[Block::SNOW_BLOCK, 0, 97],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::COBWEB, 0, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::WOOL, 0, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::WOOL, 1, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::WOOL, 3, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::WOOL, 4, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::WOOL, 0, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 7],
|
||||||
|
[Block::BOOKSHELF, 0, 90],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 30],
|
||||||
|
[Block::OBSIDIAN, 0, 70],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 7],
|
||||||
|
[Block::STONE_BRICK, 0, 90],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 7],
|
||||||
|
[Block::GRAVEL, 0, 40],
|
||||||
|
[Block::STONE, 0, 50],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 7],
|
||||||
|
[Block::SAND, 0, 40],
|
||||||
|
[Block::SANDSTONE, 0, 53],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 7],
|
||||||
|
[Block::PACKED_ICE, 0, 93],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 3],
|
||||||
|
[Block::SLIME_BLOCK, 0, 97],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::QUARTZ_BLOCK, 0, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 2],
|
||||||
|
[Block::NETHERRACK, 0, 98],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 5],
|
||||||
|
[Block::EMERALD_ORE, 0, 95],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 7],
|
||||||
|
[Block::REDSTONE_LAMP, 0, 90],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 10],
|
||||||
|
[Block::END_STONE, 0, 90],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 10],
|
||||||
|
[Block::NETHER_BRICKS, 0, 90],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 10],
|
||||||
|
[Block::MELON_BLOCK, 0, 90],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 7],
|
||||||
|
[Block::GLOWSTONE, 0, 93],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 7],
|
||||||
|
[Block::PUMPKIN, 0, 93],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 10],
|
||||||
|
[Block::SOUL_SAND, 0, 90],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 10],
|
||||||
|
[Block::SPONGE, 0, 90],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 10],
|
||||||
|
[Block::PRISMARINE, 0, 90],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 10],
|
||||||
|
[Block::SEA_LANTERN, 0, 90],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[Block::DIAMOND_ORE, 0, 10],
|
||||||
|
[Block::NETHER_REACTOR, 0, 90],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
public function __construct(array $options = []){}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inits the class for the var
|
||||||
|
* @param ChunkManager $level
|
||||||
|
* @param Random $random
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function init(ChunkManager $level, Random $random) {
|
||||||
|
$this->level = $level;
|
||||||
|
$this->random = $random;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Returns the name of the generator
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName() : string{
|
||||||
|
return "spheres";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the settings of the generator
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getSettings() : array{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a chunk
|
||||||
|
*
|
||||||
|
* @param int $chunkX
|
||||||
|
* @param int $chunkZ
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function generateChunk(int $chunkX, int $chunkZ){
|
||||||
|
// Leave blank, planets will be generated later
|
||||||
|
$chunk = $this->level->getChunk($chunkX, $chunkZ);
|
||||||
|
for($x = 0; $x < 16; $x++) {
|
||||||
|
for($z = 0; $z < 16; $z++) {
|
||||||
|
$chunk->setBiomeId($x, $z, 1);
|
||||||
|
if($chunkX == 16 && $chunkZ == 16) $chunk->setBlockId($x, 254, $z, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$chunk->setGenerated();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates the chunk with planets
|
||||||
|
*
|
||||||
|
* @param int $chunkX
|
||||||
|
* @param int $chunkZ
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function populateChunk(int $chunkX, int $chunkZ){
|
||||||
|
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
|
||||||
|
$chunk = $this->level->getChunk($chunkX, $chunkZ);
|
||||||
|
$count = $this->random->nextRange(1, 4);
|
||||||
|
for($i = 0; $i <= $count; $i++){
|
||||||
|
$y = $this->random->nextRange(17, Level::Y_MAX - 25);
|
||||||
|
$maxRadius = $y % 10;
|
||||||
|
if($maxRadius < 6) $maxRadius = 6;
|
||||||
|
// $maxRadius is situated between 12 and 20 depending on Y choosen
|
||||||
|
// Let's add a little bit more random
|
||||||
|
$radius = $this->random->nextRange(5, (int) round($maxRadius));
|
||||||
|
// Generating planet
|
||||||
|
$x = $chunkX * 16 + $this->random->nextRange(0, 15);
|
||||||
|
$z = $chunkZ * 16 + $this->random->nextRange(0, 15);
|
||||||
|
$center = new Vector3($x, $y, $z);
|
||||||
|
$this->generatePlanet($center, $radius);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the dafault spawn
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function getSpawn() : Vector3{
|
||||||
|
return new Vector3(264, 255, 264);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a planet
|
||||||
|
* psmcoreactplugin createlevel4psm Welp spheres 9247603569486
|
||||||
|
*
|
||||||
|
* @param Vector3 $center
|
||||||
|
* @param int $radius
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function generatePlanet(Vector3 $center, int $radius){
|
||||||
|
$radiusSquared = $radius ** 2;
|
||||||
|
$currentSphereBlocks = $this->spheresBlocks[array_rand($this->spheresBlocks)];
|
||||||
|
for ($x = $center->x - $radius; $x <= $center->x + $radius; $x++) {
|
||||||
|
$xsquared = ($center->x - $x) * ($center->x - $x);
|
||||||
|
for ($y = $center->y - $radius; $y <= $center->y + $radius; $y++) {
|
||||||
|
$ysquared = ($center->y - $y) * ($center->y - $y);
|
||||||
|
for ($z = $center->z - $radius; $z <= $center->z + $radius; $z++) {
|
||||||
|
$zsquared = ($center->z - $z) * ($center->z - $z);
|
||||||
|
if($xsquared + $ysquared + $zsquared < $radiusSquared) {
|
||||||
|
// Choosing a random block to place
|
||||||
|
$rand = $this->random->nextBoundedInt(100) + 1;
|
||||||
|
foreach($currentSphereBlocks as $block){
|
||||||
|
if($rand > $block[2]) {
|
||||||
|
$rand = $block[2];
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
$this->level->setBlockIdAt($x, $y, $z, $block[0], false, false);
|
||||||
|
$this->level->setBlockDataAt($x, $y, $z, $block[1], false, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue