Skip to content

Commit

Permalink
added silent join/leave
Browse files Browse the repository at this point in the history
note this feature is only compatible with default join/leave messages
  • Loading branch information
sqrrrrl committed Jul 12, 2021
1 parent a7f0bbb commit 4cfe0a9
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
3 changes: 3 additions & 0 deletions plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ permissions:
vanish.see:
description: "Permission to see vanished players"
default: op
vanish.silent:
description: "Permission to silently join the server"
default: op
14 changes: 11 additions & 3 deletions resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@


# Do not change this!
config-version: 4
config-version: 5

# The message that will be sent to online players when you turn on your vanish
# The message that will be sent to online players when you turn on vanish
enable-leave: false
FakeLeave-message: "§e%name left the game"

# The message that will be sent to online players when you turn off your vanish
# The message that will be sent to online players when you turn off vanish
enable-join: false
FakeJoin-message: "§e%name joined the game"

Expand Down Expand Up @@ -60,4 +60,12 @@ silent-chest: true

# Choose if vanished players should lose hunger
hunger: false

# Choose if the join/leave message should appear when a player with the permission vanish.silent joins the server
# (Only compatible with default join/leave message)
silent-join-leave:
join: true
leave: true
#Choose if this should only apply to players who are already vanished
vanished-only: true
...
28 changes: 28 additions & 0 deletions src/superbobby/VanishV2/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,32 @@ public function onInteract(PlayerInteractEvent $event) {
}
}
}

public function silentJoin(PlayerJoinEvent $event) {
if ($event->getPlayer()->hasPermission("vanish.silent")) {
if ($this->plugin->getConfig()->get("silent-join-leave")["join"]) {
if (!$this->plugin->getConfig()->get("silent-join-leave")["vanished-only"]) {
$event->setJoinMessage(null);
}else{
if (in_array($event->getPlayer()->getName(), VanishV2::$vanish)){
$event->setJoinMessage(null);
}
}
}
}
}

public function silentLeave(PlayerQuitEvent $event) {
if ($event->getPlayer()->hasPermission("vanish.silent")) {
if ($this->plugin->getConfig()->get("silent-join-leave")["leave"]) {
if (!$this->plugin->getConfig()->get("silent-join-leave")["vanished-only"]) {
$event->setQuitMessage(null);
}else{
if (in_array($event->getPlayer()->getName(), VanishV2::$vanish)){
$event->setQuitMessage(null);
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/superbobby/VanishV2/VanishV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function onEnable() {
$this->getLogger()->error("InvMenu virion not found download VanishV2 on poggit or download InvMenu with DEVirion (not recommended)");
$this->getServer()->getPluginManager()->disablePlugin($this);
}
if ($this->getConfig()->get("config-version") < 4 or $this->getConfig()->get("config-version") == null) {
if ($this->getConfig()->get("config-version") < 5 or $this->getConfig()->get("config-version") == null) {
$this->getLogger()->error("Your configuration file is outdated you have to delete it to get the new config");
$this->getServer()->getPluginManager()->disablePlugin($this);
}
Expand Down

0 comments on commit 4cfe0a9

Please sign in to comment.