mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +01:00
Get rid of one-line separate class tasks
This commit is contained in:
parent
a526822c6e
commit
420b880c63
@ -26,6 +26,7 @@ import java.util.UUID;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
* DGlobalPlayer instance manager.
|
||||
@ -49,8 +50,19 @@ public class DPlayerCache {
|
||||
if (config.isSecureModeEnabled()) {
|
||||
new SecureModeTask(plugin).runTaskTimer(plugin, config.getSecureModeCheckInterval(), config.getSecureModeCheckInterval());
|
||||
}
|
||||
new UpdateTask(plugin).runTaskTimer(plugin, 2L, 2L);
|
||||
new LazyUpdateTask(plugin).runTaskTimer(plugin, 20L, 20L);
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getDPlayerCache().getDGamePlayers().forEach(p -> p.update(false));
|
||||
}
|
||||
}.runTaskTimer(plugin, 2L, 2L);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getDPlayerCache().getDGamePlayers().forEach(p -> p.update(true));
|
||||
}
|
||||
}.runTaskTimer(plugin, 20L, 20L);
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new DPlayerListener(plugin), plugin);
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2019 Frank Baumann
|
||||
*
|
||||
* 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 3 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/>.
|
||||
*/
|
||||
package de.erethon.dungeonsxl.player;
|
||||
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class LazyUpdateTask extends BukkitRunnable {
|
||||
|
||||
private DungeonsXL plugin;
|
||||
|
||||
public LazyUpdateTask(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (DGamePlayer dPlayer : plugin.getDPlayerCache().getDGamePlayers()) {
|
||||
dPlayer.update(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2019 Frank Baumann
|
||||
*
|
||||
* 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 3 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/>.
|
||||
*/
|
||||
package de.erethon.dungeonsxl.player;
|
||||
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
* @author Frank Baumann, Daniel Saukel
|
||||
*/
|
||||
public class UpdateTask extends BukkitRunnable {
|
||||
|
||||
private DungeonsXL plugin;
|
||||
|
||||
public UpdateTask(DungeonsXL plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (DInstancePlayer dPlayer : plugin.getDPlayerCache().getDInstancePlayers()) {
|
||||
dPlayer.update(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,6 @@
|
||||
package de.erethon.dungeonsxl.sign.lobby;
|
||||
|
||||
import de.erethon.caliburn.item.VanillaItem;
|
||||
import de.erethon.commons.chat.MessageUtil;
|
||||
import de.erethon.commons.misc.NumberUtil;
|
||||
import de.erethon.dungeonsxl.DungeonsXL;
|
||||
import de.erethon.dungeonsxl.config.DMessage;
|
||||
|
@ -197,7 +197,7 @@ public class DResourceWorld {
|
||||
* @param game whether the instance is a DGameWorld
|
||||
* @return an instance of this world
|
||||
*/
|
||||
public DInstanceWorld instantiate(final boolean game) {
|
||||
public DInstanceWorld instantiate(boolean game) {
|
||||
int id = worlds.generateId();
|
||||
String name = worlds.generateName(game, id);
|
||||
|
||||
@ -223,7 +223,7 @@ public class DResourceWorld {
|
||||
|
||||
FileUtil.copyDir(folder, instanceFolder, DungeonsXL.EXCLUDED_FILES);
|
||||
instance.world = Bukkit.createWorld(WorldCreator.name(name).environment(getWorldEnvironment()));
|
||||
if (Bukkit.getPluginManager().getPlugin("dynmap") != null) {
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("dynmap")) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "dynmap pause all");
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "dmap worldset " + name + " enabled:false");
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "dynmap pause none");
|
||||
|
@ -29,7 +29,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
/**
|
||||
* World instance manager.
|
||||
@ -252,8 +251,7 @@ public class DWorldCache {
|
||||
*/
|
||||
public void deleteAllInstances() {
|
||||
BackupMode backupMode = config.getBackupMode();
|
||||
HashSet<DInstanceWorld> instances = new HashSet<>(this.instances);
|
||||
for (DInstanceWorld instance : instances) {
|
||||
for (DInstanceWorld instance : instances.toArray(new DInstanceWorld[instances.size()])) {
|
||||
if (backupMode == BackupMode.ON_DISABLE | backupMode == BackupMode.ON_DISABLE_AND_SAVE && instance instanceof DEditWorld) {
|
||||
instance.getResource().backup();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user