mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Prevent players from having more than one database querying command running at once.
This commit is contained in:
parent
d8ad519cd0
commit
d687543910
@ -7,6 +7,8 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -17,7 +19,6 @@ import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McrankCommand implements TabExecutor {
|
||||
@ -88,6 +89,13 @@ public class McrankCommand implements TabExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (((Player) sender).hasMetadata(mcMMO.databaseCommandKey)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing"));
|
||||
return;
|
||||
} else {
|
||||
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null));
|
||||
}
|
||||
|
||||
mcMMOPlayer.actualizeDatabaseATS();
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -19,7 +20,6 @@ import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MctopCommand implements TabExecutor {
|
||||
@ -91,6 +91,13 @@ public class MctopCommand implements TabExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (((Player) sender).hasMetadata(mcMMO.databaseCommandKey)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing"));
|
||||
return;
|
||||
} else {
|
||||
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null));
|
||||
}
|
||||
|
||||
mcMMOPlayer.actualizeDatabaseATS();
|
||||
}
|
||||
|
||||
|
@ -116,6 +116,7 @@ public class mcMMO extends JavaPlugin {
|
||||
public final static String playerDataKey = "mcMMO: Player Data";
|
||||
public final static String greenThumbDataKey = "mcMMO: Green Thumb";
|
||||
public final static String pistonDataKey = "mcMMO: Piston State";
|
||||
public final static String databaseCommandKey = "mcMMO: Processing Database Command";
|
||||
|
||||
public static FixedMetadataValue metadataValue;
|
||||
|
||||
|
@ -57,6 +57,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
|
||||
rank = skills.get(null);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", (rank == null ? LocaleLoader.getString("Commands.mcrank.Unranked") : rank)));
|
||||
player.removeMetadata(mcMMO.databaseCommandKey, mcMMO.p);
|
||||
}
|
||||
|
||||
public void displayBoard() {
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@ -61,6 +62,9 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
|
||||
sender.sendMessage(String.format("%2d. %s%s - %s%s", place, ChatColor.GREEN, stat.name, ChatColor.WHITE, stat.statVal));
|
||||
place++;
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
((Player) sender).removeMetadata(mcMMO.databaseCommandKey, mcMMO.p);
|
||||
}
|
||||
}
|
||||
|
||||
private void displayBoard() {
|
||||
|
@ -454,6 +454,7 @@ Commands.Cooldowns.Header=[[GOLD]]--= [[GREEN]]mcMMO Ability Cooldowns[[GOLD]] =
|
||||
Commands.Cooldowns.Row.N=\ [[RED]]{0}[[WHITE]] - [[GOLD]]{1} seconds left
|
||||
Commands.Cooldowns.Row.Y=\ [[AQUA]]{0}[[WHITE]] - [[DARK_GREEN]]Ready!
|
||||
Commands.Database.Cooldown=[[RED]]You must wait 1 second before using this command again.
|
||||
Commands.Database.Processing=[[RED]]Your previous command is still being processed. Please wait.
|
||||
Commands.Disabled=[[RED]]This command is disabled.
|
||||
Commands.DoesNotExist= [[RED]]Player does not exist in the database!
|
||||
Commands.GodMode.Disabled=[[YELLOW]]mcMMO Godmode Disabled
|
||||
|
Loading…
Reference in New Issue
Block a user