├── meta
├── simplewarp.png
├── simplewarp-1.png
└── simplewarp-2.png
├── .gitignore
├── src
└── falkirks
│ └── simplewarp
│ ├── store
│ ├── Reloadable.php
│ ├── Saveable.php
│ ├── StandardStore.php
│ ├── DataStore.php
│ └── YAMLStore.php
│ ├── event
│ ├── WarpEvent.php
│ ├── WarpCloseEvent.php
│ ├── WarpAddEvent.php
│ ├── WarpOpenEvent.php
│ ├── WarpDeleteEvent.php
│ └── PlayerWarpEvent.php
│ ├── Version.php
│ ├── command
│ ├── SimpleWarpCommand.php
│ ├── essentials
│ │ ├── EssentialsWarpCommand.php
│ │ └── EssentialsDelWarpCommand.php
│ ├── DelWarpCommand.php
│ ├── OpenWarpCommand.php
│ ├── CloseWarpCommand.php
│ ├── WarpReportCommand.php
│ ├── ListWarpsCommand.php
│ ├── WarpCommand.php
│ └── AddWarpCommand.php
│ ├── utils
│ ├── WeakPosition.php
│ ├── ChecksumVerify.php
│ ├── DebugDumpFactory.php
│ └── SpoonDetector.php
│ ├── permission
│ └── SimpleWarpPermissions.php
│ ├── task
│ ├── PlayerWarpTask.php
│ └── CommandWarpTask.php
│ ├── Warp.php
│ ├── Destination.php
│ ├── SimpleWarp.php
│ ├── api
│ └── SimpleWarpAPI.php
│ ├── lang
│ └── TranslationManager.php
│ └── WarpManager.php
├── .poggit.yml
├── entry.php
├── ISSUE_TEMPLATE.md
├── LICENSE
├── plugin.yml
├── resources
└── config.yml
└── README.md
/meta/simplewarp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/falkirks/SimpleWarp/HEAD/meta/simplewarp.png
--------------------------------------------------------------------------------
/meta/simplewarp-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/falkirks/SimpleWarp/HEAD/meta/simplewarp-1.png
--------------------------------------------------------------------------------
/meta/simplewarp-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/falkirks/SimpleWarp/HEAD/meta/simplewarp-2.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/*
2 | src/simplewarp
3 | out
4 | config.yml
5 | lang.yml
6 | warps.yml
7 | .started
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/store/Reloadable.php:
--------------------------------------------------------------------------------
1 | warp = $warp;
13 | }
14 |
15 | /**
16 | * @return Warp
17 | */
18 | public function getWarp(): Warp{
19 | return $this->warp;
20 | }
21 | }
--------------------------------------------------------------------------------
/entry.php:
--------------------------------------------------------------------------------
1 | $warp){
9 | $this->add($name, $warp);
10 | }
11 | }
12 | public function removeAll($warps){
13 | foreach($warps as $warp){
14 | $this->remove($warp);
15 | }
16 | }
17 | public function exists($name): bool{
18 | return $this->get($name) !== null;
19 | }
20 |
21 | }
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/event/WarpCloseEvent.php:
--------------------------------------------------------------------------------
1 | sender = $sender;
16 | }
17 | /**
18 | * @return CommandSender
19 | */
20 | public function getSender(): CommandSender{
21 | return $this->sender;
22 | }
23 |
24 | }
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/event/WarpAddEvent.php:
--------------------------------------------------------------------------------
1 | sender = $sender;
16 | }
17 |
18 |
19 | /**
20 | * @return CommandSender
21 | */
22 | public function getSender(): CommandSender{
23 | return $this->sender;
24 | }
25 |
26 | }
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/event/WarpOpenEvent.php:
--------------------------------------------------------------------------------
1 | sender = $sender;
18 | }
19 |
20 | /**
21 | * @return CommandSender
22 | */
23 | public function getSender(): CommandSender{
24 | return $this->sender;
25 | }
26 | }
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/event/WarpDeleteEvent.php:
--------------------------------------------------------------------------------
1 | sender = $sender;
17 | }
18 |
19 | /**
20 | * @return CommandSender
21 | */
22 | public function getSender(): CommandSender{
23 | return $this->sender;
24 | }
25 |
26 | }
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/Version.php:
--------------------------------------------------------------------------------
1 | sendMessage(Version::$quotes[array_rand(Version::$quotes)]);
18 | }
19 | //$sender->sendMessage("SimpleWarp " . self::VERSION_STRING);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/command/SimpleWarpCommand.php:
--------------------------------------------------------------------------------
1 | getPlugin()->isDisabled()){
24 | $sender->sendMessage($this->getPlugin()->getApi()->executeTranslationItem("plugin-disabled"));
25 | return false;
26 | }
27 | return true;
28 | }
29 |
30 | public abstract function getPlugin(): Plugin;
31 | }
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/store/DataStore.php:
--------------------------------------------------------------------------------
1 | player = $player;
19 | $this->warp = $warp;
20 | }
21 |
22 | /**
23 | * @return Warp
24 | */
25 | public function getWarp(): Warp{
26 | return $this->warp;
27 | }
28 | public function getDestination(): Destination{
29 | return ($this->destination instanceof Destination ? $this->destination : $this->warp->getDestination());
30 | }
31 | public function setDestination(Destination $destination){
32 | $this->destination = $destination;
33 | }
34 |
35 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2015 Falkirks
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/utils/WeakPosition.php:
--------------------------------------------------------------------------------
1 | levelName = $levelName;
23 | }
24 | public function isValid(): bool {
25 | return Server::getInstance()->getLevelByName($this->levelName) instanceof Level;
26 | }
27 | public function updateProperties(){
28 | $this->level = $this->getLevel();
29 | }
30 | public function getLevel(): Level{
31 | return Server::getInstance()->getLevelByName($this->levelName);
32 | }
33 |
34 | public function getLevelName(){
35 | return $this->levelName;
36 | }
37 | }
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/utils/ChecksumVerify.php:
--------------------------------------------------------------------------------
1 | getDescription()->getName() . "/" . $pluginBase->getDescription()->getVersion();
18 | $hash = Internet::getURL($url);
19 | if($pluginBase->getPluginLoader() instanceof PharPluginLoader){
20 | $reflect = new \ReflectionClass($pluginBase);
21 | $method = $reflect->getMethod("getFile");
22 | $method->setAccessible(true);
23 | $file = $method->invoke($pluginBase);
24 | $method->setAccessible(false);
25 |
26 | $check = sha1_file(substr($file, 7, -1));
27 | return $check === $hash;
28 | }
29 | return false;
30 |
31 | }
32 |
33 | }
--------------------------------------------------------------------------------
/plugin.yml:
--------------------------------------------------------------------------------
1 | # Do NOT edit this file to change permissions
2 | name: SimpleWarp
3 | main: falkirks\simplewarp\SimpleWarp
4 | version: 4.0.1
5 | author: Falkirks
6 | api: [3.0.0, 4.0.0]
7 | load: POSTWORLD
8 | softdepend: ["FastTransfer", "SlowTransfer", "EssentialsPE"]
9 | permissions:
10 | simplewarp:
11 | default: op
12 | children:
13 | simplewarp.command:
14 | default: op
15 | children:
16 | simplewarp.command.list:
17 | default: true
18 | children:
19 | simplewarp.command.list.xyz:
20 | default: op
21 | simplewarp.command.list.visual:
22 | default: op
23 | simplewarp.command.addwarp:
24 | default: op
25 | simplewarp.command.delwarp:
26 | default: op
27 | simplewarp.command.warp:
28 | default: true
29 | simplewarp.command.warp.other:
30 | default: op
31 | simplewarp.command.openwarp:
32 | default: op
33 | simplewarp.command.closewarp:
34 | default: op
35 | simplewarp.command.closewarp:
36 | default: op
37 | simplewarp.essentials.notice:
38 | default: op
39 | description: Recieve messages when their is warp conflict in Essentials
40 | simplewarp.warp:
41 | default: op
42 | description: Allows usage of all warps
43 |
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/store/YAMLStore.php:
--------------------------------------------------------------------------------
1 | config = $config;
12 | }
13 |
14 | public function add($name, $warp){
15 | $past = $this->config->get($name, null);
16 | $this->config->set($name, $warp);
17 | $this->config->save();
18 | return $past;
19 | }
20 | public function get($name){
21 | return $this->config->get($name, null);
22 | }
23 |
24 | public function remove($name){
25 | $past = $this->config->get($name, null);
26 | $this->config->remove($name);
27 | $this->config->save();
28 | return $past;
29 | }
30 |
31 | public function clear(){
32 | $this->config->setAll([]);
33 | $this->config->save();
34 | }
35 |
36 | public function reload(){
37 | $this->config->reload();
38 | }
39 | /**
40 | * Returns something which can be used to iterate
41 | * over the store.
42 | * @return mixed
43 | */
44 | public function getIterator(){
45 | return $this->config->getAll();
46 | }
47 |
48 | public function save(){
49 | $this->config->save();
50 | }
51 |
52 | }
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/permission/SimpleWarpPermissions.php:
--------------------------------------------------------------------------------
1 | getPermission("simplewarp.warp");
28 | $permission = new Permission(self::BASE_WARP_PERMISSION . "." . $warp->getName(), "Allow use of " . $warp->getName()); //TODO correct default value
29 | PermissionManager::getInstance()->addPermission($permission);
30 | self::$baseWarpPerm->getChildren()[$permission->getName()] = true;
31 | }
32 | }
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/utils/DebugDumpFactory.php:
--------------------------------------------------------------------------------
1 | api = $simpleWarp;
18 | }
19 |
20 |
21 | public function generate(): string {
22 | return implode("\n", [
23 | "SERVER VERSION: " . $this->api->getSimpleWarp()->getServer()->getPocketMineVersion(),
24 | "API: " . $this->api->getSimpleWarp()->getServer()->getApiVersion(),
25 | "MCPE VERSION: " . $this->api->getSimpleWarp()->getServer()->getVersion(),
26 | "SOFTWARE: " . $this->api->getSimpleWarp()->getServer()->getName(),
27 | "SimpleWarp Version: " . $this->api->getSimpleWarp()->getDescription()->getVersion(),
28 | "PLUGINS: " . implode(",", array_keys($this->api->getSimpleWarp()->getServer()->getPluginManager()->getPlugins())),
29 | "storage-mode: " . $this->api->getSimpleWarp()->getWarpManager()->getFlag(),
30 | "essentials-support: " . ($this->api->getSimpleWarp()->getConfig()->get("essentials-support") ? 'true' : 'false'),
31 | json_encode($this->api->getSimpleWarp()->getWarpManager()->getWarps(), JSON_PRETTY_PRINT)
32 | ]);
33 | }
34 |
35 |
36 | function __toString(){
37 | return $this->generate();
38 | }
39 |
40 | /**
41 | * @return SimpleWarpAPI
42 | */
43 | public function getApi(): SimpleWarpAPI{
44 | return $this->api;
45 | }
46 | }
--------------------------------------------------------------------------------
/resources/config.yml:
--------------------------------------------------------------------------------
1 | # >=>>=> >=> >=> >=> >=>
2 | # >=> >=> >=> >=> >=> >=>
3 | # >=> >=> >===>>=>>==> >=> >=> >=> >==> >=> >> >=> >=> >=> >> >==> >=> >=>
4 | # >=> >=> >=> >> >=> >> >=> >=> >> >=> >=> >=> >=> >=> >=> >=> >> >=>
5 | # >=> >=> >=> >> >=> >> >=> >=> >>===>>=> >=> >> >=> >=> >=> >=> >=> >> >=>
6 | # >=> >=> >=> >=> >> >=> >=> >=> >=> >> >> >> >===> >=> >=> >=> >=> >=>
7 | # >=>>=> >=> >==> >> >=> >=> >==> >====> >=> >=> >==>>>==> >==> >=>
8 | # >=> The original warp plugin for PocketMine >=>
9 |
10 | display-exact-coordinates: false
11 | # If set to false the coordinates shown to the end user
12 | # will be rounded, players will still be teleported to the
13 | # exact location.
14 | storage-mode: 1
15 | # SimpleWarp can handle the storage of warps in three main ways.
16 | #
17 | # MEMORY_TILL_CLOSE = 0
18 | # Warps are loaded into memory when the server starts and are
19 | # held there until the server closes. When the server closes
20 | # they are converted back into YAML. This new YAML will
21 | # replace warps.yml, this means that changes are lost and
22 | # warps which fail to load are discarded.
23 | #
24 | #
25 | # FLUSH_ON_CHANGE = 1
26 | # Warps are loaded into memory when the server starts. Whenever a
27 | # warp is updated, it will be updated in the warps.yml. When the
28 | # server closes, the warps file is NOT overwritten.
29 | #
30 | # NO_MEMORY_STORE = 2
31 | # Warps are never "stored" in memory. They are converted on demand
32 | # between YAML and object format. Any changes made to the config
33 | # will be available right away in the server and vice versa.
34 | #
35 | essentials-support: false
36 | # If essentials-support is enabled and EssentialsPE is installed,
37 | # SimpleWarp will take steps to ensure compatibility between the
38 | # two plugins.
39 | hold-still-enabled: true
40 | hold-still-time: 60
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/task/PlayerWarpTask.php:
--------------------------------------------------------------------------------
1 | simpleWarp = $plugin;
18 | $this->warp = $warp;
19 | $this->player = $player;
20 | $this->position = $player->getPosition();
21 | }
22 |
23 | /**
24 | * Actions to execute when run
25 | *
26 | * @param $currentTick
27 | *
28 | * @return void
29 | */
30 | public function onRun(int $currentTick){
31 | if($this->player instanceof Player && $this->player->isOnline()){
32 | if(!$this->getSimpleWarp()->getConfig()->get("hold-still-enabled") || $this->player->getPosition()->equals($this->position)){
33 | $this->warp->teleport($this->player);
34 | }
35 | }
36 | }
37 |
38 | public function runNext(){
39 | $this->getSimpleWarp()->getScheduler()->scheduleTask($this);
40 | }
41 |
42 | public function runWithHoldStill(){
43 | $this->getSimpleWarp()->getScheduler()->scheduleDelayedTask($this, $this->getSimpleWarp()->getConfig()->get("hold-still-time"));
44 | }
45 |
46 | public function run(){
47 | if($this->getSimpleWarp()->getConfig()->get("hold-still-enabled")){
48 | $this->runWithHoldStill();
49 | }
50 | else{
51 | $this->runNext();
52 | }
53 | }
54 |
55 |
56 | /**
57 | * @return Warp
58 | */
59 | public function getWarp(): Warp{
60 | return $this->warp;
61 | }
62 |
63 | /**
64 | * @return Player
65 | */
66 | public function getPlayer(): Player{
67 | return $this->player;
68 | }
69 |
70 | /**
71 | * @return SimpleWarp
72 | */
73 | public function getSimpleWarp(): SimpleWarp{
74 | return $this->simpleWarp;
75 | }
76 |
77 |
78 |
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/command/essentials/EssentialsWarpCommand.php:
--------------------------------------------------------------------------------
1 | essCommand = $essCommand;
18 | }
19 |
20 | public function execute(CommandSender $sender, string $commandLabel, array $args) {
21 | if(isset($args[0])) {
22 | $ess = $this->getEssAPI();
23 | if (isset($this->api->getWarpManager()[$args[0]])) {
24 | parent::execute($sender, $commandLabel, $args);
25 | if($ess->warpExists($args[0]) && $sender->hasPermission("simplewarp.essentials.notice")){
26 | $sender->sendMessage($this->api->executeTranslationItem("ess-warp-conflict", $args[0]));
27 | }
28 | }
29 | elseif(($name = $this->getEssWarpName($ess, $args[0])) !== null){
30 | $args[0] = $name;
31 | $this->getEssCommand()->execute($sender, $commandLabel, $args);
32 | }
33 | else{
34 | $sender->sendMessage($this->api->executeTranslationItem("ess-warp-doesnt-exist"));
35 | }
36 | }
37 | else{
38 | $sender->sendMessage($this->getUsage());
39 | Version::sendVersionMessage($sender);
40 | }
41 | }
42 | private function getEssWarpName($loader, $string){
43 | if($loader->warpExists($string)){
44 | return $string;
45 | }
46 | if(substr($string, 0, 4) === "ess:" && $loader->warpExists(substr($string, 4))){
47 | return substr($string, 4);
48 | }
49 | return null;
50 | }
51 | private function getEssAPI(){
52 | $ess = $this->getPlugin()->getServer()->getPluginManager()->getPlugin("EssentialsPE");
53 | if(method_exists($ess, "getAPI")){
54 | return $ess->getAPI();
55 | }
56 | return $ess;
57 | }
58 | /**
59 | * @return Command
60 | */
61 | public function getEssCommand(): SimpleWarp{
62 | return $this->essCommand;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/command/essentials/EssentialsDelWarpCommand.php:
--------------------------------------------------------------------------------
1 | essCommand = $essCommand;
19 | }
20 | public function execute(CommandSender $sender, string $commandLabel, array $args) {
21 | if(isset($args[0])) {
22 | $ess = $this->getEssAPI();
23 | if (isset($this->api->getWarpManager()[$args[0]])) {
24 | parent::execute($sender, $commandLabel, $args);
25 | if($ess->warpExists($args[0]) && $sender->hasPermission("simplewarp.essentials.notice")){
26 | $sender->sendMessage($this->api->executeTranslationItem("ess-warp-conflict", $args[0]));
27 | }
28 | }
29 | elseif(($name = $this->getEssWarpName($ess, $args[0])) !== null){
30 | $args[0] = $name;
31 | $this->getEssCommand()->execute($sender, $commandLabel, $args);
32 | }
33 | else{
34 | $sender->sendMessage($this->api->executeTranslationItem("ess-warp-doesnt-exist"));
35 | }
36 | }
37 | else{
38 | $sender->sendMessage($this->getUsage());
39 | Version::sendVersionMessage($sender);
40 | }
41 | }
42 | private function getEssWarpName($loader, $string){
43 | if($loader->warpExists($string)){
44 | return $string;
45 | }
46 | if(substr($string, 0, 4) === "ess:" && $loader->warpExists(substr($string, 4))){
47 | return substr($string, 4);
48 | }
49 | return null;
50 | }
51 |
52 | private function getEssAPI(){
53 | $ess = $this->getPlugin()->getServer()->getPluginManager()->getPlugin("EssentialsPE");
54 | if(method_exists($ess, "getAPI")){
55 | return $ess->getAPI();
56 | }
57 | return $ess;
58 | }
59 |
60 | /**
61 | * @return Command
62 | */
63 | public function getEssCommand(): SimpleWarp{
64 | return $this->essCommand;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/command/DelWarpCommand.php:
--------------------------------------------------------------------------------
1 | executeTranslationItem("delwarp-cmd"), $api->executeTranslationItem("delwarp-desc"), $api->executeTranslationItem("delwarp-usage"));
20 | $this->api = $api;
21 | }
22 |
23 | /**
24 | * @param CommandSender $sender
25 | * @param string $commandLabel
26 | * @param string[] $args
27 | *
28 | * @return mixed
29 | */
30 | public function execute(CommandSender $sender, string $commandLabel, array $args) {
31 | if(parent::execute($sender, $commandLabel, $args)) {
32 | if ($sender->hasPermission(SimpleWarpPermissions::DEL_WARP_COMMAND)) {
33 | if (isset($args[0])) {
34 | if (isset($this->api->getWarpManager()[$args[0]])) {
35 | $ev = new WarpDeleteEvent($sender, $this->api->getWarpManager()[$args[0]]);
36 | $this->getPlugin()->getServer()->getPluginManager()->callEvent($ev);
37 | if (!$ev->isCancelled()) {
38 | unset($this->api->getWarpManager()[$args[0]]);
39 | $sender->sendMessage($this->api->executeTranslationItem("warp-deleted", $args[0]));
40 | }
41 | else {
42 | $sender->sendMessage($this->api->executeTranslationItem("delwarp-event-cancelled"));
43 | }
44 | }
45 | else {
46 | $sender->sendMessage($this->api->executeTranslationItem("warp-doesnt-exist", $args[0]));
47 | }
48 | }
49 | else {
50 | $sender->sendMessage($this->getUsage());
51 | Version::sendVersionMessage($sender);
52 | }
53 | }
54 | else {
55 | $sender->sendMessage($this->api->executeTranslationItem("delwarp-noperm"));
56 | }
57 | }
58 | }
59 |
60 |
61 | /**
62 | * @return \pocketmine\plugin\Plugin
63 | */
64 | public function getPlugin(): Plugin{
65 | return $this->api->getSimpleWarp();
66 | }
67 | }
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/utils/SpoonDetector.php:
--------------------------------------------------------------------------------
1 | getName(), self::$thingsThatAreNotSpoons);
40 | }
41 |
42 | private static function contentValid(string $content): bool {
43 | return (strpos($content, self::$spoonTxtContent) > -1) && (strrpos($content, "yes") > strrpos($content, "?"));
44 | }
45 |
46 | public static function printSpoon(PluginBase $pluginBase, $fileToCheck){
47 | if(self::isThisSpoon()){
48 | if(!file_exists($pluginBase->getDataFolder() . $fileToCheck)){
49 | file_put_contents($pluginBase->getDataFolder() . $fileToCheck, self::$spoonTxtContent);
50 | }
51 | if(!self::contentValid(file_get_contents($pluginBase->getDataFolder() . $fileToCheck))) {
52 | $pluginBase->getLogger()->info(self::$subtleAsciiSpoon);
53 | $pluginBase->getLogger()->warning("You are attempting to run " . $pluginBase->getDescription()->getName() . " on a SPOON!");
54 | $pluginBase->getLogger()->warning("Before using the plugin you will need to open /plugins/" . $pluginBase->getDescription()->getName() . "/" . $fileToCheck . " in a text editor and agree to the terms.");
55 | $pluginBase->getServer()->getPluginManager()->disablePlugin($pluginBase);
56 | }
57 | }
58 | }
59 |
60 | }
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/command/OpenWarpCommand.php:
--------------------------------------------------------------------------------
1 | executeTranslationItem("openwarp-cmd"), $api->executeTranslationItem("openwarp-desc"), $api->executeTranslationItem("openwarp-usage"));
21 | $this->api = $api;
22 | }
23 |
24 | /**
25 | * @param CommandSender $sender
26 | * @param string $commandLabel
27 | * @param string[] $args
28 | *
29 | * @return mixed
30 | */
31 | public function execute(CommandSender $sender, string $commandLabel, array $args) {
32 | if(parent::execute($sender, $commandLabel, $args)) {
33 | if ($sender->hasPermission(SimpleWarpPermissions::OPEN_WARP_COMMAND)) {
34 | if (isset($args[0])) {
35 | if (isset($this->api->getWarpManager()[$args[0]])) {
36 | /** @var Warp $warp */
37 | $warp = $this->api->getWarpManager()[$args[0]];
38 | $ev = new WarpOpenEvent($sender, $warp);
39 | $this->getPlugin()->getServer()->getPluginManager()->callEvent($ev);
40 | if (!$ev->isCancelled()) {
41 | $warp->setPublic(true);
42 | $sender->sendMessage($this->api->executeTranslationItem("opened-warp-1", $args[0]));
43 | $sender->sendMessage($this->api->executeTranslationItem("opened-warp-2"));
44 | }
45 | else {
46 | $sender->sendMessage($this->api->executeTranslationItem("openwarp-event-cancelled"));
47 | }
48 | }
49 | else {
50 | $sender->sendMessage($this->api->executeTranslationItem("warp-doesnt-exist", $args[0]));
51 | }
52 | }
53 | else {
54 | $sender->sendMessage($this->getUsage());
55 | Version::sendVersionMessage($sender);
56 | }
57 | }
58 | else {
59 | $sender->sendMessage($this->api->executeTranslationItem("openwarp-noperm"));
60 | }
61 | }
62 | }
63 |
64 |
65 | /**
66 | * @return \pocketmine\plugin\Plugin
67 | */
68 | public function getPlugin(): Plugin{
69 | return $this->api->getSimpleWarp();
70 | }
71 | }
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/command/CloseWarpCommand.php:
--------------------------------------------------------------------------------
1 | executeTranslationItem("closewarp-cmd"), $api->executeTranslationItem("closewarp-desc"), $api->executeTranslationItem("closewarp-usage"));
21 | $this->api = $api;
22 | }
23 |
24 | /**
25 | * @param CommandSender $sender
26 | * @param string $commandLabel
27 | * @param string[] $args
28 | *
29 | * @return mixed
30 | */
31 | public function execute(CommandSender $sender, string $commandLabel, array $args) {
32 | if(parent::execute($sender, $commandLabel, $args)) {
33 | if ($sender->hasPermission(SimpleWarpPermissions::OPEN_WARP_COMMAND)) {
34 | if (isset($args[0])) {
35 | if (isset($this->api->getWarpManager()[$args[0]])) {
36 | /** @var Warp $warp */
37 | $warp = $this->api->getWarpManager()[$args[0]];
38 | $ev = new WarpCloseEvent($sender, $warp);
39 | $this->getPlugin()->getServer()->getPluginManager()->callEvent($ev);
40 | if (!$ev->isCancelled()) {
41 | $warp->setPublic(false);
42 | $sender->sendMessage($this->api->executeTranslationItem("closed-warp-1", $args[0]));
43 | $sender->sendMessage($this->api->executeTranslationItem("closed-warp-2", SimpleWarpPermissions::BASE_WARP_PERMISSION . "." . $warp->getName()));
44 | }
45 | else {
46 | $sender->sendMessage($this->api->executeTranslationItem("closewarp-event-cancelled"));
47 | }
48 | }
49 | else {
50 | $sender->sendMessage($this->api->executeTranslationItem("warp-doesnt-exist"));
51 | }
52 | }
53 | else {
54 | $sender->sendMessage($this->getUsage());
55 | Version::sendVersionMessage($sender);
56 | }
57 | }
58 | else {
59 | $sender->sendMessage($this->api->executeTranslationItem("closewarp-noperm"));
60 | }
61 | }
62 | }
63 |
64 |
65 | /**
66 | * @return \pocketmine\plugin\Plugin
67 | */
68 | public function getPlugin(): Plugin{
69 | return $this->api->getSimpleWarp();
70 | }
71 | }
--------------------------------------------------------------------------------
/src/falkirks/simplewarp/command/WarpReportCommand.php:
--------------------------------------------------------------------------------
1 | executeTranslationItem("warpreport-cmd"), $api->executeTranslationItem("warpreport-desc"), $api->executeTranslationItem("warpreport-usage"));
23 | $this->api = $api;
24 | }
25 |
26 | /**
27 | * @param CommandSender $sender
28 | * @param string $commandLabel
29 | * @param string[] $args
30 | *
31 | * @return mixed
32 | */
33 | public function execute(CommandSender $sender, string $commandLabel, array $args) {
34 | if(parent::execute($sender, $commandLabel, $args)) {
35 | if ($sender->hasPermission(SimpleWarpPermissions::WARP_REPORT_COMMAND)) {
36 | $data = $this->getPlugin()->getDebugDumpFactory()->generate();
37 | if ($sender instanceof ConsoleCommandSender) {
38 | $issueContent = "\n\n(Explain your problem here)\n\n```\n$data\n```";
39 | $url = "https://github.com/Falkirks/SimpleWarp/issues/new" . (count($args) > 0 ? "?title=" . urlencode(implode(" ", $args)) . "\&" : "?") . "body=" . urlencode($issueContent);
40 | switch (Utils::getOS()) {
41 | case 'win':
42 | `start $url`;
43 | break;
44 | case 'mac':
45 | `open $url`;
46 | break;
47 | case 'linux':
48 | `xdg-open $url`;
49 | break;
50 | default:
51 | $sender->sendMessage("Copy and paste the following URL into your browser to start a report.");
52 | $sender->sendMessage("------------------");
53 | $sender->sendMessage($url);
54 | $sender->sendMessage("------------------");
55 | break;
56 | }
57 | }
58 | $sender->sendMessage("--- SimpleWarp Data ---");
59 | $sender->sendMessage($data);
60 | }
61 | else {
62 | $sender->sendMessage($this->api->executeTranslationItem("warpreport-noperm"));
63 | }
64 | return true;
65 | }
66 | }
67 |
68 |
69 | /**
70 | * @return \pocketmine\plugin\Plugin
71 | */
72 | public function getPlugin(): Plugin{
73 | return $this->api->getSimpleWarp();
74 | }
75 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | 
4 | [](http://isitmaintained.com/project/Falkirks/SimpleWarp "Average time to resolve an issue")
5 | 
6 |
7 | SimpleWarp is the original warp plugin for PocketMine-MP. It allows players to move from point **A** to **B** with ease. At the core of SimpleWarp is simplicity and extensibility. Although very easy on the end user, it exposes a powerful backend for developers to hack around with.
8 |
9 | **SimpleWarp 2.0 is not compatible with older SimpleWarp and PocketMine versions.**
10 |
11 | ## Commands
12 | | Command | Usage | Description |
13 | | ------- | ----- | ----------- |
14 | | `/warp` | `/warp
78 | * An offset to check for.
79 | *
75 | * Whether a offset exists
76 | * @link http://php.net/manual/en/arrayaccess.offsetexists.php
77 | * @param mixed $offset
83 | * The return value will be casted to boolean if non-boolean was returned.
84 | */
85 | public function offsetExists($offset){
86 | $this->reloadStore();
87 | if(isset($this->warps[$offset]) || ($this->flag >= 2 && $this->store->exists($offset))){
88 | return true;
89 | }
90 | return false;
91 | }
92 |
93 | /**
94 | * (PHP 5 >= 5.0.0)
95 | * Offset to retrieve
96 | * @link http://php.net/manual/en/arrayaccess.offsetget.php
97 | * @param mixed $offset
98 | * The offset to retrieve. 99 | *
100 | * @return mixed Can return all value types. 101 | */ 102 | public function offsetGet($offset){ 103 | if($this->flag >= 2){ 104 | $this->reloadStore(); 105 | return $this->warpFromData($offset, $this->store->get($offset)); 106 | } 107 | return isset($this->warps[$offset]) ? $this->warps[$offset] : null; 108 | } 109 | 110 | /** 111 | * (PHP 5 >= 5.0.0)115 | * The offset to assign the value to. 116 | *
117 | * @param mixed $value118 | * The value to set. 119 | *
120 | * @return void 121 | */ 122 | public function offsetSet($offset, $value){ 123 | if($value instanceof Warp && $value->getName() === $offset) { 124 | if($this->flag < 2) { 125 | $this->warps[$offset] = $value; 126 | } 127 | 128 | if ($this->flag >= 1) { 129 | $this->store->add($offset, $this->warpToData($value)); 130 | $this->saveStore(); 131 | } 132 | } 133 | else{ 134 | //TODO report failure 135 | } 136 | } 137 | 138 | /** 139 | * (PHP 5 >= 5.0.0)143 | * The offset to unset. 144 | *
145 | * @return void 146 | */ 147 | public function offsetUnset($offset){ 148 | if($this->flag < 2){ 149 | unset($this->warps[$offset]); 150 | } 151 | 152 | if($this->flag >= 1){ 153 | $this->store->remove($offset); 154 | $this->saveStore(); 155 | } 156 | } 157 | 158 | /** 159 | * This method requires the key of the warp in order 160 | * to construct a warp object 161 | * @param $name 162 | * @param array $array 163 | * @return Warp 164 | * @throws \Exception 165 | */ 166 | protected function warpFromData($name, array $array){ 167 | if(isset($array["level"]) && isset($array["x"]) && isset($array["y"]) && isset($array["z"]) && isset($array["public"])){ // This is an internal warp 168 | return new Warp($this, $name, new Destination(new WeakPosition($array["x"], $array["y"], $array["z"], $array["level"])), $array["public"], $array["metadata"] ?? []); 169 | } 170 | elseif(isset($array["address"]) && isset($array["port"]) && isset($array["public"])) { 171 | return new Warp($this, $name, new Destination($array["address"], $array["port"]), $array["public"], $array["metadata"] ?? []); 172 | } 173 | 174 | $this->api->getSimpleWarp()->getLogger()->critical("A warp with the name " . TextFormat::AQUA . $name . TextFormat::RESET . " is incomplete. It will be removed automatically when your server stops."); 175 | return null; 176 | } 177 | 178 | /** 179 | * In order to pass data to a DataStore 180 | * a key is needed. Typically one should 181 | * use $warp->getName() 182 | * @param Warp $warp 183 | * @return array 184 | */ 185 | protected function warpToData(Warp $warp){ 186 | $ret = []; 187 | if($warp->getDestination()->isInternal()) { 188 | //TODO implement yaw and pitch 189 | $pos = $warp->getDestination()->getPosition(); 190 | $ret = [ 191 | "x" => $pos->getX(), 192 | "y" => $pos->getY(), 193 | "z" => $pos->getZ(), 194 | "level" => ($pos instanceof WeakPosition ? $pos->getLevelName() : $pos->getLevel()->getName()), 195 | "public" => $warp->isPublic(), 196 | ]; 197 | } 198 | else{ 199 | $ret = [ 200 | "address" => $warp->getDestination()->getAddress(), 201 | "port" => $warp->getDestination()->getPort(), 202 | "public" => $warp->isPublic() 203 | ]; 204 | } 205 | 206 | $ret["metadata"] = $warp->getAllMetadata(); 207 | return $ret; 208 | } 209 | 210 | /** 211 | * (PHP 5 >= 5.0.0)