mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06: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.CommandSender;
|
||||||
import org.bukkit.command.TabExecutor;
|
import org.bukkit.command.TabExecutor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
import org.bukkit.metadata.MetadataValue;
|
||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
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.Permissions;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class McrankCommand implements TabExecutor {
|
public class McrankCommand implements TabExecutor {
|
||||||
@ -88,6 +89,13 @@ public class McrankCommand implements TabExecutor {
|
|||||||
return;
|
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();
|
mcMMOPlayer.actualizeDatabaseATS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabExecutor;
|
import org.bukkit.command.TabExecutor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
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.StringUtils;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class MctopCommand implements TabExecutor {
|
public class MctopCommand implements TabExecutor {
|
||||||
@ -91,6 +91,13 @@ public class MctopCommand implements TabExecutor {
|
|||||||
return;
|
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();
|
mcMMOPlayer.actualizeDatabaseATS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +116,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
public final static String playerDataKey = "mcMMO: Player Data";
|
public final static String playerDataKey = "mcMMO: Player Data";
|
||||||
public final static String greenThumbDataKey = "mcMMO: Green Thumb";
|
public final static String greenThumbDataKey = "mcMMO: Green Thumb";
|
||||||
public final static String pistonDataKey = "mcMMO: Piston State";
|
public final static String pistonDataKey = "mcMMO: Piston State";
|
||||||
|
public final static String databaseCommandKey = "mcMMO: Processing Database Command";
|
||||||
|
|
||||||
public static FixedMetadataValue metadataValue;
|
public static FixedMetadataValue metadataValue;
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
|||||||
|
|
||||||
rank = skills.get(null);
|
rank = skills.get(null);
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", (rank == null ? LocaleLoader.getString("Commands.mcrank.Unranked") : rank)));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", (rank == null ? LocaleLoader.getString("Commands.mcrank.Unranked") : rank)));
|
||||||
|
player.removeMetadata(mcMMO.databaseCommandKey, mcMMO.p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayBoard() {
|
public void displayBoard() {
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
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));
|
sender.sendMessage(String.format("%2d. %s%s - %s%s", place, ChatColor.GREEN, stat.name, ChatColor.WHITE, stat.statVal));
|
||||||
place++;
|
place++;
|
||||||
}
|
}
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
((Player) sender).removeMetadata(mcMMO.databaseCommandKey, mcMMO.p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayBoard() {
|
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.N=\ [[RED]]{0}[[WHITE]] - [[GOLD]]{1} seconds left
|
||||||
Commands.Cooldowns.Row.Y=\ [[AQUA]]{0}[[WHITE]] - [[DARK_GREEN]]Ready!
|
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.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.Disabled=[[RED]]This command is disabled.
|
||||||
Commands.DoesNotExist= [[RED]]Player does not exist in the database!
|
Commands.DoesNotExist= [[RED]]Player does not exist in the database!
|
||||||
Commands.GodMode.Disabled=[[YELLOW]]mcMMO Godmode Disabled
|
Commands.GodMode.Disabled=[[YELLOW]]mcMMO Godmode Disabled
|
||||||
|
Loading…
Reference in New Issue
Block a user