Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preview text RewardCount/Occurrence #105

Open
wants to merge 1 commit into
base: rewrite
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/main/java/com/codehusky/huskycrates/crate/virtual/Crate.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
public class Crate {
private String id;
private String name;
private String previewTextOccurrence;
private String previewTextRewardCount;

private Hologram hologram;

Expand Down Expand Up @@ -197,9 +199,11 @@ public Crate(ConfigurationNode node){
}

this.previewable = node.getNode("previewable").getBoolean(false);
this.previewTextOccurrence=node.getNode("previewTextOccurrence").getString("Occurrence: ");
this.previewTextRewardCount=node.getNode("previewTextRewardCount").getString("Rewards: ");
this.previewShowsRewardCount = node.getNode("previewShowsRewardCount").getBoolean(true);
}
public Crate(String id, String name, Hologram hologram, Effect idleEffect, Effect rejectEffect, Effect winEffect, Effect openEffect, List<Slot> slots, boolean scrambleSlots, boolean free, boolean previewable, boolean previewRewardCount, long cooldownSeconds, boolean useLocalKey, Key localKey, HashMap<String, Integer> acceptedKeys, ViewType viewType, ViewConfig viewConfig){
public Crate(String id, String name, Hologram hologram, Effect idleEffect, Effect rejectEffect, Effect winEffect, Effect openEffect, List<Slot> slots, boolean scrambleSlots, boolean free, boolean previewable, boolean previewRewardCount, long cooldownSeconds, boolean useLocalKey, Key localKey, HashMap<String, Integer> acceptedKeys, ViewType viewType, ViewConfig viewConfig,String previewTextOccurrence,String previewTextRewardCount){
this.id = id;
this.name = name;
this.hologram = hologram;
Expand All @@ -225,12 +229,14 @@ public Crate(String id, String name, Hologram hologram, Effect idleEffect, Effec
this.acceptedKeys = acceptedKeys;
this.viewType = viewType;
this.viewConfig = viewConfig;
this.previewTextOccurrence=previewTextOccurrence;
this.previewTextRewardCount=previewTextRewardCount;
}

public Crate getScrambledCrate() {
ArrayList<Slot> newSlots = new ArrayList<>(slots);
Collections.shuffle(newSlots);
return new Crate(id,name,hologram,idleEffect,rejectEffect,winEffect,openEffect,newSlots,scrambleSlots,free,previewable,previewShowsRewardCount,cooldownSeconds,useLocalKey,localKey,acceptedKeys,viewType,viewConfig);
return new Crate(id,name,hologram,idleEffect,rejectEffect,winEffect,openEffect,newSlots,scrambleSlots,free,previewable,previewShowsRewardCount,cooldownSeconds,useLocalKey,localKey,acceptedKeys,viewType,viewConfig,previewTextOccurrence,previewTextRewardCount);
}
public boolean isScrambled() {
return this.scrambleSlots;
Expand Down Expand Up @@ -482,9 +488,9 @@ public void launchPreview(Player player){
double val = ((double)slots.get(j).getChance()/(double)slotChanceMax)*100;
BigDecimal occurance = new BigDecimal(val).setScale(2,BigDecimal.ROUND_HALF_UP);
if (previewShowsRewardCount) {
oldLore.add(Text.of(TextStyles.NONE,TextColors.GRAY,"Rewards: " + slots.get(j).getRewards().size()));
oldLore.add(TextSerializers.FORMATTING_CODE.deserialize("&r&7"+previewTextRewardCount + slots.get(j).getRewards().size()));
}
oldLore.add(Text.of(TextStyles.NONE,TextColors.GRAY,"Occurrence: " + ((val < 0.01)?"< 0.01":occurance.toString()) + "%"));
oldLore.add(TextSerializers.FORMATTING_CODE.deserialize("&r&7"+previewTextOccurrence + ((val < 0.01)?"< 0.01":occurance.toString()) + "%"));
builder.addElement(new Element(ItemStack.builder().from(orig).add(Keys.ITEM_LORE,oldLore).build()));
}
Page built = builder.build("preview");
Expand Down