mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-01 00:11:37 +01:00
Implement ability to Fix player Data from GUI.
Fix issue when accept and decline buttons were with wrong names.
This commit is contained in:
parent
7f399b2961
commit
78fa459aa4
@ -1077,4 +1077,39 @@ public class ChallengesManager
|
||||
this.levelDatabase.deleteObject(challengeLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Section: Fix world duplication issue.
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* This allows to fix player data issue when world name is duplicated.
|
||||
* @deprecated Will be removed in 0.7.0 release.
|
||||
*/
|
||||
@Deprecated
|
||||
public void fixCorruptedPlayerData()
|
||||
{
|
||||
this.playersDatabase.loadObjects().forEach(playerData -> {
|
||||
Map<String, Integer> completed = playerData.getChallengeStatus();
|
||||
Map<String, Long> timeStamps = playerData.getChallengesTimestamp();
|
||||
|
||||
new ArrayList<>(completed.keySet()).forEach(challenge -> {
|
||||
String correctName = challenge.replaceFirst("(\\w+)(?=(\\1))", "");
|
||||
if (!correctName.isEmpty() && !correctName.equals(challenge))
|
||||
{
|
||||
completed.put(correctName, completed.get(challenge));
|
||||
timeStamps.put(correctName, timeStamps.get(challenge));
|
||||
|
||||
completed.remove(challenge);
|
||||
timeStamps.remove(challenge);
|
||||
this.addon.log("ChallengeString was modified " + challenge + " was changed to " + correctName);
|
||||
}
|
||||
});
|
||||
|
||||
this.playerCacheData.put(UUID.fromString(playerData.getUniqueId()), playerData);
|
||||
this.savePlayer(UUID.fromString(playerData.getUniqueId()));
|
||||
});
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
import world.bentobox.challenges.ChallengesAddon;
|
||||
import world.bentobox.challenges.panel.CommonGUI;
|
||||
import world.bentobox.challenges.panel.util.ConfirmationGUI;
|
||||
import world.bentobox.challenges.utils.GuiUtils;
|
||||
|
||||
|
||||
@ -55,6 +56,7 @@ public class AdminGUI extends CommonGUI
|
||||
DELETE_LEVEL,
|
||||
IMPORT_CHALLENGES,
|
||||
BACKWARD_CHALLENGES,
|
||||
BACKWARD_PLAYER_DATA,
|
||||
EDIT_SETTINGS
|
||||
}
|
||||
|
||||
@ -111,6 +113,7 @@ public class AdminGUI extends CommonGUI
|
||||
// Import Challenges
|
||||
panelBuilder.item(15, this.createButton(Button.IMPORT_CHALLENGES));
|
||||
panelBuilder.item(24, this.createButton(Button.BACKWARD_CHALLENGES));
|
||||
panelBuilder.item(33, this.createButton(Button.BACKWARD_PLAYER_DATA));
|
||||
|
||||
// Edit Addon Settings
|
||||
panelBuilder.item(16, this.createButton(Button.EDIT_SETTINGS));
|
||||
@ -388,6 +391,30 @@ public class AdminGUI extends CommonGUI
|
||||
|
||||
break;
|
||||
}
|
||||
case BACKWARD_PLAYER_DATA:
|
||||
{
|
||||
permissionSuffix = IMPORT;
|
||||
|
||||
name = this.user.getTranslation("challenges.gui.buttons.admin.backward-player");
|
||||
description = this.user.getTranslation("challenges.gui.descriptions.admin.backward-player");
|
||||
icon = new ItemStack(Material.HOPPER);
|
||||
clickHandler = (panel, user, clickType, slot) -> {
|
||||
|
||||
new ConfirmationGUI(this.user, status -> {
|
||||
if (status)
|
||||
{
|
||||
this.addon.getChallengesManager().fixCorruptedPlayerData();
|
||||
}
|
||||
|
||||
this.build();
|
||||
});
|
||||
|
||||
return true;
|
||||
};
|
||||
glow = false;
|
||||
|
||||
break;
|
||||
}
|
||||
case EDIT_SETTINGS:
|
||||
{
|
||||
permissionSuffix = SETTINGS;
|
||||
|
@ -88,8 +88,8 @@ public class ConfirmationGUI
|
||||
private PanelItem getButton(boolean returnValue)
|
||||
{
|
||||
return new PanelItemBuilder().
|
||||
name(this.user.getTranslation("challenges.gui.admin.buttons." + (returnValue ? "accept" : "cancel"))).
|
||||
icon(returnValue ? Material.GRAY_STAINED_GLASS_PANE : Material.RED_STAINED_GLASS_PANE).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.admin." + (returnValue ? "accept" : "cancel"))).
|
||||
icon(returnValue ? Material.GREEN_STAINED_GLASS_PANE : Material.RED_STAINED_GLASS_PANE).
|
||||
clickHandler((panel, user1, clickType, i) -> {
|
||||
this.consumer.accept(returnValue);
|
||||
return true;
|
||||
|
@ -69,6 +69,7 @@ challenges:
|
||||
delete-level: 'Remove level'
|
||||
import: 'Import ASkyblock Challenges'
|
||||
backward: 'Import 0.3.0 Challenges'
|
||||
backward-player: 'Fix 0.3.0 PlayerData'
|
||||
settings: 'Edit Settings'
|
||||
properties: 'Properties'
|
||||
requirements: 'Requirements'
|
||||
@ -157,6 +158,7 @@ challenges:
|
||||
delete-challenge: 'Allows remove any Challenge.'
|
||||
delete-level: 'Allows remove any Level.'
|
||||
backward: 'Allows to import challenges from 0.3.0 and below addon version.'
|
||||
backward-player: 'Allows to fix corrupted PlayerData from 0.3.0 version.|&2USE ONLY IF NECESSARY|&2MAY NOT WORK IN ALL SITUATIONS'
|
||||
settings: 'Allows to change addon settings.'
|
||||
properties: 'Allows to change general properties'
|
||||
requirements: 'Allows to manage requirements'
|
||||
@ -305,4 +307,4 @@ challenges:
|
||||
import-no-file: '&cCould not find challenges.yml file to import!'
|
||||
no-load: '&cError: Could not load challenges.yml. [message]'
|
||||
load-error: '&cError: Cannot load [value].'
|
||||
version: 5
|
||||
version: 6
|
Loading…
Reference in New Issue
Block a user