Remove Static Abuse - Command Tasks

This commit is contained in:
nossr50 2019-07-03 00:40:28 -07:00
parent 40a3de76fb
commit 4da455b9d2
76 changed files with 124 additions and 98 deletions

View File

@ -11,7 +11,7 @@ import org.bukkit.inventory.ItemStack;
*/
public class BukkitFactory {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public BukkitFactory(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -13,7 +13,7 @@ import java.util.regex.Pattern;
public class ChatManager {
private final String ADMIN_CHAT_PERMISSION = "mcmmo.chat.adminchat";
private mcMMO pluginRef;
private final mcMMO pluginRef;
public ChatManager(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -12,7 +12,7 @@ import java.util.List;
public class ChatNotificationToggleCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public ChatNotificationToggleCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -23,7 +23,7 @@ public class ConvertCommand implements TabExecutor {
private CommandExecutor databaseConvertCommand;
private CommandExecutor experienceConvertCommand;
private mcMMO pluginRef;
private final mcMMO pluginRef;
public ConvertCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -16,7 +16,7 @@ import java.util.List;
public class ExperienceRateCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public ExperienceRateCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -10,7 +10,7 @@ import org.bukkit.command.CommandSender;
public class McMMOCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public McMMOCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -13,7 +13,7 @@ import java.util.List;
public class ResetUserHealthBarSettingsCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public ResetUserHealthBarSettingsCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -12,7 +12,7 @@ import java.util.List;
public class ScoreboardCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public ScoreboardCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
public class PlayerDebug implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PlayerDebug(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -11,7 +11,7 @@ import org.bukkit.command.CommandSender;
*/
public final class ReloadLocaleCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public ReloadLocaleCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
public class ConvertDatabaseCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public ConvertDatabaseCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -14,7 +14,7 @@ import java.util.UUID;
public class McremoveCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public McremoveCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -10,7 +10,7 @@ import java.util.List;
public class PurgeCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PurgeCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -10,7 +10,7 @@ import java.util.List;
public class ShowDatabaseCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public ShowDatabaseCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
public class ConvertExperienceCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public ConvertExperienceCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -24,7 +24,7 @@ import java.util.UUID;
*/
public class SkillResetCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public SkillResetCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
public class PartyAcceptCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyAcceptCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
public class PartyChangeOwnerCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyChangeOwnerCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
public class PartyChangePasswordCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyChangePasswordCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -24,7 +24,7 @@ import java.util.List;
//TODO: This class horrifies me, rewrite it at some point
public class PartyCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
private CommandExecutor partyJoinCommand;
private CommandExecutor partyAcceptCommand;
private CommandExecutor partyCreateCommand;

View File

@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
public class PartyCreateCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyCreateCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
public class PartyDisbandCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyDisbandCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
public class PartyHelpCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyHelpCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -16,7 +16,7 @@ import java.util.List;
public class PartyInfoCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyInfoCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
public class PartyInviteCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyInviteCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
public class PartyItemShareCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyItemShareCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
public class PartyJoinCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyJoinCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
public class PartyKickCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyKickCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
public class PartyLockCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyLockCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
public class PartyQuitCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyQuitCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
public class PartyRenameCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyRenameCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -12,7 +12,7 @@ import org.bukkit.entity.Player;
public class PartyXpShareCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyXpShareCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
public class PartyAllianceAcceptCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyAllianceAcceptCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -19,7 +19,7 @@ import java.util.List;
public class PartyAllianceCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
private Player player;
private Party playerParty;
private Party targetParty;

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
public class PartyAllianceDisbandCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyAllianceDisbandCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
public class PartyAllianceInviteCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PartyAllianceInviteCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -8,7 +8,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class PtpAcceptAnyCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PtpAcceptAnyCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -12,7 +12,7 @@ import org.bukkit.entity.Player;
public class PtpAcceptCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PtpAcceptCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -24,7 +24,7 @@ import java.util.List;
public class PtpCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
private CommandExecutor ptpToggleCommand;
private CommandExecutor ptpAcceptAnyCommand;
private CommandExecutor ptpAcceptCommand;

View File

@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
public class PtpToggleCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public PtpToggleCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -13,7 +13,7 @@ import java.util.List;
public class CooldownCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public CooldownCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -17,7 +17,7 @@ import java.util.List;
public class InspectCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public InspectCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -4,7 +4,7 @@ import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
import com.gmail.nossr50.runnables.commands.LeaderboardsCommandAsyncTask;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.google.common.collect.ImmutableList;
@ -20,7 +20,7 @@ import java.util.List;
public class LeaderboardCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public LeaderboardCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
@ -120,7 +120,7 @@ public class LeaderboardCommand implements TabExecutor {
boolean useBoard = (sender instanceof Player) && (pluginRef.getScoreboardSettings().isScoreboardEnabled(pluginRef.getScoreboardManager().SidebarType.TOP_BOARD));
boolean useChat = !useBoard || pluginRef.getScoreboardSettings().isScoreboardPrinting(pluginRef.getScoreboardManager().SidebarType.TOP_BOARD);
new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(pluginRef);
new LeaderboardsCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(pluginRef);
}
private PrimarySkillType extractSkill(CommandSender sender, String skillName) {

View File

@ -3,7 +3,7 @@ package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
import com.gmail.nossr50.runnables.commands.RankCommandAsyncTask;
import com.gmail.nossr50.util.Permissions;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
@ -18,7 +18,7 @@ import java.util.List;
public class RankCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public RankCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;
@ -117,7 +117,7 @@ public class RankCommand implements TabExecutor {
&& (pluginRef.getScoreboardSettings().isScoreboardEnabled(pluginRef.getScoreboardManager().SidebarType.RANK_BOARD));
boolean useChat = !useBoard || pluginRef.getScoreboardSettings().isScoreboardPrinting(pluginRef.getScoreboardManager().SidebarType.RANK_BOARD);
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(pluginRef);
new RankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(pluginRef);
}
private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) {

View File

@ -11,7 +11,7 @@ import java.util.List;
public class SkillStatsCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public SkillStatsCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
public class ReloadPluginCommand implements CommandExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public ReloadPluginCommand(mcMMO plugin) {
this.pluginRef = plugin;

View File

@ -22,7 +22,7 @@ import java.util.List;
*/
public class MmoInfoCommand implements TabExecutor {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public MmoInfoCommand(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -14,7 +14,7 @@ public class SkillGuideCommand implements CommandExecutor {
private String header;
private ArrayList<String> guide;
private String invalidPage;
private mcMMO pluginRef;
private final mcMMO pluginRef;
public SkillGuideCommand(PrimarySkillType skill, mcMMO pluginRef) {
header = pluginRef.getLocaleManager().getString("Guides.Header", skill.getName());

View File

@ -82,7 +82,7 @@ import java.util.Set;
* Settings in configs are sometimes not platform-ready, you can find platform ready implementations in the {@link com.gmail.nossr50.core.DynamicSettingsManager DynamicSettingsManager}
*/
public final class ConfigManager {
private mcMMO pluginRef;
private final mcMMO pluginRef;
/* File array - Used for backups */

View File

@ -13,7 +13,7 @@ import java.util.List;
public class BonusDropManager {
private HashMap<Material, Boolean> bonusDropWhitelist;
private mcMMO pluginRef;
private final mcMMO pluginRef;
public BonusDropManager(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -24,7 +24,7 @@ import java.util.HashMap;
*/
public class DynamicSettingsManager {
private mcMMO pluginRef;
private final mcMMO pluginRef;
/* UNLOAD REGISTER */
private SkillPropertiesManager skillPropertiesManager;

View File

@ -16,7 +16,7 @@ import java.util.HashMap;
* Hacky way to do this until I rewrite the skill system fully
*/
public class SkillPropertiesManager {
private mcMMO pluginRef;
private final mcMMO pluginRef;
private HashMap<SubSkillType, Double> maxChanceMap;
private HashMap<SubSkillType, Double> staticActivationChanceMap;

View File

@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.mcMMO;
public class DatabaseManagerFactory {
private mcMMO pluginRef;
private final mcMMO pluginRef;
private Class<? extends DatabaseManager> customManager = null;
public DatabaseManagerFactory(mcMMO pluginRef) {

View File

@ -16,7 +16,7 @@ import java.io.*;
import java.util.*;
public final class FlatFileDatabaseManager implements DatabaseManager {
private mcMMO pluginRef;
private final mcMMO pluginRef;
private final Object fileWritingLock = new Object();
private int USERNAME = 0;
private int SKILLS_MINING = 1;

View File

@ -19,7 +19,7 @@ import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
public final class SQLDatabaseManager implements DatabaseManager {
private mcMMO pluginRef;
private final mcMMO pluginRef;
private final String COM_MYSQL_JDBC_DRIVER = "com.mysql.jdbc.Driver";
private final String ALL_QUERY_VERSION = "total";
private final Map<UUID, Integer> cachedUserIDs = new HashMap<>();

View File

@ -19,7 +19,7 @@ import java.util.UUID;
import java.util.stream.Collectors;
public class Party {
private mcMMO pluginRef;
private final mcMMO pluginRef;
private static final String ONLINE_PLAYER_PREFIX = "";
private static final String OFFLINE_PLAYER_PREFIX = "";
private final LinkedHashMap<UUID, String> members = new LinkedHashMap<>();

View File

@ -18,7 +18,7 @@ public final class LocaleManager {
private ResourceBundle bundle;
private ResourceBundle filesystemBundle;
private ResourceBundle enBundle;
private mcMMO pluginRef;
private final mcMMO pluginRef;
public LocaleManager(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -18,7 +18,7 @@ import com.gmail.nossr50.listeners.*;
import com.gmail.nossr50.locale.LocaleManager;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.SaveTimerTask;
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
import com.gmail.nossr50.runnables.backups.CleanBackupFilesTask;
import com.gmail.nossr50.runnables.commands.NotifySquelchReminderTask;
import com.gmail.nossr50.runnables.database.UserPurgeTask;
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
@ -586,7 +586,7 @@ public class mcMMO extends JavaPlugin {
new SaveTimerTask().runTaskTimer(this, saveIntervalTicks, saveIntervalTicks);
// Cleanup the backups folder
new CleanBackupsTask().runTaskAsynchronously(this);
new CleanBackupFilesTask().runTaskAsynchronously(this);
// Bleed timer (Runs every 0.5 seconds)
new BleedTimerTask().runTaskTimer(this, Misc.TICK_CONVERSION_FACTOR, (Misc.TICK_CONVERSION_FACTOR / 2));

View File

@ -26,7 +26,7 @@ import java.util.Map.Entry;
import java.util.UUID;
public final class PartyManager {
private mcMMO pluginRef;
private final mcMMO pluginRef;
private List<Party> parties;
private File partyFile;

View File

@ -17,7 +17,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.List;
public final class ShareHandler {
private mcMMO pluginRef;
private final mcMMO pluginRef;
private Party party;
public ShareHandler(mcMMO pluginRef, Party party) {

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.runnables.backups;
import com.gmail.nossr50.mcMMO;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
@ -11,9 +12,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
public class CleanBackupsTask extends BukkitRunnable {
private static final String BACKUP_DIRECTORY = pluginRef.getMainDirectory() + "backup" + File.separator;
private static final File BACKUP_DIR = new File(BACKUP_DIRECTORY);
public class CleanBackupFilesTask extends BukkitRunnable {
private final mcMMO pluginRef;
private final File BACKUP_DIR;
public CleanBackupFilesTask(mcMMO pluginRef) {
this.pluginRef = pluginRef;
BACKUP_DIR = new File(pluginRef.getMainDirectory() + "backup" + File.separator);
}
@Override
public void run() {
@ -24,13 +31,8 @@ public class CleanBackupsTask extends BukkitRunnable {
int amountDeleted = 0;
int oldFileAgeLimit = pluginRef.getConfigManager().getConfigAutomatedBackups().getBackupDayLimit();
if (BACKUP_DIR.listFiles() == null) {
return;
}
//if(BACKUP_DIR.listFiles().length < mcMMO.getConfigManager().getConfigAutomatedBackups().getMinimumBackupCount())
//Don't remove files unless there is at least 10 of them
if (BACKUP_DIR.listFiles().length < 10)
if (BACKUP_DIR.listFiles() == null || BACKUP_DIR.listFiles().length < 10)
return;
// Check files in backup folder from oldest to newest

View File

@ -2,6 +2,7 @@ package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import org.apache.commons.lang.Validate;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -9,13 +10,16 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
public class MctopCommandAsyncTask extends BukkitRunnable {
public class LeaderboardsCommandAsyncTask extends BukkitRunnable {
private final mcMMO pluginRef;
private final CommandSender sender;
private final PrimarySkillType skill;
private final int page;
private final boolean useBoard, useChat;
public MctopCommandAsyncTask(int page, PrimarySkillType skill, CommandSender sender, boolean useBoard, boolean useChat) {
public LeaderboardsCommandAsyncTask(mcMMO pluginRef, int page, PrimarySkillType skill, CommandSender sender, boolean useBoard, boolean useChat) {
this.pluginRef = pluginRef;
Validate.isTrue(useBoard || useChat, "Attempted to start a rank retrieval with both board and chat off");
Validate.notNull(sender, "Attempted to start a rank retrieval with no recipient");
@ -34,6 +38,6 @@ public class MctopCommandAsyncTask extends BukkitRunnable {
public void run() {
final List<PlayerStat> userStats = pluginRef.getDatabaseManager().readLeaderboard(skill, page, 10);
new MctopCommandDisplayTask(userStats, page, skill, sender, useBoard, useChat).runTaskLater(pluginRef, 1);
new LeaderboardsCommandDisplayTask(pluginRef, userStats, page, skill, sender, useBoard, useChat).runTaskLater(pluginRef, 1);
}
}

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -11,16 +12,18 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
/**
* Display the results of {@link MctopCommandAsyncTask} to the sender.
* Display the results of {@link LeaderboardsCommandAsyncTask} to the sender.
*/
public class MctopCommandDisplayTask extends BukkitRunnable {
public class LeaderboardsCommandDisplayTask extends BukkitRunnable {
private final mcMMO pluginRef;
private final List<PlayerStat> userStats;
private final CommandSender sender;
private final PrimarySkillType skill;
private final int page;
private final boolean useBoard, useChat;
MctopCommandDisplayTask(List<PlayerStat> userStats, int page, PrimarySkillType skill, CommandSender sender, boolean useBoard, boolean useChat) {
LeaderboardsCommandDisplayTask(mcMMO pluginRef, List<PlayerStat> userStats, int page, PrimarySkillType skill, CommandSender sender, boolean useBoard, boolean useChat) {
this.pluginRef = pluginRef;
this.userStats = userStats;
this.page = page;
this.skill = skill;

View File

@ -1,11 +1,19 @@
package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
//TODO: Rewrite, wrote this in a rush.
public class NotifySquelchReminderTask extends BukkitRunnable {
private final mcMMO pluginRef;
public NotifySquelchReminderTask(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import org.apache.commons.lang.Validate;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -8,12 +9,14 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.util.Map;
public class McrankCommandAsyncTask extends BukkitRunnable {
public class RankCommandAsyncTask extends BukkitRunnable {
private final mcMMO pluginRef;
private final String playerName;
private final CommandSender sender;
private final boolean useBoard, useChat;
public McrankCommandAsyncTask(String playerName, CommandSender sender, boolean useBoard, boolean useChat) {
public RankCommandAsyncTask(mcMMO pluginRef, String playerName, CommandSender sender, boolean useBoard, boolean useChat) {
this.pluginRef = pluginRef;
Validate.isTrue(useBoard || useChat, "Attempted to start a rank retrieval with both board and chat off");
Validate.notNull(sender, "Attempted to start a rank retrieval with no recipient");
@ -31,7 +34,7 @@ public class McrankCommandAsyncTask extends BukkitRunnable {
public void run() {
Map<PrimarySkillType, Integer> skills = pluginRef.getDatabaseManager().readRank(playerName);
new McrankCommandDisplayTask(skills, sender, playerName, useBoard, useChat).runTaskLater(pluginRef, 1);
new RankCommandDisplayTask(pluginRef, skills, sender, playerName, useBoard, useChat).runTaskLater(pluginRef, 1);
}
}

View File

@ -2,6 +2,7 @@ package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@ -9,15 +10,17 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.util.Map;
/**
* Display the results of McrankCommandAsyncTask to the sender.
* Display the results of RankCommandAsyncTask to the sender.
*/
public class McrankCommandDisplayTask extends BukkitRunnable {
public class RankCommandDisplayTask extends BukkitRunnable {
private final mcMMO pluginRef;
private final Map<PrimarySkillType, Integer> skills;
private final CommandSender sender;
private final String playerName;
private final boolean useBoard, useChat;
McrankCommandDisplayTask(Map<PrimarySkillType, Integer> skills, CommandSender sender, String playerName, boolean useBoard, boolean useChat) {
RankCommandDisplayTask(mcMMO pluginRef, Map<PrimarySkillType, Integer> skills, CommandSender sender, String playerName, boolean useBoard, boolean useChat) {
this.pluginRef = pluginRef;
this.skills = skills;
this.sender = sender;
this.playerName = playerName;

View File

@ -1,12 +1,15 @@
package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.mcMMO;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class McScoreboardKeepTask extends BukkitRunnable {
public class ScoreboardKeepTask extends BukkitRunnable {
private final mcMMO pluginRef;
private Player player;
public McScoreboardKeepTask(Player player) {
public ScoreboardKeepTask(mcMMO pluginRef, Player player) {
this.pluginRef = pluginRef;
this.player = player;
}

View File

@ -2,7 +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.runnables.commands.McScoreboardKeepTask;
import com.gmail.nossr50.runnables.commands.ScoreboardKeepTask;
import com.gmail.nossr50.util.Misc;
import org.bukkit.Server;
import org.bukkit.entity.Player;
@ -87,7 +87,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
if (pluginRef.getScoreboardSettings().getShowStatsAfterLogin()) {
pluginRef.getScoreboardManager().enablePlayerStatsScoreboard(player);
new McScoreboardKeepTask(player).runTaskLater(pluginRef, Misc.TICK_CONVERSION_FACTOR);
new ScoreboardKeepTask(player).runTaskLater(pluginRef, Misc.TICK_CONVERSION_FACTOR);
}
}

View File

@ -55,7 +55,7 @@ import java.util.Map;
*/
public class EventManager {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public EventManager(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -13,7 +13,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.metadata.FixedMetadataValue;
public final class MobHealthBarManager {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public MobHealthBarManager(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -22,7 +22,7 @@ import java.util.List;
//TODO: Needs to be rewritten
public class TextComponentFactory {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public TextComponentFactory(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -26,7 +26,7 @@ import java.util.ArrayList;
import java.util.List;
public final class CommandRegistrationManager {
private mcMMO pluginRef;
private final mcMMO pluginRef;
private String permissionsMessage = pluginRef.getLocaleManager().getString("mcMMO.NoPermission");
public CommandRegistrationManager(mcMMO pluginRef) {

View File

@ -16,7 +16,7 @@ import java.util.ArrayList;
import java.util.List;
public final class CommandTools {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public CommandTools(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -13,7 +13,7 @@ import java.util.HashMap;
* This class handles the XP maps for various skills
*/
public class ExperienceManager {
private mcMMO pluginRef;
private final mcMMO pluginRef;
private HashMap<PrimarySkillType, HashMap<Material, String>> skillMaterialXPMap;
private HashMap<String, Integer> miningFullyQualifiedBlockXpMap;

View File

@ -29,7 +29,7 @@ import java.util.HashMap;
public class NotificationManager {
private HashMap<NotificationType, PlayerNotificationSettings> playerNotificationHashMap;
private mcMMO pluginRef;
private final mcMMO pluginRef;
public NotificationManager(mcMMO pluginRef) {
this.pluginRef = pluginRef;

View File

@ -15,7 +15,7 @@ import java.util.HashSet;
public final class UserManager {
private mcMMO pluginRef;
private final mcMMO pluginRef;
public UserManager(mcMMO pluginRef) {
this.pluginRef = pluginRef;