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; package com.gmail.nossr50.runnables.party;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.mcMMO;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@ -11,7 +12,13 @@ import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
public class PartyAutoKickTask extends BukkitRunnable { 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 @Override
public void run() { public void run() {

View File

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

View File

@ -1,9 +1,17 @@
package com.gmail.nossr50.runnables.player; package com.gmail.nossr50.runnables.player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
public class ClearRegisteredXPGainTask extends BukkitRunnable { public class ClearRegisteredXPGainTask extends BukkitRunnable {
private final mcMMO pluginRef;
public ClearRegisteredXPGainTask(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override @Override
public void run() { public void run() {
for (McMMOPlayer mcMMOPlayer : pluginRef.getUserManager().getPlayers()) { 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.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.ScoreboardKeepTask; import com.gmail.nossr50.runnables.commands.ScoreboardKeepTask;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import org.bukkit.Server; import org.bukkit.Server;
@ -9,14 +10,17 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
public class PlayerProfileLoadingTask extends BukkitRunnable { public class PlayerProfileLoadingTask extends BukkitRunnable {
private final mcMMO pluginRef;
private final Player player; private final Player player;
private int attempt = 0; private int attempt = 0;
public PlayerProfileLoadingTask(Player player) { public PlayerProfileLoadingTask(mcMMO pluginRef, Player player) {
this.pluginRef = pluginRef;
this.player = player; this.player = player;
} }
private PlayerProfileLoadingTask(Player player, int attempt) { private PlayerProfileLoadingTask(mcMMO pluginRef, Player player, int attempt) {
this.pluginRef = pluginRef;
this.player = player; this.player = player;
this.attempt = attempt; this.attempt = attempt;
} }
@ -39,7 +43,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true); PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true);
// If successful, schedule the apply // If successful, schedule the apply
if (profile.isLoaded()) { if (profile.isLoaded()) {
new ApplySuccessfulProfile(new McMMOPlayer(player, profile)).runTask(pluginRef); new ApplySuccessfulProfile(new McMMOPlayer(player, profile, pluginRef)).runTask(pluginRef);
return; return;
} }
@ -59,7 +63,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
// Increment attempt counter and try // Increment attempt counter and try
attempt++; 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 { private class ApplySuccessfulProfile extends BukkitRunnable {
@ -87,7 +91,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
if (pluginRef.getScoreboardSettings().getShowStatsAfterLogin()) { if (pluginRef.getScoreboardSettings().getShowStatsAfterLogin()) {
pluginRef.getScoreboardManager().enablePlayerStatsScoreboard(player); 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; package com.gmail.nossr50.runnables.player;
import com.gmail.nossr50.mcMMO;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
public class PowerLevelUpdatingTask extends BukkitRunnable { public class PowerLevelUpdatingTask extends BukkitRunnable {
private final mcMMO pluginRef;
public PowerLevelUpdatingTask(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override @Override
public void run() { public void run() {
if (!pluginRef.getScoreboardManager().powerLevelHeartbeat()) { if (!pluginRef.getScoreboardManager().powerLevelHeartbeat()) {