mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 16:46:46 +01:00
Queue
This commit is contained in:
parent
0e9953c25b
commit
a97b889af5
@ -123,11 +123,7 @@ public class McrankCommand implements CommandExecutor {
|
||||
|
||||
private void sqlDisplay(CommandSender sender, String playerName) {
|
||||
if (mcMMO.queueManager.contains(sender.getName()) || !mcMMO.queueManager.queue(new McRankAsync(playerName, sender))) {
|
||||
<<<<<<< HEAD
|
||||
//Warn that queue is unable to accept
|
||||
=======
|
||||
//Tell user to wait until their first command goes through
|
||||
>>>>>>> One per player
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
@ -129,121 +128,3 @@ public class MctopCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
}
|
||||
=======
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Leaderboard;
|
||||
import com.gmail.nossr50.database.queuemanager.McTopAsync;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class MctopCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
boolean useMySQL = Config.getInstance().getUseMySQL();
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
display(1, "ALL", sender, useMySQL, command);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (StringUtils.isInt(args[0])) {
|
||||
display(Integer.parseInt(args[0]), "ALL", sender, useMySQL, command);
|
||||
}
|
||||
else if (SkillTools.isSkill(args[0])) {
|
||||
display(1, SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!StringUtils.isInt(args[1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (SkillTools.isSkill(args[0])) {
|
||||
display(Integer.parseInt(args[1]), SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void display(int page, String skill, CommandSender sender, boolean sql, Command command) {
|
||||
if (sql) {
|
||||
if (skill.equalsIgnoreCase("all")) {
|
||||
sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender, command);
|
||||
}
|
||||
else {
|
||||
sqlDisplay(page, skill, sender, command);
|
||||
}
|
||||
}
|
||||
else {
|
||||
flatfileDisplay(page, skill, sender, command);
|
||||
}
|
||||
}
|
||||
|
||||
private void flatfileDisplay(int page, String skill, CommandSender sender, Command command) {
|
||||
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, SkillType.getSkill(skill))) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
Leaderboard.updateLeaderboards(); //Make sure we have the latest information
|
||||
|
||||
String[] info = Leaderboard.retrieveInfo(skill, page);
|
||||
|
||||
if (skill.equalsIgnoreCase("all")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(skill)));
|
||||
}
|
||||
|
||||
int n = (page * 10) - 9; // Position
|
||||
for (String x : info) {
|
||||
if (x != null) {
|
||||
String digit = String.valueOf(n);
|
||||
|
||||
if (n < 10) {
|
||||
digit = "0" + digit;
|
||||
}
|
||||
|
||||
String[] splitx = x.split(":");
|
||||
|
||||
// Format: 1. Playername - skill value
|
||||
sender.sendMessage(digit + ". " + ChatColor.GREEN + splitx[1] + " - " + ChatColor.WHITE + splitx[0]);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||
}
|
||||
|
||||
private void sqlDisplay(int page, String query, CommandSender sender, Command command) {
|
||||
if (mcMMO.queueManager.contains(sender.getName()) || !mcMMO.queueManager.queue(new McTopAsync(page, query, sender, command))) {
|
||||
//Tell user to wait until their first command goes through
|
||||
}
|
||||
}
|
||||
}
|
||||
>>>>>>> One per player
|
||||
|
@ -255,22 +255,4 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
|
||||
public double getForumulaMultiplier(SkillType skill) { return config.getDouble("Experience.Formula.Multiplier." + StringUtils.getCapitalized(skill.toString())); }
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
for (String key : keys) {
|
||||
if (config.getBoolean("Double_Drops." + skillName + "." + key)) {
|
||||
disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
private int getLevelCap(String configString) {
|
||||
int cap = config.getInt(configString, 0);
|
||||
return ((cap <= 0) ? Integer.MAX_VALUE : cap);
|
||||
}
|
||||
|
||||
>>>>>>> Throttle
|
||||
}
|
||||
|
@ -10,13 +10,8 @@ public class AsyncQueueManager implements Runnable {
|
||||
private long throttle;
|
||||
|
||||
public AsyncQueueManager(long throttle) {
|
||||
<<<<<<< HEAD
|
||||
this.queue = new LinkedBlockingQueue<Queueable>();
|
||||
this.running = true;
|
||||
=======
|
||||
queue = new LinkedBlockingQueue<Queueable>();
|
||||
running = true;
|
||||
>>>>>>> Throttle
|
||||
this.throttle = throttle;
|
||||
}
|
||||
|
||||
@ -41,10 +36,6 @@ public class AsyncQueueManager implements Runnable {
|
||||
}
|
||||
|
||||
public boolean contains(String player) {
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> String wrapper
|
||||
return queue.contains(new EqualString(player));
|
||||
}
|
||||
|
||||
@ -60,12 +51,6 @@ public class AsyncQueueManager implements Runnable {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
return queue.contains(player);
|
||||
>>>>>>> One per player
|
||||
=======
|
||||
>>>>>>> String wrapper
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ public class McRankAsync implements Queueable {
|
||||
this.player = sender.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final Map<String, Integer> skills = DatabaseManager.readSQLRank(playerName);
|
||||
|
||||
@ -55,24 +54,9 @@ public class McRankAsync implements Queueable {
|
||||
|
||||
}, 1L);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
@Override
|
||||
public String getPlayer() {
|
||||
return player;
|
||||
=======
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof String) {
|
||||
return ((String)obj).equalsIgnoreCase(player);
|
||||
}
|
||||
return false;
|
||||
>>>>>>> One per player
|
||||
=======
|
||||
public String getPlayer() {
|
||||
return player;
|
||||
>>>>>>> String wrapper
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ public class McTopAsync implements Queueable {
|
||||
this.player = sender.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
||||
if (!Permissions.mctop(sender, SkillType.getSkill(query))) {
|
||||
@ -68,24 +67,8 @@ public class McTopAsync implements Queueable {
|
||||
}
|
||||
|
||||
@Override
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
public String getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
=======
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof String) {
|
||||
return ((String)obj).equalsIgnoreCase(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
>>>>>>> One per player
|
||||
=======
|
||||
public String getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
>>>>>>> String wrapper
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import java.io.File;
|
||||
@ -489,452 +488,3 @@ public class mcMMO extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
=======
|
||||
package com.gmail.nossr50;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
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.util.blockmeta.chunkmeta.ChunkManager;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
||||
import com.gmail.nossr50.util.metrics.MetricsManager;
|
||||
import com.gmail.nossr50.commands.CommandRegistrationHelper;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.database.Leaderboard;
|
||||
import com.gmail.nossr50.database.queuemanager.AsyncQueueManager;
|
||||
import com.gmail.nossr50.database.runnables.UserPurgeTask;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.listeners.BlockListener;
|
||||
import com.gmail.nossr50.listeners.EntityListener;
|
||||
import com.gmail.nossr50.listeners.InventoryListener;
|
||||
import com.gmail.nossr50.listeners.PlayerListener;
|
||||
import com.gmail.nossr50.listeners.WorldListener;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mods.config.CustomArmorConfig;
|
||||
import com.gmail.nossr50.mods.config.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.mods.config.CustomEntityConfig;
|
||||
import com.gmail.nossr50.mods.config.CustomToolsConfig;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.party.runnables.PartiesLoader;
|
||||
import com.gmail.nossr50.party.runnables.PartyAutoKick;
|
||||
import com.gmail.nossr50.runnables.SaveTimer;
|
||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||
import com.gmail.nossr50.skills.repair.RepairManagerFactory;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.config.RepairConfigManager;
|
||||
import com.gmail.nossr50.skills.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.runnables.SkillMonitor;
|
||||
import com.gmail.nossr50.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.spout.SpoutTools;
|
||||
import com.gmail.nossr50.util.UpdateCheck;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
private final PlayerListener playerListener = new PlayerListener(this);
|
||||
private final BlockListener blockListener = new BlockListener(this);
|
||||
private final EntityListener entityListener = new EntityListener(this);
|
||||
private final InventoryListener inventoryListener = new InventoryListener(this);
|
||||
private final WorldListener worldListener = new WorldListener();
|
||||
|
||||
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
|
||||
private HashMap<Block, String> furnaceTracker = new HashMap<Block, String>();
|
||||
|
||||
public static mcMMO p;
|
||||
|
||||
public static ChunkManager placeStore;
|
||||
public static RepairManager repairManager;
|
||||
public static AsyncQueueManager queueManager;
|
||||
|
||||
// Jar Stuff
|
||||
public static File mcmmo;
|
||||
|
||||
// File Paths
|
||||
private static String mainDirectory;
|
||||
private static String flatFileDirectory;
|
||||
private static String usersFile;
|
||||
private static String modDirectory;
|
||||
|
||||
// Update Check
|
||||
public boolean updateAvailable;
|
||||
|
||||
// Spout Check
|
||||
public static boolean spoutEnabled = false;
|
||||
|
||||
// XP Event Check
|
||||
private boolean xpEventEnabled = false;
|
||||
|
||||
// Entity Metadata Values
|
||||
public static FixedMetadataValue entityMetadata;
|
||||
public final static String entityMetadataKey = "mcMMO: Spawned Entity";
|
||||
|
||||
/**
|
||||
* Things to be run when the plugin is enabled.
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
p = this;
|
||||
entityMetadata = new FixedMetadataValue(mcMMO.p, true);
|
||||
setupFilePaths();
|
||||
setupSpout();
|
||||
loadConfigFiles();
|
||||
|
||||
if (!Config.getInstance().getUseMySQL()) {
|
||||
Users.loadUsers();
|
||||
}
|
||||
|
||||
registerEvents();
|
||||
|
||||
// Setup the leader boards
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
// TODO: Why do we have to check for a connection that hasn't be made yet?
|
||||
Database.checkConnected();
|
||||
Database.createStructure();
|
||||
}
|
||||
else {
|
||||
Leaderboard.updateLeaderboards();
|
||||
}
|
||||
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
Users.addUser(player); // In case of reload add all users back into PlayerProfile
|
||||
}
|
||||
|
||||
getLogger().info("Version " + getDescription().getVersion() + " is enabled!");
|
||||
|
||||
scheduleTasks();
|
||||
registerCommands();
|
||||
|
||||
MetricsManager.setup();
|
||||
|
||||
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
|
||||
|
||||
try {
|
||||
updateAvailable = Config.getInstance().getUpdateCheckEnabled() && UpdateCheck.updateAvailable();
|
||||
} catch (Exception e) {
|
||||
updateAvailable = false;
|
||||
}
|
||||
if (updateAvailable) {
|
||||
getLogger().info(LocaleLoader.getString("UpdateChecker.outdated"));
|
||||
getLogger().info(LocaleLoader.getString("UpdateChecker.newavailable"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the various storage file paths
|
||||
*/
|
||||
private void setupFilePaths() {
|
||||
mcmmo = getFile();
|
||||
mainDirectory = getDataFolder().getPath() + File.separator;
|
||||
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
|
||||
usersFile = flatFileDirectory + "mcmmo.users";
|
||||
modDirectory = mainDirectory + "ModConfigs" + File.separator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get profile of the player by name.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName Name of player whose profile to get
|
||||
* @return the PlayerProfile object
|
||||
*/
|
||||
public PlayerProfile getPlayerProfile(String playerName) {
|
||||
return Users.getPlayer(playerName).getProfile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get profile of the player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player player whose profile to get
|
||||
* @return the PlayerProfile object
|
||||
*/
|
||||
public PlayerProfile getPlayerProfile(OfflinePlayer player) {
|
||||
return Users.getPlayer(player.getName()).getProfile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get profile of the player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player player whose profile to get
|
||||
* @return the PlayerProfile object
|
||||
*/
|
||||
@Deprecated
|
||||
public PlayerProfile getPlayerProfile(Player player) {
|
||||
return Users.getProfile(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Things to be run when the plugin is disabled.
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Users.saveAll(); // Make sure to save player information if the server shuts down
|
||||
PartyManager.saveParties();
|
||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
||||
placeStore.saveAll(); // Save our metadata
|
||||
placeStore.cleanUp(); // Cleanup empty metadata stores
|
||||
|
||||
if (Config.getInstance().getBackupsEnabled()) {
|
||||
// Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
||||
try {
|
||||
ZipLibrary.mcMMObackup();
|
||||
}
|
||||
catch (IOException e) {
|
||||
getLogger().severe(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
getLogger().info("Was disabled."); //How informative!
|
||||
}
|
||||
|
||||
private void loadConfigFiles() {
|
||||
// Force the loading of config files
|
||||
Config configInstance = Config.getInstance();
|
||||
TreasuresConfig.getInstance();
|
||||
HiddenConfig.getInstance();
|
||||
AdvancedConfig.getInstance();
|
||||
|
||||
|
||||
|
||||
List<Repairable> repairables = new ArrayList<Repairable>();
|
||||
|
||||
if (configInstance.getToolModsEnabled()) {
|
||||
repairables.addAll(CustomToolsConfig.getInstance().getLoadedRepairables());
|
||||
}
|
||||
|
||||
if (configInstance.getArmorModsEnabled()) {
|
||||
repairables.addAll(CustomArmorConfig.getInstance().getLoadedRepairables());
|
||||
}
|
||||
|
||||
if (configInstance.getBlockModsEnabled()) {
|
||||
CustomBlocksConfig.getInstance();
|
||||
}
|
||||
|
||||
if (configInstance.getEntityModsEnabled()) {
|
||||
CustomEntityConfig.getInstance();
|
||||
}
|
||||
|
||||
// Load repair configs, make manager, and register them at this time
|
||||
RepairConfigManager rManager = new RepairConfigManager(this);
|
||||
repairables.addAll(rManager.getLoadedRepairables());
|
||||
repairManager = RepairManagerFactory.getRepairManager(repairables.size());
|
||||
repairManager.registerRepairables(repairables);
|
||||
|
||||
// Check if Repair Anvil and Salvage Anvil have different itemID's
|
||||
if (configInstance.getSalvageAnvilId() == configInstance.getRepairAnvilId()) {
|
||||
getLogger().warning("Can't use the same itemID for Repair/Salvage Anvils!");
|
||||
}
|
||||
}
|
||||
|
||||
private void setupSpout() {
|
||||
// Check for Spout
|
||||
if (getServer().getPluginManager().isPluginEnabled("Spout")) {
|
||||
spoutEnabled = true;
|
||||
|
||||
SpoutConfig.getInstance();
|
||||
SpoutTools.setupSpoutConfigs();
|
||||
SpoutTools.registerCustomEvent();
|
||||
SpoutTools.preCacheFiles();
|
||||
SpoutTools.reloadSpoutPlayers(); // Handle spout players after a /reload
|
||||
}
|
||||
}
|
||||
|
||||
private void registerEvents() {
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
|
||||
// Register events
|
||||
pluginManager.registerEvents(playerListener, this);
|
||||
pluginManager.registerEvents(blockListener, this);
|
||||
pluginManager.registerEvents(entityListener, this);
|
||||
pluginManager.registerEvents(inventoryListener, this);
|
||||
pluginManager.registerEvents(worldListener, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands.
|
||||
*/
|
||||
private void registerCommands() {
|
||||
CommandRegistrationHelper.registerSkillCommands();
|
||||
|
||||
// mc* commands
|
||||
CommandRegistrationHelper.registerMcpurgeCommand();
|
||||
CommandRegistrationHelper.registerMcremoveCommand();
|
||||
CommandRegistrationHelper.registerMcabilityCommand();
|
||||
CommandRegistrationHelper.registerMcgodCommand();
|
||||
CommandRegistrationHelper.registerMcmmoCommand();
|
||||
CommandRegistrationHelper.registerMcrefreshCommand();
|
||||
CommandRegistrationHelper.registerMctopCommand();
|
||||
CommandRegistrationHelper.registerMcrankCommand();
|
||||
CommandRegistrationHelper.registerMcstatsCommand();
|
||||
|
||||
// Party commands
|
||||
CommandRegistrationHelper.registerAdminChatCommand();
|
||||
CommandRegistrationHelper.registerPartyCommand();
|
||||
CommandRegistrationHelper.registerPartyChatCommand();
|
||||
CommandRegistrationHelper.registerPtpCommand();
|
||||
|
||||
// Other commands
|
||||
CommandRegistrationHelper.registerAddxpCommand();
|
||||
CommandRegistrationHelper.registerAddlevelsCommand();
|
||||
CommandRegistrationHelper.registerMmoeditCommand();
|
||||
CommandRegistrationHelper.registerInspectCommand();
|
||||
CommandRegistrationHelper.registerXprateCommand();
|
||||
CommandRegistrationHelper.registerMmoupdateCommand();
|
||||
CommandRegistrationHelper.registerSkillresetCommand();
|
||||
CommandRegistrationHelper.registerHardcoreCommand();
|
||||
CommandRegistrationHelper.registerVampirismCommand();
|
||||
|
||||
// Spout commands
|
||||
CommandRegistrationHelper.registerXplockCommand();
|
||||
CommandRegistrationHelper.registerMchudCommand();
|
||||
}
|
||||
|
||||
private void scheduleTasks() {
|
||||
BukkitScheduler scheduler = getServer().getScheduler();
|
||||
|
||||
// Parties are loaded at the end of first server tick otherwise Server.getOfflinePlayer throws an IndexOutOfBoundsException
|
||||
scheduler.scheduleSyncDelayedTask(this, new PartiesLoader(), 0);
|
||||
|
||||
// Periodic save timer (Saves every 10 minutes by default)
|
||||
long saveIntervalTicks = Config.getInstance().getSaveInterval() * 1200;
|
||||
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(), saveIntervalTicks, saveIntervalTicks);
|
||||
// Regen & Cooldown timer (Runs every second)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(), 20, 20);
|
||||
// Bleed timer (Runs every two seconds)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(), 40, 40);
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
queueManager = new AsyncQueueManager(Config.getInstance().getQueueThrottle());
|
||||
scheduler.scheduleAsyncDelayedTask(this, queueManager, 1L);
|
||||
}
|
||||
|
||||
// Old & Powerless User remover
|
||||
int purgeInterval = Config.getInstance().getPurgeInterval();
|
||||
|
||||
if (purgeInterval == 0) {
|
||||
scheduler.scheduleSyncDelayedTask(this, new UserPurgeTask(), 40); // Start 2 seconds after startup.
|
||||
}
|
||||
else if (purgeInterval > 0) {
|
||||
long purgeIntervalTicks = purgeInterval * 60 * 60 * 20;
|
||||
|
||||
scheduler.scheduleSyncRepeatingTask(this, new UserPurgeTask(), purgeIntervalTicks, purgeIntervalTicks);
|
||||
}
|
||||
|
||||
// Automatically remove old members from parties
|
||||
long kickInterval = Config.getInstance().getAutoPartyKickInterval();
|
||||
|
||||
if (kickInterval == 0) {
|
||||
scheduler.scheduleSyncDelayedTask(this, new PartyAutoKick(), 40); // Start 2 seconds after startup.
|
||||
}
|
||||
else if (kickInterval > 0) {
|
||||
long kickIntervalTicks = kickInterval * 60 * 60 * 20;
|
||||
|
||||
scheduler.scheduleSyncRepeatingTask(this, new PartyAutoKick(), kickIntervalTicks, kickIntervalTicks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a set of values to the TNT tracker.
|
||||
*
|
||||
* @param tntID The EntityID of the TNT
|
||||
* @param playerName The name of the detonating player
|
||||
*/
|
||||
public void addToTNTTracker(int tntID, String playerName) {
|
||||
tntTracker.put(tntID, playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a given TNT Entity is tracked.
|
||||
*
|
||||
* @param tntID The EntityID of the TNT
|
||||
* @return true if the TNT is being tracked, false otherwise
|
||||
*/
|
||||
public boolean tntIsTracked(int tntID) {
|
||||
return tntTracker.containsKey(tntID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player who detonated the TNT.
|
||||
*
|
||||
* @param tntID The EntityID of the TNT
|
||||
* @return the Player who detonated it
|
||||
*/
|
||||
public Player getTNTPlayer(int tntID) {
|
||||
return getServer().getPlayer(tntTracker.get(tntID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove TNT from the tracker after it explodes.
|
||||
*
|
||||
* @param tntID The EntityID of the TNT
|
||||
*/
|
||||
public void removeFromTNTTracker(int tntID) {
|
||||
tntTracker.remove(tntID);
|
||||
}
|
||||
|
||||
public void addToOpenFurnaceTracker(Block furnace, String playerName) {
|
||||
furnaceTracker.put(furnace, playerName);
|
||||
}
|
||||
|
||||
public boolean furnaceIsTracked(Block furnace) {
|
||||
return furnaceTracker.containsKey(furnace);
|
||||
}
|
||||
|
||||
public void removeFromFurnaceTracker(Block furnace) {
|
||||
furnaceTracker.remove(furnace);
|
||||
}
|
||||
|
||||
public Player getFurnacePlayer(Block furnace) {
|
||||
return getServer().getPlayer(furnaceTracker.get(furnace));
|
||||
}
|
||||
|
||||
public static String getMainDirectory() {
|
||||
return mainDirectory;
|
||||
}
|
||||
|
||||
public static String getFlatFileDirectory() {
|
||||
return flatFileDirectory;
|
||||
}
|
||||
|
||||
public static String getUsersFilePath() {
|
||||
return usersFile;
|
||||
}
|
||||
|
||||
public static String getModDirectory() {
|
||||
return modDirectory;
|
||||
}
|
||||
|
||||
public boolean isXPEventEnabled() {
|
||||
return xpEventEnabled;
|
||||
}
|
||||
|
||||
public void setXPEventEnabled(boolean enabled) {
|
||||
this.xpEventEnabled = enabled;
|
||||
}
|
||||
|
||||
public void toggleXpEventEnabled() {
|
||||
xpEventEnabled = !xpEventEnabled;
|
||||
}
|
||||
}
|
||||
>>>>>>> Throttle
|
||||
|
@ -1,61 +0,0 @@
|
||||
package com.gmail.nossr50.runnables.commands;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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 {
|
||||
private final String playerName;
|
||||
private final CommandSender sender;
|
||||
|
||||
public McrankCommandAsyncTask(String playerName, CommandSender sender) {
|
||||
this.playerName = playerName;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final Map<String, Integer> skills = DatabaseManager.readSQLRank(playerName);
|
||||
|
||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(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 (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((sender instanceof Player) && !Permissions.skillEnabled((Player) sender, skillType)) {
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package com.gmail.nossr50.runnables.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
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.StringUtils;
|
||||
|
||||
public class MctopCommandAsyncTask implements Runnable {
|
||||
|
||||
private CommandSender sender;
|
||||
private String query;
|
||||
private int page;
|
||||
private Command command;
|
||||
|
||||
public MctopCommandAsyncTask(int page, String query, CommandSender sender, Command command) {
|
||||
this.page = page;
|
||||
this.query = query;
|
||||
this.sender = sender;
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
||||
if (!Permissions.mctop(sender, SkillType.getSkill(query))) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
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().scheduleSyncDelayedTask(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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user