This repository has been archived by the owner on Jul 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e53ba5
commit 7d6f692
Showing
4 changed files
with
261 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<img src="https://raw.githubusercontent.com/alejandroliu/bad-plugins/master/Media/floatchat.jpg" style="width:64px;height:64px" width="64" height="64"/> | ||
|
||
# FloatChat | ||
|
||
* Summary: Float chat messages | ||
* PocketMine-MP version: 1.5 - API 1.12.0 | ||
* DependencyPlugins: - | ||
* OptionalPlugins: - | ||
* Categories: Chat, Fun, Mechanics | ||
* Plugin Access: Entities | ||
This comment has been minimized.
Sorry, something went wrong. |
||
* WebSite: [github](https://github.com/alejandroliu/pocketmine-plugins/tree/master/LocalChat) | ||
|
||
Overview | ||
-------- | ||
|
||
Make chats to appear in text above the player. | ||
If you want to broadcast a message to all players in the Level use: | ||
|
||
.text | ||
|
||
While if you want to broacast a message to all players in the Server | ||
use: | ||
|
||
:text | ||
|
||
|
||
Documentation | ||
------------- | ||
|
||
By prefixing your text with a "." to a message you can *shout* your | ||
message to everybody in the same level. | ||
|
||
By prefixing your text with a ":" to a message you can *broadcast* | ||
your message to everybody in the same server. | ||
|
||
|
||
### Permission Nodes: | ||
|
||
* floatchat.brodcast: Allow access to `.` and `:` to broadcast messages. | ||
* floatchat.brodcast.level: Allow access to `.` messages | ||
* floatchat.brodcast.server: Allow access to `:` messages | ||
* floatchat.spy: Users with this permission are always able to hear | ||
all messages. | ||
|
||
### TODO | ||
|
||
|
||
Changes | ||
------- | ||
|
||
* 1.0.0 : First public release | ||
|
||
Copyright | ||
--------- | ||
|
||
FloatChat | ||
Copyright (C) 2015 Alejandro Liu | ||
All Rights Reserved. | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 2 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: FloatChat | ||
version: 0.1.0 | ||
main: aliuly\floatchat\Main | ||
api: 1.12.0 | ||
load: POSTWORLD | ||
|
||
description: Float chat messages | ||
author: aliuly | ||
|
||
permissions: | ||
floatchat.broadcast: | ||
default: true | ||
description: "Give players the ability to broadcast messages" | ||
floatchat.broadcast.server: | ||
default: op | ||
description: "Broadcast to the server" | ||
floatchat.broadcast.level: | ||
default: true | ||
description: "Broadcast to the level" | ||
floatchat.spy: | ||
default: true | ||
description: "Grant players the ability to spy on players" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
<?php | ||
namespace aliuly\floatchat; | ||
|
||
use pocketmine\plugin\PluginBase; | ||
use pocketmine\Player; | ||
use pocketmine\event\Listener; | ||
use pocketmine\event\player\PlayerChatEvent; | ||
use pocketmine\event\player\PlayerQuitEvent; | ||
use pocketmine\event\player\PlayerMoveEvent; | ||
use pocketmine\event\entity\EntityTeleportEvent; | ||
use pocketmine\utils\Config; | ||
use pocketmine\utils\TextFormat; | ||
use pocketmine\command\CommandSender; | ||
|
||
use pocketmine\level\particle\FloatingTextParticle; | ||
use pocketmine\math\Vector3; | ||
|
||
use pocketmine\scheduler\PluginTask; | ||
|
||
class cleanUpTask extends PluginTask { | ||
public function onRun($currentTick){ | ||
if ($this->owner->isDisabled()) return; | ||
$this->owner->timerTick(); | ||
} | ||
} | ||
|
||
|
||
class Main extends PluginBase implements Listener { | ||
protected $particles; | ||
protected $timeout = 5; | ||
|
||
protected static function iName($player) { | ||
return strtolower($player->getName()); | ||
} | ||
|
||
// Access and other permission related checks | ||
private function access(CommandSender $sender, $permission) { | ||
if($sender->hasPermission($permission)) return true; | ||
$sender->sendMessage("You do not have permission to do that."); | ||
return false; | ||
} | ||
////////////////////////////////////////////////////////////////////// | ||
// | ||
// Standard call-backs | ||
// | ||
////////////////////////////////////////////////////////////////////// | ||
public function onEnable(){ | ||
//if (!is_dir($this->getDataFolder())) mkdir($this->getDataFolder()); | ||
$this->getServer()->getPluginManager()->registerEvents($this, $this); | ||
$this->particles = []; | ||
$this->getServer()->getScheduler()->scheduleRepeatingTask(new cleanUpTask($this),20); | ||
|
||
} | ||
|
||
protected function deSpawn($particle,$level) { | ||
if ($level === null) return; | ||
$particle->setInvisible(); | ||
$level->addParticle($particle); | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// | ||
// Event handlers | ||
// | ||
////////////////////////////////////////////////////////////////////// | ||
public function timerTick() { | ||
$now = time(); | ||
foreach (array_keys($this->particles) as $n) { | ||
list($particle,$level,$expby,) = $this->particles[$n]; | ||
if ($level !== null && $now > $expby) { | ||
$this->deSpawn($particle,$level); | ||
$this->particles[$n][1] = null; | ||
} | ||
} | ||
} | ||
|
||
public function onQuit(PlayerQuitEvent $e){ | ||
$n = self::iName($e->getPlayer()); | ||
if (isset($this->particles[$n])) { | ||
list($p,$level,,) = $this->particles[$n]; | ||
unset($this->particles[$n]); | ||
$this->deSpawn($p,$level); | ||
} | ||
} | ||
|
||
public function onMove(PlayerMoveEvent $e) { | ||
$n = self::iName($e->getPlayer()); | ||
if (!isset($this->particles[$n])) return; | ||
list($p,$level,,) = $this->particles[$n]; | ||
if ($level === null) return; | ||
$pw = $e->getPlayer(); | ||
$p->x = $pw->getX(); | ||
$p->y = $pw->getY()+2+count($this->particles[$n][3])*0.5; | ||
$p->z = $pw->getZ(); | ||
$pw->getLevel()->addParticle($p); | ||
} | ||
|
||
public function onChat(PlayerChatEvent $e){ | ||
if ($e->isCancelled()) return; | ||
$pw = $e->getPlayer(); | ||
// Non players are handled normally | ||
if (!($pw instanceof Player)) return; | ||
|
||
$msg = $e->getMessage(); | ||
if (substr($msg,0,1) == ":") { | ||
// This messages goes to everybody on the server... | ||
// no need to do much... | ||
if (!$this->access($pw,"floatchat.broadcast.server")) { | ||
$e->setCancelled(); | ||
return; | ||
} | ||
$e->setMessage(substr($msg,1)); | ||
return; | ||
} | ||
if (substr($msg,0,1) == ".") { | ||
$target = []; | ||
if (!$this->access($pw,"floatchat.broadcast.level")) { | ||
$e->setCancelled(); | ||
return; | ||
} | ||
// Send this message to everybody on this level | ||
$e->setMessage(substr($msg,1)); | ||
foreach ($e->getRecipients() as $pr) { | ||
if ($pr instanceof Player) { | ||
if (!$pr->hasPermission("floatchat.spy") && | ||
$pr->getLevel() != $pw->getLevel()) continue; | ||
} | ||
$target[] = $pr; | ||
} | ||
$e->setRecipients($target); | ||
return; | ||
} | ||
$target = []; | ||
foreach ($e->getRecipients() as $pr) { | ||
if ($pr instanceof Player) { | ||
if (!$pr->hasPermission("floatchat.spy") && $pr != $pw) continue; | ||
} | ||
$target[] = $pr; | ||
} | ||
$e->setRecipients($target); | ||
echo __METHOD__.",".__LINE__."\n";//##DEBUG | ||
|
||
$n = self::iName($pw); | ||
if (!isset($this->particles[$n])) | ||
$this->particles[$n] = [new FloatingTextParticle($pw,""), null, 0, ""]; | ||
|
||
$p = $this->particles[$n][0]; | ||
$msg = $e->getMessage(); | ||
if ($p->isInvisible()) { | ||
$this->particles[$n][3] = [ $msg ]; | ||
$p->setText(TextFormat::YELLOW.$msg); | ||
$p->setInvisible(false); | ||
} else { | ||
$this->particles[$n][3][] = $msg; | ||
while (count($this->particles[$n][3]) > 3) { | ||
array_shift($this->particles[$n][3]); | ||
} | ||
$p->setText(TextFormat::YELLOW.implode("\n",$this->particles[$n][3])); | ||
} | ||
$p->x = $pw->getX(); | ||
$p->y = $pw->getY()+2+count($this->particles[$n][3])*0.5; | ||
$p->z = $pw->getZ(); | ||
$this->particles[$n][1] = $pw->getLevel(); | ||
$this->particles[$n][2] = time()+$this->timeout; | ||
|
||
$pw->getLevel()->addParticle($p); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 comment
on commit 7d6f692
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could You tell me the op comand
Lol