-
Notifications
You must be signed in to change notification settings - Fork 0
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
arboriginal
committed
Dec 3, 2018
0 parents
commit 0eb4307
Showing
3 changed files
with
106 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,18 @@ | ||
# WBFillPause | ||
|
||
WBFillPause is a small plugin for [Spigot](https://www.spigotmc.org) Minecraft servers. It simply pause [WorldBorder's fill command](https://www.spigotmc.org/threads/worldborder.339635/#post-3162182) when a player join the server, then resume when nobody is online. | ||
|
||
## How to install | ||
|
||
Simply drop the jar file into your plugin directory, then restart (or reload) your server. | ||
|
||
You can download the last release here: [WBFillPause.jar](https://github.com/arboriginal/WBFillPause/releases). | ||
|
||
## Permissions | ||
|
||
- **wbfp.bypass**: Players with this permission will not pause the fill command. | ||
(default: op) | ||
|
||
## Note | ||
|
||
The fill command doesn't resume immediately when the player disconnect, but after 15 seconds. It prevent to re-launch the process if the player had a short connection loss. |
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,67 @@ | ||
package me.arboriginal.WBFillPause; | ||
|
||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.HandlerList; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerJoinEvent; | ||
import org.bukkit.event.player.PlayerQuitEvent; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
import org.bukkit.scheduler.BukkitRunnable; | ||
import com.wimbli.WorldBorder.Config; | ||
|
||
public class Main extends JavaPlugin implements Listener { | ||
public static BukkitRunnable task; | ||
|
||
@Override | ||
public void onEnable() { | ||
getServer().getPluginManager().registerEvents(this, this); | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
super.onDisable(); | ||
|
||
HandlerList.unregisterAll((JavaPlugin) this); | ||
} | ||
|
||
@EventHandler | ||
public void onPlayerJoin(PlayerJoinEvent event) { | ||
if (playerBypass(event.getPlayer())) return; | ||
|
||
if (WBFill(false)) { | ||
Config.fillTask.pause(); | ||
getLogger().info("================== WorldBorder fill => Pause =================="); | ||
} | ||
} | ||
|
||
@EventHandler | ||
public void onPlayerQuit(PlayerQuitEvent event) { | ||
if (WBFill(true)) { | ||
if (task != null) task.cancel(); | ||
|
||
task = new BukkitRunnable() { | ||
@Override | ||
public void run() { | ||
for (Player player : getServer().getOnlinePlayers()) { | ||
if (!playerBypass(player)) return; | ||
} | ||
|
||
Config.fillTask.pause(false); | ||
getLogger().info("================== WorldBorder fill => Resume =================="); | ||
task = null; | ||
} | ||
}; | ||
|
||
task.runTaskLater(this, 300); | ||
} | ||
} | ||
|
||
private boolean playerBypass(Player player) { | ||
return player.hasPermission("wbfp.bypass"); | ||
} | ||
|
||
private boolean WBFill(boolean paused) { | ||
return ((Config.fillTask != null) && Config.fillTask.valid() && (Config.fillTask.isPaused() == paused)); | ||
} | ||
} |
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,21 @@ | ||
name: WBFillPause | ||
description: Suspend your Worlborder fill command when a player join. | ||
version: 0.1 | ||
|
||
author: arboriginal | ||
website: https://github.com/arboriginal | ||
dev-url: https://github.com/arboriginal/WBFillPause | ||
|
||
depend: [ WorldBorder ] | ||
softdepend: [ ] | ||
|
||
api-version: 1.13 | ||
database: false | ||
|
||
main: me.arboriginal.WBFillPause.Main | ||
|
||
permissions: | ||
wbfp.bypass: | ||
description: DO NOT pause the worldborder fill on join. | ||
default: op | ||
|