mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2025-02-11 09:51:44 +01:00
Implement ConfirmationGUIs in Delete operation for ListLevelsGUI and ListChallengesGUI.
This commit is contained in:
parent
29dadf3841
commit
13291b450c
@ -527,4 +527,16 @@ public class ChallengesManager {
|
||||
{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
public void deleteChallenge(Challenges selectedChallenge)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void deleteChallengeLevel(ChallengeLevels valueObject)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.challenges.ChallengesAddon;
|
||||
import world.bentobox.challenges.database.object.Challenges;
|
||||
import world.bentobox.challenges.panel.CommonGUI;
|
||||
import world.bentobox.challenges.panel.util.ConfirmationGUI;
|
||||
|
||||
|
||||
/**
|
||||
@ -140,7 +141,8 @@ public class ListChallengesGUI extends CommonGUI
|
||||
else if (this.currentMode.equals(Mode.DELETE))
|
||||
{
|
||||
itemBuilder.clickHandler((panel, user1, clickType, i) -> {
|
||||
// TODO: Conformation GUI for DELETING.
|
||||
new ConfirmationGUI(this, this.user);
|
||||
this.valueObject = challenge;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@ -149,6 +151,25 @@ public class ListChallengesGUI extends CommonGUI
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Overwriting set value allows to catch if ConfirmationGui returns true.
|
||||
* @param value new Value of valueObject.
|
||||
*/
|
||||
@Override
|
||||
public void setValue(Object value)
|
||||
{
|
||||
if (value instanceof Boolean && ((Boolean) value) && this.valueObject != null)
|
||||
{
|
||||
this.addon.getChallengesManager().deleteChallenge((Challenges) this.valueObject);
|
||||
this.valueObject = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.valueObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Section: Enums
|
||||
// ---------------------------------------------------------------------
|
||||
|
@ -2,7 +2,6 @@ package world.bentobox.challenges.panel.admin;
|
||||
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import world.bentobox.bentobox.api.panels.PanelItem;
|
||||
@ -12,6 +11,7 @@ import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.challenges.ChallengesAddon;
|
||||
import world.bentobox.challenges.database.object.ChallengeLevels;
|
||||
import world.bentobox.challenges.panel.CommonGUI;
|
||||
import world.bentobox.challenges.panel.util.ConfirmationGUI;
|
||||
|
||||
|
||||
/**
|
||||
@ -141,7 +141,8 @@ public class ListLevelsGUI extends CommonGUI
|
||||
else if (this.currentMode.equals(Mode.DELETE))
|
||||
{
|
||||
itemBuilder.clickHandler((panel, user1, clickType, i) -> {
|
||||
// TODO: Conformation GUI for DELETING.
|
||||
new ConfirmationGUI(this, this.user);
|
||||
this.valueObject = challengeLevel;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@ -150,6 +151,25 @@ public class ListLevelsGUI extends CommonGUI
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Overwriting set value allows to catch if ConfirmationGui returns true.
|
||||
* @param value new Value of valueObject.
|
||||
*/
|
||||
@Override
|
||||
public void setValue(Object value)
|
||||
{
|
||||
if (value instanceof Boolean && ((Boolean) value) && this.valueObject != null)
|
||||
{
|
||||
this.addon.getChallengesManager().deleteChallengeLevel((ChallengeLevels) this.valueObject);
|
||||
this.valueObject = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.valueObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Section: Enums
|
||||
// ---------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user