mirror of
https://github.com/bloodmc/GriefDefender.git
synced 2024-11-25 12:45:48 +01:00
Fix giveblocks command with negative amounts.
This commit is contained in:
parent
2ccd881bb6
commit
c4543827eb
@ -38,6 +38,11 @@ public class CommandGiveBlocks extends BaseCommand {
|
|||||||
@Syntax("<player> <amount>")
|
@Syntax("<player> <amount>")
|
||||||
@Subcommand("giveblocks")
|
@Subcommand("giveblocks")
|
||||||
public void execute(Player src, OfflinePlayer targetPlayer, int amount) {
|
public void execute(Player src, OfflinePlayer targetPlayer, int amount) {
|
||||||
|
if (amount <= 0) {
|
||||||
|
TextAdapter.sendComponent(src, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.COMMAND_INVALID_AMOUNT));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(src.getWorld(), src.getUniqueId());
|
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(src.getWorld(), src.getUniqueId());
|
||||||
int availableBlocks = playerData.getAccruedClaimBlocks() + playerData.getBonusClaimBlocks();
|
int availableBlocks = playerData.getAccruedClaimBlocks() + playerData.getBonusClaimBlocks();
|
||||||
if (amount > availableBlocks) {
|
if (amount > availableBlocks) {
|
||||||
|
@ -37,6 +37,11 @@ public class CommandGiveBlocks extends BaseCommand {
|
|||||||
@Syntax("<player> <amount>")
|
@Syntax("<player> <amount>")
|
||||||
@Subcommand("giveblocks")
|
@Subcommand("giveblocks")
|
||||||
public void execute(Player src, User targetPlayer, int amount) {
|
public void execute(Player src, User targetPlayer, int amount) {
|
||||||
|
if (amount <= 0) {
|
||||||
|
TextAdapter.sendComponent(src, GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.COMMAND_INVALID_AMOUNT));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(src.getWorld(), src.getUniqueId());
|
final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(src.getWorld(), src.getUniqueId());
|
||||||
int availableBlocks = playerData.getAccruedClaimBlocks() + playerData.getBonusClaimBlocks();
|
int availableBlocks = playerData.getAccruedClaimBlocks() + playerData.getBonusClaimBlocks();
|
||||||
if (amount > availableBlocks) {
|
if (amount > availableBlocks) {
|
||||||
|
Loading…
Reference in New Issue
Block a user