1.0.0-SNAPSHOT-U147

+ Completed the SprayEditorPanel's
This commit is contained in:
Charles 2018-12-29 04:23:50 +08:00
parent fbb2250117
commit e154cd25cf
5 changed files with 48 additions and 7 deletions

1
TODO
View File

@ -1,4 +1,3 @@
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)
00:30 -> Is a list panel of reward sections, button to add a new section

View File

@ -2212,7 +2212,6 @@ SprayRewardMainEditMenu:
- '&bCurrently: &f{itemStack}'
- '&7This is the selected itemStack for this'
- '&7reward section.'
Button: Selected
'4':
type: EMERALD
name: '&e&lChance'

View File

@ -6,6 +6,7 @@ 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.skills.Skill;
import com.songoda.epicbosses.utils.Message;
import com.songoda.epicbosses.utils.NumberUtils;
import com.songoda.epicbosses.utils.panel.Panel;
@ -14,6 +15,7 @@ import com.songoda.epicbosses.utils.panel.base.handlers.SubSubVariablePanelHandl
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
import com.songoda.epicbosses.utils.panel.builder.PanelBuilderCounter;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.HashMap;
import java.util.Map;
@ -49,8 +51,7 @@ public class SprayRewardMainEditorPanel extends SubSubVariablePanelHandler<DropT
Panel panel = panelBuilder.getPanel()
.setParentPanelHandler(this.bossPanelManager.getSprayRewardListEditMenu(), dropTable, sprayTableElement);
panelBuilderCounter.getSlotsWith("Selected").forEach(slot -> {});
panelBuilderCounter.getSlotsWith("Chance").forEach(slot -> {});
panelBuilderCounter.getSlotsWith("Chance").forEach(slot -> panel.setOnClick(slot, getChanceAction(dropTable, sprayTableElement, string)));
panelBuilderCounter.getSlotsWith("Remove").forEach(slot -> panel.setOnClick(slot, getRemoveAction(dropTable, sprayTableElement, string)));
panel.openFor(player);
@ -61,17 +62,58 @@ public class SprayRewardMainEditorPanel extends SubSubVariablePanelHandler<DropT
}
private ClickAction getChanceAction(DropTable dropTable, SprayTableElement sprayTableElement, String name) {
return event -> {
ClickType clickType = event.getClick();
double amountToModifyBy;
if(clickType == ClickType.SHIFT_LEFT) {
amountToModifyBy = 0.1;
} else if(clickType == ClickType.RIGHT) {
amountToModifyBy = -1.0;
} else if(clickType == ClickType.SHIFT_RIGHT) {
amountToModifyBy = -0.1;
} else {
amountToModifyBy = 1.0;
}
String modifyValue = amountToModifyBy > 0? "increased" : "decreased";
Map<String, Double> rewards = sprayTableElement.getSprayRewards();
double currentValue = rewards.getOrDefault(name, 50.0);
double newValue = currentValue + amountToModifyBy;
if(newValue < 0) {
newValue = 0;
}
if(newValue > 100) {
newValue = 100;
}
rewards.put(name, newValue);
sprayTableElement.setSprayRewards(rewards);
save(dropTable, sprayTableElement);
openFor((Player) event.getWhoClicked(), dropTable, sprayTableElement, name);
Message.Boss_DropTable_SprayRewardChance.msg(event.getWhoClicked(), modifyValue, BossAPI.getDropTableName(dropTable), NumberUtils.get().formatDouble(newValue));
};
}
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();
save(dropTable, sprayTableElement);
Message.Boss_DropTable_SprayRewardRemoved.msg(event.getWhoClicked());
this.bossPanelManager.getSprayRewardListEditMenu().openFor((Player) event.getWhoClicked(), dropTable, sprayTableElement);
};
}
private void save(DropTable dropTable, SprayTableElement sprayTableElement) {
dropTable.setRewards(BossAPI.convertObjectToJsonObject(sprayTableElement));
this.dropTableFileManager.save();
}
}

View File

@ -40,6 +40,7 @@ public enum Message {
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_DropTable_SprayRewardChance("&b&lEpicBosses &8» &7You have {0} the chance for the reward section for &f{1}&7 to &f{2}%&7."),
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-U146</plugin.version>
<plugin.version>1.0.0-U147</plugin.version>
<plugin.name>EpicBosses</plugin.name>
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
<plugin.author>AMinecraftDev</plugin.author>