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

Commit

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

* Summary: Easy to use Portal plugin
* Dependency Plugins: N/A
Expand Down Expand Up @@ -56,22 +55,22 @@ broadcast-tp: true

### Permission Nodes:

* metooportal.cmd.mtp: Permission to create portals
* 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.

Todo
----

* Add broadcast-tp option.

Changes
-------

* 1.2.0 : Simple update
* Renamed to MagicTelePortal
* Added `mtp.destroy` permission
* 1.1.0 : Next release
* Support for FastTransfer
* Some configuration options
Expand All @@ -80,7 +79,7 @@ Changes
Copyright
---------

MeTooPortal
MagicTelePortal
Copyright (C) 2015 Alejandro Liu
All Rights Reserved.

Expand Down
13 changes: 8 additions & 5 deletions plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ main: aliuly\mtp\Main
api: 1.10.0
load: POSTWORLD

name: MeTooPortal
description: Yet another portal plugin
version: 1.1.0
name: MagicTelePortal
description: A simple portal plugin
version: 1.2.0
author: aliuly

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

permissions:
metooportal.cmd.mtp:
mtp.cmd.mtp:
default: op
description: "Allow to create portal"
mtp.destroy:
default: op
description: Allow destruction of portals
11 changes: 10 additions & 1 deletion src/aliuly/mtp/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function onEnable(){
if (!is_dir($this->getDataFolder())) mkdir($this->getDataFolder());
$this->getServer()->getPluginManager()->registerEvents($this, $this);
$defaults = [
"version" => $this->getDescription()->getVersion(),
"max-dist" => 8,
"border" => Block::NETHER_BRICKS,
"center" => Block::STILL_WATER,
Expand Down Expand Up @@ -247,6 +248,9 @@ public function onMove(PlayerMoveEvent $ev) {
}
}

/**
* @priority HIGH
*/
public function onBlockBreak(BlockBreakEvent $ev){
if ($ev->isCancelled()) return;
$bl = $ev->getBlock();
Expand All @@ -264,6 +268,12 @@ public function onBlockBreak(BlockBreakEvent $ev){
if ($bb2[0] <= $x && $bb2[1] <= $y && $bb2[2] <= $z &&
$x <= $bb2[3] && $y <= $bb2[4] && $z <= $bb2[5]) {
// Breaking a portal!
$pl = $ev->getPlayer();
if (($pl instanceof Player) && !$pl->hasPermission("mtp.destroy")) {
$ev->setCancelled();
$pl->sendMessage("You are not allowed to do that!");
return;
}
$air = Block::get(Block::AIR);
for($bx=$bb1[0];$bx<$bb1[3];$bx++) {
for($by=$bb1[1];$by<$bb1[4];$by++) {
Expand All @@ -272,7 +282,6 @@ public function onBlockBreak(BlockBreakEvent $ev){
}
}
}
$pl = $ev->getPlayer();
$pl->sendMessage("Portal broken!");
unset($this->portals[$world][$i]);
$this->saveCfg();
Expand Down

0 comments on commit a3b6de0

Please sign in to comment.