1.0.0-SNAPSHOT-U146

+ Continued working on the boss spray menus
This commit is contained in:
Charles 2018-12-29 04:07:04 +08:00
parent 28d036cf97
commit fbb2250117
5 changed files with 96 additions and 3 deletions

3
TODO
View File

@ -1,4 +1,3 @@
01:00 -> Add the DropTable Rewards Editing GUI (1hr)
01:00 -> Spray - Has a button for Rewards List (with chances), button for RandomSpray, button for MaxDistance, button for MaxDrops (1hr)
01:00 -> Drop - Has a button for Rewards List (with chances), button for RandomDrops, button for MaxDrops (1hr)
01:00 -> Give - Is a list panel with the positions and a button for adding a new position (1hr)
@ -21,4 +20,4 @@
01:00 -> Add a new branch for the plugin and add support for Legacy version
-----------
21:15 hrs
20:15 hrs

View File

@ -2193,3 +2193,50 @@ SprayNewRewardEditMenu:
lore:
- '&7Click this button to go back to'
- '&7the drop table reward list menu.'
SprayRewardMainEditMenu:
name: '&b&l{name} DropTable'
slots: 9
Settings:
backButton: true
emptySpaceFiller: true
EmptySpaceFiller:
type: WHITE_STAINED_GLASS_PANE
name: '&7'
Buttons:
backButton: 9
Items:
'3':
type: GUNPOWDER
name: '&e&lSelected ItemStack'
lore:
- '&bCurrently: &f{itemStack}'
- '&7This is the selected itemStack for this'
- '&7reward section.'
Button: Selected
'4':
type: EMERALD
name: '&e&lChance'
lore:
- '&bCurrently: &f{chance}'
- '&7Click here to modify the chance of this'
- '&7reward '
- '&7'
- '&bLeft Click &8» &f+1%'
- '&bShift Left-Click &8» &f+0.1%'
- '&7'
- '&bRight Click &8» &f-1%'
- '&bShift Right-Click &8» &f-0.1%'
Button: Chance
'5':
type: BARRIER
name: '&e&lClick here to remove'
lore:
- '&7Click here to remove this rewards section.'
- '&7You can always re-create this section if'
- '&7was a mistake.'
Button: Remove
'9':
type: REDSTONE
name: '&e&lGo Back'
lore:
- '&7Click here to go back.'

View File

@ -1,13 +1,23 @@
package com.songoda.epicbosses.panel.droptables.types.spray;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.api.BossAPI;
import com.songoda.epicbosses.droptable.DropTable;
import com.songoda.epicbosses.droptable.elements.SprayTableElement;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.managers.files.DropTableFileManager;
import com.songoda.epicbosses.utils.Message;
import com.songoda.epicbosses.utils.NumberUtils;
import com.songoda.epicbosses.utils.panel.Panel;
import com.songoda.epicbosses.utils.panel.base.ClickAction;
import com.songoda.epicbosses.utils.panel.base.handlers.SubSubVariablePanelHandler;
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
import com.songoda.epicbosses.utils.panel.builder.PanelBuilderCounter;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
/**
* @author Charles Cullen
* @version 1.0.0
@ -15,17 +25,53 @@ import org.bukkit.entity.Player;
*/
public class SprayRewardMainEditorPanel extends SubSubVariablePanelHandler<DropTable, SprayTableElement, String> {
private DropTableFileManager dropTableFileManager;
public SprayRewardMainEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
super(bossPanelManager, panelBuilder);
this.dropTableFileManager = plugin.getDropTableFileManager();
}
@Override
public void openFor(Player player, DropTable dropTable, SprayTableElement sprayTableElement, String string) {
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
Map<String, String> replaceMap = new HashMap<>();
Double chance = sprayTableElement.getSprayRewards().get(string);
if(chance == null) chance = 50.0;
replaceMap.put("{chance}", NumberUtils.get().formatDouble(chance));
replaceMap.put("{itemStack}", string);
panelBuilder.addReplaceData(replaceMap);
PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
Panel panel = panelBuilder.getPanel()
.setParentPanelHandler(this.bossPanelManager.getSprayRewardListEditMenu(), dropTable, sprayTableElement);
panelBuilderCounter.getSlotsWith("Selected").forEach(slot -> {});
panelBuilderCounter.getSlotsWith("Chance").forEach(slot -> {});
panelBuilderCounter.getSlotsWith("Remove").forEach(slot -> panel.setOnClick(slot, getRemoveAction(dropTable, sprayTableElement, string)));
panel.openFor(player);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
}
private ClickAction getRemoveAction(DropTable dropTable, SprayTableElement sprayTableElement, String name) {
return event -> {
Map<String, Double> current = sprayTableElement.getSprayRewards();
current.remove(name);
sprayTableElement.setSprayRewards(current);
dropTable.setRewards(BossAPI.convertObjectToJsonObject(sprayTableElement));
this.dropTableFileManager.save();
Message.Boss_DropTable_SprayRewardRemoved.msg(event.getWhoClicked());
this.bossPanelManager.getSprayRewardListEditMenu().openFor((Player) event.getWhoClicked(), dropTable, sprayTableElement);
};
}
}

View File

@ -39,6 +39,7 @@ public enum Message {
Boss_DropTable_SetMaxDistance("&b&lEpicBosses &8» &7You have {0} the max distance for the drop table to &f{1}&7."),
Boss_DropTable_SetRandomDrops("&b&lEpicBosses &8» &7You have set the random drops mode for the drop table to &f{0}&7."),
Boss_DropTable_SprayAddedNewReward("&b&lEpicBosses &8» &7You have added a new reward to the drop table &f{0}&7. Now opening the editing panel for the new reward."),
Boss_DropTable_SprayRewardRemoved("&b&lEpicBosses &8» &7You have removed the reward section from the spray drop table."),
Boss_Edit_NoPermission("&c&l(!) &cYou do not have access to this command."),
Boss_Edit_ItemStackHolderNull("&c&l(!) &cThe itemstack name that is provided for the spawn item doesn't exist or wasn't found."),

View File

@ -20,7 +20,7 @@
<properties>
<!--<plugin.version>maven-version-number-SNAPSHOT-U90</plugin.version>-->
<plugin.version>1.0.0-U145</plugin.version>
<plugin.version>1.0.0-U146</plugin.version>
<plugin.name>EpicBosses</plugin.name>
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
<plugin.author>AMinecraftDev</plugin.author>