mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2025-01-15 20:51:45 +01:00
Improve Wipe Button behaviour.
Add 2 new buttons: - User wipe - deletes all challenges addon player data. - challenges wipe - deletes only challenges and levels. By clicking on challenges wipe with right click, it will switch to compelte wipe, and via versa.
This commit is contained in:
parent
ecbb8ef1f2
commit
a5022bea7a
@ -488,12 +488,17 @@ public class ChallengesManager
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method removes all challenges addon data from Database.
|
* This method removes all challenges addon data from Database.
|
||||||
|
* @param complete Remove also user data.
|
||||||
*/
|
*/
|
||||||
public void wipeDatabase()
|
public void wipeDatabase(boolean complete)
|
||||||
{
|
{
|
||||||
this.wipeLevels();
|
this.wipeLevels();
|
||||||
this.wipeChallenges();
|
this.wipeChallenges();
|
||||||
this.wipePlayers();
|
|
||||||
|
if (complete)
|
||||||
|
{
|
||||||
|
this.wipePlayers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -527,7 +532,7 @@ public class ChallengesManager
|
|||||||
* This method collects all data from players database and removes them.
|
* This method collects all data from players database and removes them.
|
||||||
* Also clears players cache data.
|
* Also clears players cache data.
|
||||||
*/
|
*/
|
||||||
private void wipePlayers()
|
public void wipePlayers()
|
||||||
{
|
{
|
||||||
List<ChallengesPlayerData> playerDataList = this.playersDatabase.loadObjects();
|
List<ChallengesPlayerData> playerDataList = this.playersDatabase.loadObjects();
|
||||||
|
|
||||||
|
@ -68,7 +68,21 @@ public class AdminGUI extends CommonGUI
|
|||||||
EDIT_SETTINGS,
|
EDIT_SETTINGS,
|
||||||
DEFAULT_IMPORT_CHALLENGES,
|
DEFAULT_IMPORT_CHALLENGES,
|
||||||
DEFAULT_EXPORT_CHALLENGES,
|
DEFAULT_EXPORT_CHALLENGES,
|
||||||
|
/**
|
||||||
|
* Allows to remove whole database
|
||||||
|
*/
|
||||||
COMPLETE_WIPE,
|
COMPLETE_WIPE,
|
||||||
|
/**
|
||||||
|
* Allows to remove only challenges and levels
|
||||||
|
*/
|
||||||
|
CHALLENGE_WIPE,
|
||||||
|
/**
|
||||||
|
* Allows to remove only players data
|
||||||
|
*/
|
||||||
|
USER_WIPE,
|
||||||
|
/**
|
||||||
|
* Allows to access Web Library
|
||||||
|
*/
|
||||||
LIBRARY
|
LIBRARY
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,6 +127,9 @@ public class AdminGUI extends CommonGUI
|
|||||||
panelBuilder.item(10, this.createButton(Button.COMPLETE_USER_CHALLENGES));
|
panelBuilder.item(10, this.createButton(Button.COMPLETE_USER_CHALLENGES));
|
||||||
panelBuilder.item(19, this.createButton(Button.RESET_USER_CHALLENGES));
|
panelBuilder.item(19, this.createButton(Button.RESET_USER_CHALLENGES));
|
||||||
|
|
||||||
|
// Add All Player Data removal.
|
||||||
|
panelBuilder.item(28, this.createButton(Button.USER_WIPE));
|
||||||
|
|
||||||
// Add Challenges
|
// Add Challenges
|
||||||
panelBuilder.item(12, this.createButton(Button.ADD_CHALLENGE));
|
panelBuilder.item(12, this.createButton(Button.ADD_CHALLENGE));
|
||||||
panelBuilder.item(13, this.createButton(Button.ADD_LEVEL));
|
panelBuilder.item(13, this.createButton(Button.ADD_LEVEL));
|
||||||
@ -137,7 +154,7 @@ public class AdminGUI extends CommonGUI
|
|||||||
panelBuilder.item(16, this.createButton(Button.EDIT_SETTINGS));
|
panelBuilder.item(16, this.createButton(Button.EDIT_SETTINGS));
|
||||||
|
|
||||||
// Button that deletes everything from challenges addon
|
// Button that deletes everything from challenges addon
|
||||||
panelBuilder.item(34, this.createButton(Button.COMPLETE_WIPE));
|
panelBuilder.item(34, this.createButton(Button.CHALLENGE_WIPE));
|
||||||
|
|
||||||
panelBuilder.item(44, this.returnButton);
|
panelBuilder.item(44, this.returnButton);
|
||||||
|
|
||||||
@ -431,11 +448,77 @@ public class AdminGUI extends CommonGUI
|
|||||||
description = this.user.getTranslation("challenges.gui.descriptions.admin.complete-wipe");
|
description = this.user.getTranslation("challenges.gui.descriptions.admin.complete-wipe");
|
||||||
icon = new ItemStack(Material.TNT);
|
icon = new ItemStack(Material.TNT);
|
||||||
clickHandler = (panel, user, clickType, slot) -> {
|
clickHandler = (panel, user, clickType, slot) -> {
|
||||||
|
|
||||||
|
if (clickType.isRightClick())
|
||||||
|
{
|
||||||
|
panel.getInventory().setItem(slot, this.createButton(Button.CHALLENGE_WIPE).getItem());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
new ConfirmationGUI(this.user, value -> {
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
this.addon.getChallengesManager().wipeDatabase(false);
|
||||||
|
this.user.sendMessage("challenges.messages.admin.complete-wipe");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.build();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
glow = true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CHALLENGE_WIPE:
|
||||||
|
{
|
||||||
|
permissionSuffix = WIPE;
|
||||||
|
|
||||||
|
name = this.user.getTranslation("challenges.gui.buttons.admin.challenge-wipe");
|
||||||
|
description = this.user.getTranslation("challenges.gui.descriptions.admin.challenge-wipe");
|
||||||
|
icon = new ItemStack(Material.TNT);
|
||||||
|
clickHandler = (panel, user, clickType, slot) -> {
|
||||||
|
|
||||||
|
if (clickType.isRightClick())
|
||||||
|
{
|
||||||
|
panel.getInventory().setItem(slot, this.createButton(Button.COMPLETE_WIPE).getItem());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new ConfirmationGUI(this.user, value -> {
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
this.addon.getChallengesManager().wipeDatabase(false);
|
||||||
|
this.user.sendMessage("challenges.messages.admin.challenge-wipe");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.build();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
glow = false;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case USER_WIPE:
|
||||||
|
{
|
||||||
|
permissionSuffix = WIPE;
|
||||||
|
|
||||||
|
name = this.user.getTranslation("challenges.gui.buttons.admin.players-wipe");
|
||||||
|
description = this.user.getTranslation("challenges.gui.descriptions.admin.players-wipe");
|
||||||
|
icon = new ItemStack(Material.TNT);
|
||||||
|
clickHandler = (panel, user, clickType, slot) -> {
|
||||||
|
|
||||||
new ConfirmationGUI(this.user, value -> {
|
new ConfirmationGUI(this.user, value -> {
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
this.addon.getChallengesManager().wipeDatabase();
|
this.addon.getChallengesManager().wipePlayers();
|
||||||
this.user.sendMessage("challenges.messages.admin.complete-wipe");
|
this.user.sendMessage("challenges.messages.admin.players-wipe");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.build();
|
this.build();
|
||||||
|
@ -167,6 +167,8 @@ challenges:
|
|||||||
default-import: 'Import Default Challenges'
|
default-import: 'Import Default Challenges'
|
||||||
default-export: 'Export Existing Challenges'
|
default-export: 'Export Existing Challenges'
|
||||||
complete-wipe: 'Wipe Addon Databases'
|
complete-wipe: 'Wipe Addon Databases'
|
||||||
|
challenge-wipe: 'Wipe Challenges Database'
|
||||||
|
players-wipe: 'Wipe User Database'
|
||||||
|
|
||||||
library: 'Web Library'
|
library: 'Web Library'
|
||||||
download: 'Download Libraries'
|
download: 'Download Libraries'
|
||||||
@ -271,6 +273,9 @@ challenges:
|
|||||||
default-export: 'Allows to export existing challenges into defaults.json file.'
|
default-export: 'Allows to export existing challenges into defaults.json file.'
|
||||||
complete-wipe: 'Allows to completely clear all challenges addon databases. Includes player data!'
|
complete-wipe: 'Allows to completely clear all challenges addon databases. Includes player data!'
|
||||||
|
|
||||||
|
challenge-wipe: 'Allows to completely clear challenges and their level databases!'
|
||||||
|
players-wipe: 'Allows to completely clear player database!'
|
||||||
|
|
||||||
library: 'Opens GUI that shows all available public Challenges Libraries.'
|
library: 'Opens GUI that shows all available public Challenges Libraries.'
|
||||||
|
|
||||||
library-author: 'by &e[author]'
|
library-author: 'by &e[author]'
|
||||||
@ -401,6 +406,10 @@ challenges:
|
|||||||
you-added: 'You added one [thing] to the challenge'
|
you-added: 'You added one [thing] to the challenge'
|
||||||
challenge-created: '[challenge]&r created!'
|
challenge-created: '[challenge]&r created!'
|
||||||
complete-wipe: '&cHope you have backups, as you just empty all Challenges Addon databases!'
|
complete-wipe: '&cHope you have backups, as you just empty all Challenges Addon databases!'
|
||||||
|
|
||||||
|
challenge-wipe: '&cHope you have backups, as you just empty Challenges and their levels from databases!'
|
||||||
|
players-wipe: '&cHope you have backups, as you just empty player completed challenges from databases!'
|
||||||
|
|
||||||
completed: '&2You completed challenge [name] for [player]!'
|
completed: '&2You completed challenge [name] for [player]!'
|
||||||
already-completed: '&2This challenge was already completed!'
|
already-completed: '&2This challenge was already completed!'
|
||||||
reset: '&2You reset challenge [name] for [player]!'
|
reset: '&2You reset challenge [name] for [player]!'
|
||||||
|
Loading…
Reference in New Issue
Block a user