mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2025-02-17 21:02:17 +01:00
Implement existing GUIs in EditChallengeGUI.
Change Challenges.environment from list to set.
This commit is contained in:
parent
865fa626af
commit
1d0f090948
@ -1,20 +1,15 @@
|
|||||||
package world.bentobox.challenges.database.object;
|
package world.bentobox.challenges.database.object;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import world.bentobox.challenges.ChallengesManager;
|
|
||||||
import world.bentobox.bentobox.api.configuration.ConfigComment;
|
import world.bentobox.bentobox.api.configuration.ConfigComment;
|
||||||
import world.bentobox.bentobox.database.objects.DataObject;
|
import world.bentobox.bentobox.database.objects.DataObject;
|
||||||
|
import world.bentobox.challenges.ChallengesManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data object for challenges
|
* Data object for challenges
|
||||||
@ -103,7 +98,7 @@ public class Challenges implements DataObject {
|
|||||||
@ConfigComment("World where this challenge operates. List only overworld. Nether and end are automatically covered.")
|
@ConfigComment("World where this challenge operates. List only overworld. Nether and end are automatically covered.")
|
||||||
private String world = "";
|
private String world = "";
|
||||||
@ConfigComment("List of environments where this challenge will occur: NETHER, NORMAL, THE_END. Leave blank for all.")
|
@ConfigComment("List of environments where this challenge will occur: NETHER, NORMAL, THE_END. Leave blank for all.")
|
||||||
private List<World.Environment> environment = new ArrayList<>();
|
private Set<World.Environment> environment = new HashSet<>();
|
||||||
@ConfigComment("The required permissions to see this challenge. String list.")
|
@ConfigComment("The required permissions to see this challenge. String list.")
|
||||||
private Set<String> reqPerms = new HashSet<>();
|
private Set<String> reqPerms = new HashSet<>();
|
||||||
@ConfigComment("The number of blocks around the player to search for items on an island")
|
@ConfigComment("The number of blocks around the player to search for items on an island")
|
||||||
@ -591,14 +586,14 @@ public class Challenges implements DataObject {
|
|||||||
/**
|
/**
|
||||||
* @return the environment
|
* @return the environment
|
||||||
*/
|
*/
|
||||||
public List<World.Environment> getEnvironment() {
|
public Set<World.Environment> getEnvironment() {
|
||||||
return environment;
|
return environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param environment the environment to set
|
* @param environment the environment to set
|
||||||
*/
|
*/
|
||||||
public void setEnvironment(List<World.Environment> environment) {
|
public void setEnvironment(Set<World.Environment> environment) {
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,17 +5,19 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import net.wesjd.anvilgui.AnvilGUI;
|
||||||
import world.bentobox.bentobox.api.panels.PanelItem;
|
import world.bentobox.bentobox.api.panels.PanelItem;
|
||||||
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
import world.bentobox.bentobox.util.ItemParser;
|
||||||
import world.bentobox.challenges.ChallengesAddon;
|
import world.bentobox.challenges.ChallengesAddon;
|
||||||
import world.bentobox.challenges.database.object.Challenges;
|
import world.bentobox.challenges.database.object.Challenges;
|
||||||
import world.bentobox.challenges.panel.CommonGUI;
|
import world.bentobox.challenges.panel.CommonGUI;
|
||||||
import world.bentobox.challenges.panel.util.ItemSwitchGUI;
|
import world.bentobox.challenges.panel.util.ItemSwitchGUI;
|
||||||
import world.bentobox.challenges.panel.util.NumberGUI;
|
import world.bentobox.challenges.panel.util.NumberGUI;
|
||||||
|
import world.bentobox.challenges.panel.util.SelectEnvironmentGUI;
|
||||||
import world.bentobox.challenges.panel.util.StringListGUI;
|
import world.bentobox.challenges.panel.util.StringListGUI;
|
||||||
|
|
||||||
|
|
||||||
@ -371,8 +373,24 @@ public class EditChallengeGUI extends CommonGUI
|
|||||||
description = Collections.emptyList();
|
description = Collections.emptyList();
|
||||||
icon = this.challenge.getIcon();
|
icon = this.challenge.getIcon();
|
||||||
clickHandler = (panel, user, clickType, slot) -> {
|
clickHandler = (panel, user, clickType, slot) -> {
|
||||||
// TODO: how to change icon.
|
new AnvilGUI(this.addon.getPlugin(),
|
||||||
|
this.user.getPlayer(),
|
||||||
|
this.challenge.getIcon().getType().name(),
|
||||||
|
(player, reply) -> {
|
||||||
|
ItemStack newIcon = ItemParser.parse(reply);
|
||||||
|
|
||||||
|
if (newIcon != null)
|
||||||
|
{
|
||||||
|
this.challenge.setIcon(newIcon);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.user.sendMessage("challenges.errors.wrong-icon", "[value]", reply);
|
||||||
|
}
|
||||||
|
|
||||||
this.build();
|
this.build();
|
||||||
|
return reply;
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@ -436,8 +454,15 @@ public class EditChallengeGUI extends CommonGUI
|
|||||||
description = values;
|
description = values;
|
||||||
icon = new ItemStack(Material.DROPPER);
|
icon = new ItemStack(Material.DROPPER);
|
||||||
clickHandler = (panel, user, clickType, slot) -> {
|
clickHandler = (panel, user, clickType, slot) -> {
|
||||||
// TODO: Create Enviroment Change GUI
|
new SelectEnvironmentGUI(this.user, this.challenge.getEnvironment(), (status, value) -> {
|
||||||
|
if (status)
|
||||||
|
{
|
||||||
|
this.challenge.setEnvironment(value);
|
||||||
|
}
|
||||||
|
|
||||||
this.build();
|
this.build();
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
glow = false;
|
glow = false;
|
||||||
@ -472,8 +497,14 @@ public class EditChallengeGUI extends CommonGUI
|
|||||||
description = Collections.emptyList();
|
description = Collections.emptyList();
|
||||||
icon = new ItemStack(Material.DROPPER);
|
icon = new ItemStack(Material.DROPPER);
|
||||||
clickHandler = (panel, user, clickType, slot) -> {
|
clickHandler = (panel, user, clickType, slot) -> {
|
||||||
// TODO: Implement AnvilGUI.
|
new AnvilGUI(this.addon.getPlugin(),
|
||||||
|
this.user.getPlayer(),
|
||||||
|
this.challenge.getFriendlyName(),
|
||||||
|
(player, reply) -> {
|
||||||
|
this.challenge.setFriendlyName(reply);
|
||||||
this.build();
|
this.build();
|
||||||
|
return reply;
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@ -782,7 +813,14 @@ public class EditChallengeGUI extends CommonGUI
|
|||||||
description = Collections.singletonList(this.challenge.getRewardText());
|
description = Collections.singletonList(this.challenge.getRewardText());
|
||||||
icon = new ItemStack(Material.WRITTEN_BOOK);
|
icon = new ItemStack(Material.WRITTEN_BOOK);
|
||||||
clickHandler = (panel, user, clickType, slot) -> {
|
clickHandler = (panel, user, clickType, slot) -> {
|
||||||
// TODO: Implement AnvilGUI
|
new AnvilGUI(this.addon.getPlugin(),
|
||||||
|
this.user.getPlayer(),
|
||||||
|
this.challenge.getRewardText(),
|
||||||
|
(player, reply) -> {
|
||||||
|
this.challenge.setRewardText(reply);
|
||||||
|
this.build();
|
||||||
|
return reply;
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@ -936,8 +974,14 @@ public class EditChallengeGUI extends CommonGUI
|
|||||||
description = Collections.singletonList(this.challenge.getRepeatRewardText());
|
description = Collections.singletonList(this.challenge.getRepeatRewardText());
|
||||||
icon = new ItemStack(Material.WRITTEN_BOOK);
|
icon = new ItemStack(Material.WRITTEN_BOOK);
|
||||||
clickHandler = (panel, user, clickType, slot) -> {
|
clickHandler = (panel, user, clickType, slot) -> {
|
||||||
// TODO: Implement AnvilGUI
|
new AnvilGUI(this.addon.getPlugin(),
|
||||||
|
this.user.getPlayer(),
|
||||||
|
this.challenge.getRepeatRewardText(),
|
||||||
|
(player, reply) -> {
|
||||||
|
this.challenge.setRepeatRewardText(reply);
|
||||||
|
this.build();
|
||||||
|
return reply;
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user