addon-challenges/src/main/java/world/bentobox/challenges/commands/admin/ChallengesGlobalAdminComman...

88 lines
2.3 KiB
Java
Raw Normal View History

package world.bentobox.challenges.commands.admin;
import java.util.List;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.panel.user.GameModePanel;
import world.bentobox.challenges.utils.Constants;
import world.bentobox.challenges.utils.Utils;
/**
* This class provides all necessary thing to implement challenges admin command
*/
public class ChallengesGlobalAdminCommand extends CompositeCommand
{
/**
* Constructor that init command with given string.
* @param addon Challenges Addon
* @param gameModeAddons List with GameModes where challenges addon operates.
*/
public ChallengesGlobalAdminCommand(ChallengesAddon addon, List<GameModeAddon> gameModeAddons)
{
super(addon,
addon.getChallengesSettings().getAdminGlobalCommand().split(" ")[0],
addon.getChallengesSettings().getAdminGlobalCommand().split(" "));
this.gameModeAddons = gameModeAddons;
}
/**
* {@inheritDoc}
*/
@Override
public void setup()
{
this.setPermission("admin.challenges");
this.setParametersHelp("challenges.commands.admin.main.parameters");
this.setDescription("challenges.commands.admin.main.description");
}
/**
* {@inheritDoc}
*/
@Override
public boolean execute(User user, String label, List<String> args)
{
// For single game mode just open correct gui.
if (this.gameModeAddons.isEmpty())
{
Release 1.2.0 (#317) * Init 1.2.0 version * Fixes #311 localization errors in zn-CN. Original translation author translated `[]` placeholders which broke locale * Init 1.2.0 version * Edit some unfit translation (#312) Edit some unfit translation * Fixes a regex bug that replaced every [player] char instead of whole word. * Fixes a crash that prevented STATISTICS entity and material/item challenges to be completed. * Add requirement-not-met-material and requirement-not-met-entity to display statistic required item on error. * Add locale of Chinese-Hong Kong (zh-HK) (#313) Addition of locale updated to latest version * Add ${argLine} to get jacoco coverage * Updated Jacoco POM section * Update build.yml Java 17 for Surefire * Updated pladdon annotations * Add support for gamemode-specific translations. This was a request from Floris * Update ChallengesManagerTest methods with world parameter. * Implement option that excludes undeployed challenges The new option allows to toggle if undeployed challenges should be included in level completion count. Disabling option will not include these challenges for level completion. Fixes #315 * Create plugin.yml (#316) * Create plugin.yml * Update pom.xml * Update ChallengesPladdon.java * Remove dependency to org.apache.commons Replace org.apache.commons.lang.ArrayUtils to a default Java implementation. --------- Co-authored-by: EpicMo <1982742309@qq.com> Co-authored-by: JamesMCL44 <epicquarters@gmail.com> Co-authored-by: tastybento <tastybento@users.noreply.github.com> Co-authored-by: tastybento <tastybento@wasteofplastic.com>
2023-04-15 21:55:34 +02:00
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "not-hooked");
return false;
}
else if (this.gameModeAddons.size() == 1)
{
this.gameModeAddons.get(0).getAdminCommand().ifPresent(compositeCommand ->
user.performCommand(compositeCommand.getTopLabel() + " " +
this.<ChallengesAddon>getAddon().getChallengesSettings().getAdminMainCommand().split(" ")[0]));
}
else
{
GameModePanel.open(this.getAddon(),
this.getWorld(),
user,
this.gameModeAddons,
true);
}
return true;
}
// ---------------------------------------------------------------------
// Section: Variables
// ---------------------------------------------------------------------
/**
* This variable stores List with game modes where challenges addon are hooked in.
*/
private final List<GameModeAddon> gameModeAddons;
}