mirror of
https://github.com/filoghost/ChestCommands.git
synced 2025-02-19 04:51:23 +01:00
Rename methods
This commit is contained in:
parent
decb0eb039
commit
f0aa5347ee
@ -131,13 +131,13 @@ public class AdvancedIcon extends ConfigurableIconImpl {
|
||||
@Override
|
||||
public boolean onClick(Inventory inventory, Player player) {
|
||||
// Check all the requirements
|
||||
boolean hasAllRequirements = Requirement.checkAll(player, clickPermission, requiredMoney, requiredExpLevel, requiredItems);
|
||||
boolean hasAllRequirements = Requirement.hasAll(player, clickPermission, requiredMoney, requiredExpLevel, requiredItems);
|
||||
if (!hasAllRequirements) {
|
||||
return closeOnClick;
|
||||
}
|
||||
|
||||
// If all requirements are satisfied, take their cost
|
||||
boolean takenAllCosts = Requirement.takeCostAll(player, clickPermission, requiredMoney, requiredExpLevel, requiredItems);
|
||||
boolean takenAllCosts = Requirement.takeAllCosts(player, clickPermission, requiredMoney, requiredExpLevel, requiredItems);
|
||||
if (!takenAllCosts) {
|
||||
return closeOnClick;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class PermissionChecker implements Requirement {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(Player player) {
|
||||
public boolean hasCost(Player player) {
|
||||
if (hasPermission(player)) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -34,7 +34,7 @@ public class RequiredExpLevel implements Requirement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(Player player) {
|
||||
public boolean hasCost(Player player) {
|
||||
if (player.getLevel() < levels) {
|
||||
player.sendMessage(ChestCommands.getLang().no_exp.replace("{levels}", Integer.toString(levels)));
|
||||
return false;
|
||||
|
@ -38,7 +38,7 @@ public class RequiredItems implements Requirement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(Player player) {
|
||||
public boolean hasCost(Player player) {
|
||||
boolean missingItems = false;
|
||||
|
||||
for (RequiredItem item : items) {
|
||||
|
@ -36,7 +36,7 @@ public class RequiredMoney implements Requirement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(Player player) {
|
||||
public boolean hasCost(Player player) {
|
||||
if (!VaultEconomyHook.INSTANCE.isEnabled()) {
|
||||
player.sendMessage(ChatColor.RED + "This action has a price, but Vault with a compatible economy plugin was not found. For security, the action has been blocked. Please inform the staff.");
|
||||
return false;
|
||||
|
@ -1,48 +1,48 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package me.filoghost.chestcommands.menu.icon;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface Requirement {
|
||||
|
||||
boolean check(Player player);
|
||||
|
||||
boolean takeCost(Player player);
|
||||
|
||||
public static boolean checkAll(Player player, Requirement... requirements) {
|
||||
for (Requirement requirement : requirements) {
|
||||
if (requirement != null && !requirement.check(player)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean takeCostAll(Player player, Requirement... requirements) {
|
||||
for (Requirement requirement : requirements) {
|
||||
if (requirement != null) {
|
||||
boolean success = requirement.takeCost(player);
|
||||
if (!success) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package me.filoghost.chestcommands.menu.icon;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface Requirement {
|
||||
|
||||
boolean hasCost(Player player);
|
||||
|
||||
boolean takeCost(Player player);
|
||||
|
||||
static boolean hasAll(Player player, Requirement... requirements) {
|
||||
for (Requirement requirement : requirements) {
|
||||
if (requirement != null && !requirement.hasCost(player)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean takeAllCosts(Player player, Requirement... requirements) {
|
||||
for (Requirement requirement : requirements) {
|
||||
if (requirement != null) {
|
||||
boolean success = requirement.takeCost(player);
|
||||
if (!success) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user