Skip to content
This repository has been archived by the owner on Jul 11, 2018. It is now read-only.

Commit

Permalink
1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandroliu committed Oct 31, 2016
1 parent a3b6de0 commit ce7d28d
Show file tree
Hide file tree
Showing 8 changed files with 385 additions and 66 deletions.
57 changes: 37 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<img src="https://raw.githubusercontent.com/Muirfield/MagicTelePortal/master/media/portal-icon.jpg" style="width:64px;height:64px" width="64" height="64"/>

# MagicTelePortal

* Summary: Easy to use Portal plugin
Expand All @@ -6,10 +8,20 @@
* DependencyPlugins: -
* OptionalPlugins: FastTransfer
* Categories: Fun
* Plugin Access: Blocks, Commands
* Plugin Access: Commands, Data Saving, World Editing

## Overview

**DO NOT POST QUESTION/BUG-REPORTS/REQUESTS IN THE REVIEWS**

Overview
--------
It is difficult to carry a conversation in the reviews. If you have a
question/bug-report/request please use the
[Thread](http://forums.pocketmine.net/threads/magicteleportal.8053/) for
that. You are more likely to get a response and help that way.

Please go to
[github](https://github.com/alejandroliu/pocketmine-plugins/tree/master/MagicTelePortal)
for the most up-to-date documentation.

Simple plugin to make creation of portals easy.

Expand Down Expand Up @@ -37,7 +49,7 @@ Examples:

### Configuration

~~~~
```YAML
[CODE]
# How far can the portals be created
max-dist: 8
Expand All @@ -47,37 +59,42 @@ border: 112
center: 9
# Block-id of the corners (defaults to Nether Brick Stairs)
corner: 114
# Broadcast teleports (UNIMPLEMENTED)
broadcast-tp: true
[/CODE]
~~~~

```

### Permission Nodes:
### Permission Nodes

* mtp.cmd.mtp: Permission to create portals
* mtp.destroy: Permission to destroy portals

FAQ
---

* Q: How do I prevent people from breaking my portal?
* A: Use an anti-grief plugin.
## FAQ


Changes
-------

* Q: How do I prevent people from breaking my portal?
* A: Use an anti-grief plugin or the `mtp.destroy` permission.

## Changes

* 1.3.2 : Bug-fix
* Fixed a very DUMB bug!
* 1.3.1 : More fixes
* Fixed the double teleport issue.
* 1.3.0 : Bug-fix
* Removed `manyworld` dependancy
* Added a base to the portal (so water won't leak)
* Translations: Spanish
* Fixed so that when people Transfer, they do not enter in the
location of the portal.
* 1.2.0 : Simple update
* Renamed to MagicTelePortal
* Renamed to MagicTelePortal.
**YOU MUST UPDATE CONFIG FILES**
* Added `mtp.destroy` permission
* 1.1.0 : Next release
* Support for FastTransfer
* Some configuration options
* 1.0.0 : First submission

Copyright
---------
## Copyright

MagicTelePortal
Copyright (C) 2015 Alejandro Liu
Expand Down
22 changes: 11 additions & 11 deletions plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ load: POSTWORLD

name: MagicTelePortal
description: A simple portal plugin
version: 1.2.0
version: 1.3.2
author: aliuly

commands:
mtp:
description: Create a portal
usage: "/mtp [world|addr:port] [x y z]"
permission: mtp.cmd.mtp
mtp:
description: Create a portal
usage: "/mtp [world|addr:port] [x y z]"
permission: mtp.cmd.mtp

permissions:
mtp.cmd.mtp:
default: op
description: "Allow to create portal"
mtp.destroy:
default: op
description: Allow destruction of portals
mtp.cmd.mtp:
default: op
description: "Allow to create portal"
mtp.destroy:
default: op
description: Allow destruction of portals
19 changes: 19 additions & 0 deletions resources/messages/messages.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; messages.ini
"%1%-mode"=""
"- Player: %1% => %2%:%3%"=""
"Adventure"=""
"Creative"=""
"FAST TRANSFER NOT INSTALLED"=""
"FastTransfer available!"=""
"FastTransfer being used hope it works!"=""
"Invalid target for portal"=""
"Nothing happens!"=""
"Portal broken!"=""
"Somebody removed FastTransfer!"=""
"Spectator"=""
"Survival"=""
"Teleporting..."=""
"You are not allowed to do that!"=""
"You can only do this in-game"=""
"You do not have permission to do that."=""
"#You can only use this command in-game"=""
18 changes: 18 additions & 0 deletions resources/messages/spa.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
; spa.ini
"%1%-mode"="Modo-%1%"
"- Player: %1% => %2%:%3%"="- Jugador: %1% => %2%:%3%"
"Adventure"="Aventura"
"Creative"="Creativo"
"FAST TRANSFER NOT INSTALLED"="FAST TRANSFER NO DISPONIBLE"
"FastTransfer available!"="FastTransfer disponible!"
"FastTransfer being used hope it works!"="Usando FastTransfer, espero que funcione!"
"Invalid target for portal"="Destino del portal no es reconocido"
"Nothing happens!"="No pasa nada!"
"Portal broken!"="Portal roto!"
"Somebody removed FastTransfer!"="Alguien borró FastTransfer"
"Spectator"="Espectador"
"Survival"="Supervivencia"
"Teleporting..."="Teletransportando..."
"You are not allowed to do that!"="No puedes hacer eso!"
"You can only do this in-game"="Solo se puede hacer esto dentro del juego"
"You do not have permission to do that."="No tienes permiso para hacer eso."
105 changes: 70 additions & 35 deletions src/aliuly/mtp/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,33 @@
use pocketmine\level\Position;
use pocketmine\utils\Config;
use pocketmine\event\player\PlayerMoveEvent;
use pocketmine\event\player\PlayerQuitEvent;
use pocketmine\event\block\BlockBreakEvent;
use pocketmine\event\block\BlockPlaceEvent;

use aliuly\mtp\common\mc;
use aliuly\mtp\common\MPMU;
use aliuly\mtp\common\PluginCallbackTask;

class Main extends PluginBase implements CommandExecutor,Listener {
protected $portals;
protected $max_dist;
protected $border;
protected $center;
protected $corner;

private function inGame(CommandSender $sender,$msg = true) {
if ($sender instanceof Player) return true;
if ($msg) $sender->sendMessage(TextFormat::RED.
"You can only use this command in-game");
return false;
}
protected $tweak;

public function onEnable(){
$this->tweak = [];
if (!is_dir($this->getDataFolder())) mkdir($this->getDataFolder());
mc::plugin_init($this,$this->getFile());
$this->getServer()->getPluginManager()->registerEvents($this, $this);
$defaults = [
"version" => $this->getDescription()->getVersion(),
"max-dist" => 8,
"border" => Block::NETHER_BRICKS,
"center" => Block::STILL_WATER,
"corner" => Block::NETHER_BRICKS_STAIRS,
"broadcast-tp" => false,
];
$cfg = (new Config($this->getDataFolder()."config.yml",
Config::YAML,$defaults))->getAll();
Expand All @@ -52,7 +52,7 @@ public function onEnable(){
$this->portals=(new Config($this->getDataFolder()."portals.yml",
Config::YAML,[]))->getAll();
if ($this->getServer()->getPluginManager()->getPlugin("FastTransfer")){
$this->getLogger()->info(TextFormat::GREEN."FastTransfer available!");
$this->getLogger()->info(TextFormat::GREEN.mc::_("FastTransfer available!"));
}
}
private function checkLevel($w) {
Expand Down Expand Up @@ -139,26 +139,36 @@ protected function buildPortal($center,$dir) {
$back = Block::get($this->corner,2);
}

// Top of the portal
$lv->setBlock(new Vector3($x,$y+4,$z),$border);
$lv->setBlock(new Vector3($x+$x_off,$y+4,$z+$z_off),$border);
$lv->setBlock(new Vector3($x-$x_off,$y+4,$z-$z_off),$border);
$lv->setBlock(new Vector3($x+$x_off*2,$y+4,$z+$z_off*2),$corner1);
$lv->setBlock(new Vector3($x-$x_off*2,$y+4,$z-$z_off*2),$corner2);

// Bottom of it (This makes sure the water doesn't leak...)
$lv->setBlock(new Vector3($x,$y-1,$z),$border);
$lv->setBlock(new Vector3($x+$x_off,$y-1,$z+$z_off),$border);
$lv->setBlock(new Vector3($x-$x_off,$y-1,$z-$z_off),$border);

// Base of the portal (rounded corners)
$lv->setBlock(new Vector3($x+$x_off*2,$y,$z+$z_off*2),$corner3);
$lv->setBlock(new Vector3($x-$x_off*2,$y,$z-$z_off*2),$corner4);
$lv->setBlock(new Vector3($x,$y,$z),$center);
$lv->setBlock(new Vector3($x+$x_off,$y,$z+$z_off),$center);
$lv->setBlock(new Vector3($x-$x_off,$y,$z-$z_off),$center);

// Base of the portal (front steps)
$lv->setBlock(new Vector3($x+$mx_off,$y,$z+$mz_off),$front);
$lv->setBlock(new Vector3($x+$mx_off+$x_off,$y,$z+$mz_off+$z_off),$front);
$lv->setBlock(new Vector3($x+$mx_off-$x_off,$y,$z+$mz_off-$z_off),$front);

// Base of the portal (back steps)
$lv->setBlock(new Vector3($x-$mx_off,$y,$z-$mz_off),$back);
$lv->setBlock(new Vector3($x-$mx_off+$x_off,$y,$z-$mz_off+$z_off),$back);
$lv->setBlock(new Vector3($x-$mx_off-$x_off,$y,$z-$mz_off-$z_off),$back);

// Middle of the portal (side column and center water)
for ($i=1;$i<=3;++$i) {
$lv->setBlock(new Vector3($x-$x_off*2,$y+$i,$z-$z_off*2),$border);
$lv->setBlock(new Vector3($x+$x_off*2,$y+$i,$z+$z_off*2),$border);
Expand All @@ -182,10 +192,11 @@ protected function saveCfg() {
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) {
switch($cmd->getName()) {
case "mtp":
if (!$this->inGame($sender)) return true;
if (!MPMU::inGame($sender)) return true;

$dest = $this->checkTarget($args);
if (!$dest) {
$sender->sendMessage(TextFormat::RED."Invalid target for portal");
$sender->sendMessage(TextFormat::RED.mc::_("Invalid target for portal"));
return true;
}
$bl = $this->targetPos($sender,$sender->getDirectionVector());
Expand All @@ -198,6 +209,10 @@ public function onCommand(CommandSender $sender, Command $cmd, $label, array $ar
}
return false;
}
public function onQuit(PlayerQuitEvent $ev) {
$n = strtolower($ev->getPlayer()->getName());
if (isset($this->tweak[$n])) unset($this->tweak[$n]);
}

public function onMove(PlayerMoveEvent $ev) {
if ($ev->isCancelled()) return;
Expand All @@ -218,35 +233,55 @@ public function onMove(PlayerMoveEvent $ev) {

$dest = $this->checkTarget($target);
if (!$dest) {
$pl->sendMessage("Nothing happens!");
$pl->sendMessage(mc::_("Nothing happens!"));
return;
}
if ($dest instanceof Vector3) {
$pl->sendMessage("Teleporting...");
if (($mw = $this->getServer()->getPluginManager()->getPlugin("ManyWorlds")) != null) {
$mw->mwtp($pl,$dest);
} else {
$pl->teleport($dest);
}
return;
$n = strtolower($pl->getName());
$now = time();
if (isset($this->tweak[$n])) {
// Already in here...
if ($this->tweak[$n][0] > $now) return;
}
// If it is not a position
$ft = $this->getServer()->getPluginManager()->getPlugin("FastTransfer");
if (!$ft) {
$this->getLogger()->info(TextFormat::RED."FAST TRANSFER NOT INSTALLED");
$pl->sendMessage("Nothing happens!");
$pl->sendMessage(TextFormat::RED."Somebody removed FastTransfer!");
return;
}
list($addr,$port) = $dest;
$this->getLogger()->info(TextFormat::RED."FastTransfer being used hope it works!");
$this->getLogger()->info("- Player: ".$pl->getName()." => ".
$addr.":".$port);
$ft->transferPlayer($pl,$addr,$port);
$this->tweak[$n] = [ $now + 3, $dest ];
$this->getServer()->getScheduler()->scheduleDelayedTask(
new PluginCallbackTask($this,[$this,"portalActiveSg1"],[$n]),
1);
return;
}
}
}
public function portalActiveSg1($n) {
if (!isset($this->tweak[$n])) return;
$pl = $this->getServer()->getPlayer($n);
if ($pl === null) return;
list(,$dest) = $this->tweak[$n];
unset($this->tweak[$n]);
if ($dest instanceof Vector3) {
$pl->sendMessage(mc::_("Teleporting..."));
$pl->teleport($dest);
return;
}
// If it is not a position... It is a FAST TRANSFER!

$ft = $this->getServer()->getPluginManager()->getPlugin("FastTransfer");
if (!$ft) {
$this->getLogger()->error(TextFormat::RED.mc::_("FAST TRANSFER NOT INSTALLED"));
$pl->sendMessage(mc::_("Nothing happens!"));
$pl->sendMessage(TextFormat::RED.mc::_("Somebody removed FastTransfer!"));
return;
}
// First we teleport to spawn to make sure that we do not enter
// this server in the portal location!
$spawn = $pl->getLevel()->getSafeSpawn();
$pl->teleport($spawn);

list($addr,$port) = $dest;
$this->getLogger()->info(TextFormat::RED.mc::_("FastTransfer being used hope it works!"));
$this->getLogger()->info(mc::_("- Player: %1% => %2%:%3%",
$pl->getName(),$addr,$port));

$ft->transferPlayer($pl,$addr,$port);
}

/**
* @priority HIGH
Expand All @@ -271,7 +306,7 @@ public function onBlockBreak(BlockBreakEvent $ev){
$pl = $ev->getPlayer();
if (($pl instanceof Player) && !$pl->hasPermission("mtp.destroy")) {
$ev->setCancelled();
$pl->sendMessage("You are not allowed to do that!");
$pl->sendMessage(mc::_("You are not allowed to do that!"));
return;
}
$air = Block::get(Block::AIR);
Expand All @@ -282,7 +317,7 @@ public function onBlockBreak(BlockBreakEvent $ev){
}
}
}
$pl->sendMessage("Portal broken!");
$pl->sendMessage(mc::_("Portal broken!"));
unset($this->portals[$world][$i]);
$this->saveCfg();
return;
Expand Down
Loading

0 comments on commit ce7d28d

Please sign in to comment.