Remove Static Abuse - Player / Party Tasks

This commit is contained in:
nossr50 2019-07-03 01:17:06 -07:00
parent 35f3c5d585
commit 997fac0d17
5 changed files with 61 additions and 34 deletions

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.runnables.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.mcMMO;
import org.bukkit.OfflinePlayer;
import org.bukkit.scheduler.BukkitRunnable;
@ -11,7 +12,13 @@ import java.util.Map.Entry;
import java.util.UUID;
public class PartyAutoKickTask extends BukkitRunnable {
private final static long KICK_TIME = 24L * 60L * 60L * 1000L * pluginRef.getConfigManager().getConfigParty().getPartyCleanup().getPartyAutoKickHoursInterval();
private final mcMMO pluginRef;
private final long KICK_TIME;
public PartyAutoKickTask(mcMMO pluginRef) {
this.pluginRef = pluginRef;
KICK_TIME = 24L * 60L * 60L * 1000L * pluginRef.getConfigManager().getConfigParty().getPartyCleanup().getPartyAutoKickHoursInterval();
}
@Override
public void run() {

View File

@ -1,28 +1,28 @@
package com.gmail.nossr50.runnables.party;
import com.gmail.nossr50.datatypes.party.Party;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
public class PartyChatTask extends BukkitRunnable {
private Plugin plugin;
private Party party;
private String senderName;
private String displayName;
private String message;
public PartyChatTask(Plugin plugin, Party party, String senderName, String displayName, String message) {
this.plugin = plugin;
this.party = party;
this.senderName = senderName;
this.displayName = displayName;
this.message = message;
}
@Override
public void run() {
}
}
//package com.gmail.nossr50.runnables.party;
//
//import com.gmail.nossr50.datatypes.party.Party;
//import org.bukkit.plugin.Plugin;
//import org.bukkit.scheduler.BukkitRunnable;
//
//public class PartyChatTask extends BukkitRunnable {
// private Plugin plugin;
//
// private Party party;
// private String senderName;
// private String displayName;
// private String message;
//
// public PartyChatTask(Plugin plugin, Party party, String senderName, String displayName, String message) {
// this.plugin = plugin;
//
// this.party = party;
// this.senderName = senderName;
// this.displayName = displayName;
// this.message = message;
// }
//
// @Override
// public void run() {
//
// }
//}

View File

@ -1,9 +1,17 @@
package com.gmail.nossr50.runnables.player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import org.bukkit.scheduler.BukkitRunnable;
public class ClearRegisteredXPGainTask extends BukkitRunnable {
private final mcMMO pluginRef;
public ClearRegisteredXPGainTask(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public void run() {
for (McMMOPlayer mcMMOPlayer : pluginRef.getUserManager().getPlayers()) {

View File

@ -2,6 +2,7 @@ package com.gmail.nossr50.runnables.player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.ScoreboardKeepTask;
import com.gmail.nossr50.util.Misc;
import org.bukkit.Server;
@ -9,14 +10,17 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class PlayerProfileLoadingTask extends BukkitRunnable {
private final mcMMO pluginRef;
private final Player player;
private int attempt = 0;
public PlayerProfileLoadingTask(Player player) {
public PlayerProfileLoadingTask(mcMMO pluginRef, Player player) {
this.pluginRef = pluginRef;
this.player = player;
}
private PlayerProfileLoadingTask(Player player, int attempt) {
private PlayerProfileLoadingTask(mcMMO pluginRef, Player player, int attempt) {
this.pluginRef = pluginRef;
this.player = player;
this.attempt = attempt;
}
@ -39,7 +43,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true);
// If successful, schedule the apply
if (profile.isLoaded()) {
new ApplySuccessfulProfile(new McMMOPlayer(player, profile)).runTask(pluginRef);
new ApplySuccessfulProfile(new McMMOPlayer(player, profile, pluginRef)).runTask(pluginRef);
return;
}
@ -59,7 +63,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
// Increment attempt counter and try
attempt++;
new PlayerProfileLoadingTask(player, attempt).runTaskLaterAsynchronously(pluginRef, (100 + (attempt * 100)));
new PlayerProfileLoadingTask(pluginRef, player, attempt).runTaskLaterAsynchronously(pluginRef, (100 + (attempt * 100)));
}
private class ApplySuccessfulProfile extends BukkitRunnable {
@ -87,7 +91,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
if (pluginRef.getScoreboardSettings().getShowStatsAfterLogin()) {
pluginRef.getScoreboardManager().enablePlayerStatsScoreboard(player);
new ScoreboardKeepTask(player).runTaskLater(pluginRef, Misc.TICK_CONVERSION_FACTOR);
new ScoreboardKeepTask(pluginRef, player).runTaskLater(pluginRef, Misc.TICK_CONVERSION_FACTOR);
}
}

View File

@ -1,8 +1,16 @@
package com.gmail.nossr50.runnables.player;
import com.gmail.nossr50.mcMMO;
import org.bukkit.scheduler.BukkitRunnable;
public class PowerLevelUpdatingTask extends BukkitRunnable {
private final mcMMO pluginRef;
public PowerLevelUpdatingTask(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public void run() {
if (!pluginRef.getScoreboardManager().powerLevelHeartbeat()) {