mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-01 08:09:39 +01:00
Use BukkitRunnable.
This commit is contained in:
parent
c3a69c8c55
commit
399bf8e3b9
@ -46,6 +46,6 @@ public class MmoupdateCommand implements CommandExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getScheduler().runTaskLaterAsynchronously(mcMMO.p, new SQLConversionTask(), 1);
|
||||
new SQLConversionTask().runTaskLaterAsynchronously(mcMMO.p, 1);
|
||||
}
|
||||
}
|
||||
|
@ -104,6 +104,6 @@ public class McrankCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void sqlDisplay(CommandSender sender, String playerName) {
|
||||
mcMMO.p.getServer().getScheduler().runTaskAsynchronously(mcMMO.p, new McrankCommandAsyncTask(playerName, sender));
|
||||
new McrankCommandAsyncTask(playerName, sender).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public class MctopCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void sqlDisplay(int page, String query, CommandSender sender) {
|
||||
mcMMO.p.getServer().getScheduler().runTaskAsynchronously(mcMMO.p, new MctopCommandAsyncTask(page, query, sender));
|
||||
new MctopCommandAsyncTask(page, query, sender).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
|
||||
private boolean extractSkill(CommandSender sender, String skillName) {
|
||||
|
@ -336,7 +336,7 @@ public final class DatabaseManager {
|
||||
if (connection != null && !connection.isClosed()) {
|
||||
// Schedule a database save if we really had an outage
|
||||
if (reconnectAttempt > 1) {
|
||||
mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new SQLReconnectTask(), 5);
|
||||
new SQLReconnectTask().runTaskLater(mcMMO.p, 5);
|
||||
}
|
||||
nextReconnectTimestamp = 0;
|
||||
reconnectAttempt = 0;
|
||||
|
@ -88,7 +88,7 @@ public class BlockListener implements Listener {
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
if (event.isSticky()) {
|
||||
// Needed only because under some circumstances Minecraft doesn't move the block
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, new StickyPistonTrackerTask(event), 2);
|
||||
new StickyPistonTrackerTask(event).runTaskLater(plugin, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
@ -402,42 +401,44 @@ public class mcMMO extends JavaPlugin {
|
||||
}
|
||||
|
||||
private void scheduleTasks() {
|
||||
BukkitScheduler scheduler = getServer().getScheduler();
|
||||
|
||||
// Parties are loaded at the end of first server tick otherwise Server.getOfflinePlayer throws an IndexOutOfBoundsException
|
||||
scheduler.runTaskLater(this, new PartyLoaderTask(), 0);
|
||||
new PartyLoaderTask().runTaskLater(this, 0);
|
||||
|
||||
// Periodic save timer (Saves every 10 minutes by default)
|
||||
long saveIntervalTicks = Config.getInstance().getSaveInterval() * 1200;
|
||||
|
||||
scheduler.runTaskTimer(this, new SaveTimerTask(), saveIntervalTicks, saveIntervalTicks);
|
||||
new SaveTimerTask().runTaskTimer(this, saveIntervalTicks, saveIntervalTicks);
|
||||
|
||||
// Regen & Cooldown timer (Runs every second)
|
||||
scheduler.runTaskTimer(this, new SkillMonitorTask(), 20, 20);
|
||||
new SkillMonitorTask().runTaskTimer(this, 20, 20);
|
||||
|
||||
// Bleed timer (Runs every two seconds)
|
||||
scheduler.runTaskTimer(this, new BleedTimerTask(), 40, 40);
|
||||
new BleedTimerTask().runTaskTimer(this, 40, 40);
|
||||
|
||||
// Old & Powerless User remover
|
||||
int purgeInterval = Config.getInstance().getPurgeInterval();
|
||||
UserPurgeTask userPurgeTask = new UserPurgeTask();
|
||||
|
||||
if (purgeInterval == 0) {
|
||||
scheduler.runTaskLater(this, new UserPurgeTask(), 40); // Start 2 seconds after startup.
|
||||
userPurgeTask.runTaskLater(this, 40);
|
||||
}
|
||||
else if (purgeInterval > 0) {
|
||||
long purgeIntervalTicks = purgeInterval * 60 * 60 * 20;
|
||||
|
||||
scheduler.runTaskTimer(this, new UserPurgeTask(), purgeIntervalTicks, purgeIntervalTicks);
|
||||
userPurgeTask.runTaskTimer(this, purgeIntervalTicks, purgeIntervalTicks);
|
||||
}
|
||||
|
||||
// Automatically remove old members from parties
|
||||
long kickInterval = Config.getInstance().getAutoPartyKickInterval();
|
||||
PartyAutoKickTask partyAutoKickTask = new PartyAutoKickTask();
|
||||
|
||||
if (kickInterval == 0) {
|
||||
scheduler.runTaskLater(this, new PartyAutoKickTask(), 40); // Start 2 seconds after startup.
|
||||
partyAutoKickTask.runTaskLater(this, 40); // Start 2 seconds after startup.
|
||||
}
|
||||
else if (kickInterval > 0) {
|
||||
long kickIntervalTicks = kickInterval * 60 * 60 * 20;
|
||||
|
||||
scheduler.runTaskTimer(this, new PartyAutoKickTask(), kickIntervalTicks, kickIntervalTicks);
|
||||
partyAutoKickTask.runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
@ -8,15 +8,14 @@ import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class SaveTimerTask implements Runnable {
|
||||
public class SaveTimerTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
// All player data will be saved periodically through this
|
||||
int count = 1;
|
||||
BukkitScheduler bukkitScheduler = mcMMO.p.getServer().getScheduler();
|
||||
|
||||
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers().values()) {
|
||||
bukkitScheduler.runTaskLater(mcMMO.p, new PlayerProfileSaveTask(mcMMOPlayer), count);
|
||||
new PlayerProfileSaveTask(mcMMOPlayer).runTaskLater(mcMMO.p, count);
|
||||
count++;
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,11 @@ package com.gmail.nossr50.runnables;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class StickyPistonTrackerTask implements Runnable {
|
||||
public class StickyPistonTrackerTask extends BukkitRunnable {
|
||||
BlockPistonRetractEvent event;
|
||||
|
||||
public StickyPistonTrackerTask(BlockPistonRetractEvent event) {
|
||||
|
@ -3,16 +3,12 @@ package com.gmail.nossr50.runnables.commands;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class McrankCommandAsyncTask implements Runnable {
|
||||
public class McrankCommandAsyncTask extends BukkitRunnable {
|
||||
private final String playerName;
|
||||
private final CommandSender sender;
|
||||
|
||||
@ -23,35 +19,8 @@ public class McrankCommandAsyncTask implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final Map<String, Integer> skills = DatabaseManager.readSQLRank(playerName);
|
||||
Map<String, Integer> skills = DatabaseManager.readSQLRank(playerName);
|
||||
|
||||
mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
||||
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if ((sender instanceof Player && !Permissions.skillEnabled(sender, skillType)) || skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (skills.get(skillType.name()) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), skills.get(skillType.name())));
|
||||
}
|
||||
}
|
||||
|
||||
if (skills.get("ALL") == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", LocaleLoader.getString("Commands.mcrank.Unranked")));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", skills.get("ALL")));
|
||||
}
|
||||
}
|
||||
|
||||
}, 1L);
|
||||
new McrankCommandDisplayTask(skills, sender, playerName).runTaskLater(mcMMO.p, 1);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,50 @@
|
||||
package com.gmail.nossr50.runnables.commands;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
private final Map<String, Integer> skills;
|
||||
private final CommandSender sender;
|
||||
private final String playerName;
|
||||
|
||||
public McrankCommandDisplayTask(Map<String, Integer> skills, CommandSender sender, String playerName) {
|
||||
this.skills = skills;
|
||||
this.sender = sender;
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
||||
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if ((sender instanceof Player && !Permissions.skillEnabled(sender, skillType)) || skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (skills.get(skillType.name()) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), skills.get(skillType.name())));
|
||||
}
|
||||
}
|
||||
|
||||
if (skills.get("ALL") == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", LocaleLoader.getString("Commands.mcrank.Unranked")));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", skills.get("ALL")));
|
||||
}
|
||||
}
|
||||
}
|
@ -3,16 +3,14 @@ package com.gmail.nossr50.runnables.commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class MctopCommandAsyncTask implements Runnable {
|
||||
public class MctopCommandAsyncTask extends BukkitRunnable {
|
||||
|
||||
private CommandSender sender;
|
||||
private String query;
|
||||
@ -28,30 +26,8 @@ public class MctopCommandAsyncTask implements Runnable {
|
||||
public void run() {
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
final HashMap<Integer, ArrayList<String>> userslist = DatabaseManager.read("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT " + ((page * 10) - 10) + ",10");
|
||||
mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(query)));
|
||||
}
|
||||
|
||||
int place = (page * 10) - 9;
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
if (userslist.get(i) == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Format: 1. Playername - skill value
|
||||
sender.sendMessage(place + ". " + ChatColor.GREEN + userslist.get(i).get(1) + " - " + ChatColor.WHITE + userslist.get(i).get(0));
|
||||
place++;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||
}
|
||||
}, 1L);
|
||||
new MctopCommandDisplayTask(userslist, page, tablePrefix, sender).runTaskLater(mcMMO.p, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
package com.gmail.nossr50.runnables.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class MctopCommandDisplayTask extends BukkitRunnable {
|
||||
private HashMap<Integer, ArrayList<String>> userslist;
|
||||
private CommandSender sender;
|
||||
private String query;
|
||||
private int page;
|
||||
|
||||
public MctopCommandDisplayTask(HashMap<Integer, ArrayList<String>> userslist, int page, String query, CommandSender sender) {
|
||||
this.userslist = userslist;
|
||||
this.page = page;
|
||||
this.query = query;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(query)));
|
||||
}
|
||||
|
||||
int place = (page * 10) - 9;
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
if (userslist.get(i) == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Format: 1. Playername - skill value
|
||||
sender.sendMessage(place + ". " + ChatColor.GREEN + userslist.get(i).get(1) + " - " + ChatColor.WHITE + userslist.get(i).get(0));
|
||||
place++;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||
}
|
||||
}
|
@ -3,13 +3,15 @@ package com.gmail.nossr50.runnables.database;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class SQLConversionTask implements Runnable {
|
||||
public class SQLConversionTask extends BukkitRunnable {
|
||||
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
@Override
|
||||
|
@ -1,12 +1,13 @@
|
||||
package com.gmail.nossr50.runnables.database;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class SQLReconnectTask implements Runnable {
|
||||
public class SQLReconnectTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
if (DatabaseManager.checkConnected()) {
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.gmail.nossr50.runnables.database;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.database.LeaderboardManager;
|
||||
|
||||
public class UserPurgeTask implements Runnable {
|
||||
public class UserPurgeTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
|
@ -3,12 +3,13 @@ package com.gmail.nossr50.runnables.party;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
|
||||
public class PartyAutoKickTask implements Runnable {
|
||||
public class PartyAutoKickTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
updatePartyMembers();
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.gmail.nossr50.runnables.party;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
|
||||
public class PartyLoaderTask implements Runnable {
|
||||
public class PartyLoaderTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
PartyManager.loadParties();
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.gmail.nossr50.runnables.player;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PlayerProfileSaveTask implements Runnable {
|
||||
public class PlayerProfileSaveTask extends BukkitRunnable {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private PlayerProfile playerProfile;
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
|
||||
public class AwardCombatXpTask implements Runnable {
|
||||
public class AwardCombatXpTask extends BukkitRunnable {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private double baseXp;
|
||||
private SkillType skillType;
|
||||
|
@ -7,12 +7,13 @@ import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
|
||||
public class BleedTimerTask implements Runnable {
|
||||
public class BleedTimerTask extends BukkitRunnable {
|
||||
private final static int MAX_BLEED_TICKS = 10;
|
||||
private static Map<LivingEntity, Integer> bleedList = new HashMap<LivingEntity, Integer>();
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class HerbalismBlockUpdaterTask implements Runnable {
|
||||
public class HerbalismBlockUpdaterTask extends BukkitRunnable {
|
||||
private BlockState blockState;
|
||||
|
||||
public HerbalismBlockUpdaterTask(BlockState blockState) {
|
||||
|
@ -1,12 +1,14 @@
|
||||
package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class SkillMonitorTask implements Runnable {
|
||||
public class SkillMonitorTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
long curTime = System.currentTimeMillis();
|
||||
|
@ -3,29 +3,27 @@ package com.gmail.nossr50.skills.archery;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class TrackedEntity implements Runnable {
|
||||
public class TrackedEntity extends BukkitRunnable {
|
||||
private LivingEntity livingEntity;
|
||||
private UUID id;
|
||||
private int arrowCount;
|
||||
private int taskId;
|
||||
private BukkitScheduler scheduler;
|
||||
|
||||
protected TrackedEntity(LivingEntity livingEntity) {
|
||||
this.livingEntity = livingEntity;
|
||||
this.id = livingEntity.getUniqueId();
|
||||
this.scheduler = mcMMO.p.getServer().getScheduler();
|
||||
this.taskId = scheduler.runTaskTimer(mcMMO.p, this, 12000, 12000).getTaskId();
|
||||
|
||||
this.runTaskTimer(mcMMO.p, 12000, 12000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!livingEntity.isValid()) {
|
||||
Archery.removeFromTracker(this);
|
||||
scheduler.cancelTask(taskId);
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ public class HerbalismManager extends SkillManager {
|
||||
|
||||
playerInventory.removeItem(seed);
|
||||
player.updateInventory(); // Needed until replacement available
|
||||
mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new HerbalismBlockUpdaterTask(blockState), 0);
|
||||
new HerbalismBlockUpdaterTask(blockState).runTaskLater(mcMMO.p, 0);
|
||||
}
|
||||
|
||||
private boolean handleBlockState(BlockState blockState, boolean greenTerra) {
|
||||
|
@ -486,7 +486,7 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (baseXP != 0) {
|
||||
mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new AwardCombatXpTask(mcMMOPlayer, skillType, baseXP, target), 0);
|
||||
new AwardCombatXpTask(mcMMOPlayer, skillType, baseXP, target).runTaskLater(mcMMO.p, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user