This site works best with JavaScript enabled. Please enable JavaScript to get the best experience from this site.
Wondering if you can add a method to get the percentage of the current genning world; or make the plugin have a configurable option to set worldborder generation broadcasting in chat, and not to just the individual, thanks a lot!
You can monitor the WorldBorderFillStartEvent (located under com.wimbli.WorldBorder.Events), and use the getFillTask() method of that event, which will return the newly started WorldFillTask. With the WorldFillTask, you can check the getPercentageCompleted() method to find what you want to know.
So, an example plugin (untested, but should work):
package com.MyFillMonitor; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; import com.wimbli.WorldBorder.Events.WorldBorderFillStartEvent; import com.wimbli.WorldBorder.WorldFillTask; public final class FillMonitorPlugin extends JavaPlugin { @Override public void onEnable() { getServer().getPluginManager().registerEvents(new FillListener(this), this); } } class FillListener implements Listener { private final JavaPlugin plugin; private final int repeatTicks = 100; // 100 ticks = 5 seconds public FillListener(JavaPlugin plugin) { this.plugin = plugin; } @EventHandler(priority = EventPriority.LOWEST) public void onFillStart(WorldBorderFillStartEvent event) { BukkitTask task = new FillMonitorTask(event.getFillTask()).runTaskTimer(this.plugin, 1, repeatTicks); } } class FillMonitorTask extends BukkitRunnable { private final WorldFillTask fillTask; public FillMonitorTask(WorldFillTask task) { this.fillTask = task; } @Override public void run() { if (fillTask == null || !fillTask.valid()) { Bukkit.getServer().broadcastMessage("World Fill has ended!"); this.cancel(); return; } Bukkit.getServer().broadcastMessage("World Fill is at " + String.format("%.2f", fillTask.getPercentageCompleted()) + "%"); } }
To post a comment, please login or register a new account.