-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathCrate.java
More file actions
622 lines (527 loc) · 24.9 KB
/
Crate.java
File metadata and controls
622 lines (527 loc) · 24.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
package com.codehusky.huskycrates.crate.virtual;
import com.codehusky.huskycrates.HuskyCrates;
import com.codehusky.huskycrates.crate.virtual.effects.Effect;
import com.codehusky.huskycrates.crate.virtual.effects.elements.Particle;
import com.codehusky.huskycrates.crate.virtual.views.SimpleView;
import com.codehusky.huskycrates.crate.virtual.views.SpinnerView;
import com.codehusky.huskycrates.crate.virtual.views.ViewConfig;
import com.codehusky.huskycrates.exception.*;
import com.codehusky.huskyui.StateContainer;
import com.codehusky.huskyui.states.Page;
import com.codehusky.huskyui.states.element.Element;
import com.flowpowered.math.vector.Vector3d;
import com.google.common.collect.Lists;
import ninja.leaping.configurate.ConfigurationNode;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.block.BlockType;
import org.spongepowered.api.data.DataQuery;
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.effect.particle.ParticleEffect;
import org.spongepowered.api.effect.particle.ParticleTypes;
import org.spongepowered.api.effect.sound.SoundTypes;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;
import org.spongepowered.api.text.format.TextStyles;
import org.spongepowered.api.text.serializer.TextSerializers;
import org.spongepowered.api.world.Location;
import javax.annotation.Nullable;
import java.math.BigDecimal;
import java.util.*;
public class Crate {
private String id;
private String name;
private String previewTextOccurrence;
private String previewTextRewardCount;
private Hologram hologram;
private Effect idleEffect;
private Effect rejectEffect;
private Effect winEffect;
private Effect openEffect;
private List<Slot> slots;
private int slotChanceMax = 0;
private Boolean scrambleSlots;
private Boolean free;
private boolean previewable;
private Boolean previewShowsRewardCount;
private long cooldownSeconds;
//TODO unused variable
private BlockType defaultBlock;
private Boolean useLocalKey;
private Key localKey;
private HashMap<String, Integer> acceptedKeys = new HashMap<>();
private ViewType viewType;
private ViewConfig viewConfig;
enum ViewType{
SPINNER, // User watches as their desired reward is selected.
ROULETTE, // User gets to pick when the reward they want is selected.
INSTANT, // Basically just delivers a reward.
SIMPLE // Delivers a reward with a slight delay.
}
private Messages messages;
private boolean injection;
public Crate(ConfigurationNode node){
if(!node.hasMapChildren()){
throw new ConfigParseError("Invalid data in crates.conf. Please remove it.",node.getPath());
}
slots = new ArrayList<>();
this.id = node.getKey().toString();
this.name = node.getNode("name").getString();
this.useLocalKey = node.getNode("useLocalKey").getBoolean(false);
this.injection = node.getNode("waitForInjection").getBoolean(false);
ConfigurationNode aKeyNode = node.getNode("acceptedKeys");
if(!aKeyNode.isVirtual()) {
if (aKeyNode.hasListChildren()) {
for(ConfigurationNode keynode : aKeyNode.getChildrenList()){
if(HuskyCrates.registry.isKey(keynode.getString())) {
acceptedKeys.put(keynode.getString(), 1);
}else{
throw new ConfigParseError("Invalid key id: " + keynode.getString(),keynode.getPath());
}
}
} else if (aKeyNode.hasMapChildren()) {
for(Object key : aKeyNode.getChildrenMap().keySet()){
if(HuskyCrates.registry.isKey(key.toString())) {
acceptedKeys.put(key.toString(), aKeyNode.getNode(key).getInt(1));
}else{
throw new ConfigParseError("Invalid key id: " + key.toString(),aKeyNode.getNode(key).getPath());
}
}
} else {
throw new ConfigParseError("Invalid key format specified. Odd.",aKeyNode.getPath());
}
}
this.free = node.getNode("free").getBoolean(false);
if(this.useLocalKey){
boolean localKeyLaunchesCrate = node.getNode("localKeyLaunchesCrate").getBoolean(false);
if(!node.getNode("localKey").isVirtual()){
this.localKey = new Key("LOCALKEY_" + this.id, new Item(node.getNode("localKey")),localKeyLaunchesCrate);
}else{
this.localKey = new Key("LOCALKEY_" + this.id, new Item("&8" + this.name + " Key", ItemTypes.NETHER_STAR, null, 1, null, null, null, null, null, null, null, null, null, null, null),localKeyLaunchesCrate);
}
}else if(aKeyNode.isVirtual() && !this.free){
throw new ConfigParseError("Non-free crate has no accepted keys!",node.getPath());
}
if(node.getNode("slots").isVirtual()){
if(!this.injection) {
throw new ConfigParseError("Crates must have associated slots!", node.getNode("slots").getPath());
}else{
HuskyCrates.instance.logger.warn("Crate with id of " + this.id + " is waiting for injection.");
}
}else{
for(ConfigurationNode slot : node.getNode("slots").getChildrenList()){
Slot thisSlot = new Slot(slot,this);
slotChanceMax += thisSlot.getChance();
slots.add(thisSlot);
}
if(slots.size() == 0){
throw new ConfigParseError("Crates must have associated slots!", node.getNode("slots").getPath());
}
}
messages = new Messages(node.getNode("messages"),this.id, HuskyCrates.crateMessages);
try {
this.viewType = ViewType.valueOf(node.getNode("viewType").getString().toUpperCase());
switch(this.viewType){
case SPINNER:
viewConfig = new SpinnerView.Config(node.getNode("viewConfig"));
break;
default:
viewConfig = new ViewConfig(node.getNode("viewConfig"));
break;
}
}catch (Exception e){
throw new ConfigParseError("Invalid view type!", node.getNode("viewType").getPath());
}
this.cooldownSeconds = node.getNode("cooldownSeconds").getLong(0);
this.scrambleSlots = node.getNode("scrambleSlots").getBoolean(false);
ConfigurationNode eNode = node.getNode("effects");
if(!eNode.getNode("idle").isVirtual()){
idleEffect = new Effect(eNode.getNode("idle"));
if(idleEffect.isDisabled()) idleEffect = null;
}
if(!eNode.getNode("reject").isVirtual()){
rejectEffect = new Effect(eNode.getNode("reject"));
if(rejectEffect.isDisabled()) rejectEffect = null;
}else{
/*
player.spawnParticles(,
event.getTargetBlock().getPosition().clone().toDouble().add(0.5,1.3,0.5));
*/
rejectEffect = new Effect(false,1,false,false,true, new ArrayList<>(Collections.singletonList(new Particle(ParticleEffect.builder().type(ParticleTypes.SMOKE).quantity(20).offset(new Vector3d(0.1, 0.3, 0.1)).build(), new Vector3d(0.5, 1.3, 0.5)))));
}
if(!eNode.getNode("win").isVirtual()){
winEffect = new Effect(eNode.getNode("win"));
if(winEffect.isDisabled()) winEffect = null;
}
if(!eNode.getNode("open").isVirtual()){
openEffect = new Effect(eNode.getNode("open"));
if(openEffect.isDisabled()) openEffect = null;
}
if(!node.getNode("hologram").isVirtual()){
hologram = new Hologram(node.getNode("hologram"));
}
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,String previewTextOccurrence,String previewTextRewardCount){
this.id = id;
this.name = name;
this.hologram = hologram;
this.idleEffect = idleEffect;
this.rejectEffect = rejectEffect;
this.winEffect = winEffect;
this.openEffect = openEffect;
this.slots = slots;
this.slotChanceMax = 0;
for(Slot slot : slots){
slotChanceMax += slot.getChance();
}
if(slots.size() == 0){
throw new ConfigParseError("Crates must have associated slots!", Lists.newArrayList("Injected!!!").toArray());
}
this.scrambleSlots = scrambleSlots;
this.free = free;
this.previewable = previewable;
this.previewShowsRewardCount = previewRewardCount;
this.cooldownSeconds = cooldownSeconds;
this.useLocalKey = useLocalKey;
this.localKey = localKey;
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,previewTextOccurrence,previewTextRewardCount);
}
public boolean isScrambled() {
return this.scrambleSlots;
}
public boolean isInjectable() {
return this.injection;
}
public void injectSlot(Slot slot) {
slots.add(slot);
slotChanceMax += slot.getChance();
}
public void postInjectionChecks() {
if(this.injection){
if(this.slots.size() == 0){
throw new InjectionMissedError("Injectable crates with no slots must be injected!");
}else{
HuskyCrates.instance.logger.info("Injection successful on " + this.id);
}
}
}
public String getId() {
return id;
}
public int selectSlot() {
int chanceCuml = 0;
int selection = new Random().nextInt(slotChanceMax+1);
for(int i = 0; i < slots.size(); i++){
chanceCuml += slots.get(i).getChance();
if(selection <= chanceCuml){
return i;
}
}
throw new SlotSelectionError("Slot could not be selected for crate \"" + this.id + "\". chanceCuml=" + chanceCuml + "; selection=" + selection);
}
public boolean testKey(ItemStack stack){
if(free) return true;
if(useLocalKey){
if(localKey.testKey(stack)) return true;
}
for(Map.Entry<String, Integer> entry : acceptedKeys.entrySet()){
Key potential = HuskyCrates.registry.getKey(entry.getKey());
if(potential.testKey(stack)) return true;
}
return false;
}
public boolean testVirtualKey(UUID playerUUID){
for(Map.Entry<String, Integer> entry : acceptedKeys.entrySet()){
if(HuskyCrates.registry.getVirtualKeyBalance(playerUUID,entry.getKey()) >= entry.getValue()){
return true;
}
}
return useLocalKey && HuskyCrates.registry.getVirtualKeyBalance(playerUUID,getLocalKey().getId()) >= 1;
}
public void consumeVirtualKeys(UUID playerUUID){
if(testVirtualKey(playerUUID)){
for(Map.Entry<String, Integer> entry : acceptedKeys.entrySet()){
String keyID = entry.getKey();
int consumed = entry.getValue();
if(HuskyCrates.registry.getVirtualKeyBalance(playerUUID,keyID) >= consumed){
HuskyCrates.registry.removeVirtualKeys(playerUUID,keyID,consumed);
if(Sponge.getServer().getPlayer(playerUUID).isPresent()) {
Player player = Sponge.getServer().getPlayer(playerUUID).get();
player.sendMessage(
messages.getVirtualKeyConsumed(
HuskyCrates.registry.getKey(keyID).getName(),
consumed,
HuskyCrates.registry.getVirtualKeyBalance(playerUUID, keyID)
)
);
}
return;
}
}
if(useLocalKey && HuskyCrates.registry.getVirtualKeyBalance(playerUUID,getLocalKey().getId()) >= 1){
HuskyCrates.registry.removeVirtualKeys(playerUUID,getLocalKey().getId(),1);
if(Sponge.getServer().getPlayer(playerUUID).isPresent()) {
Player player = Sponge.getServer().getPlayer(playerUUID).get();
player.sendMessage(
messages.getVirtualKeyConsumed(
getLocalKey().getName(),
1,
HuskyCrates.registry.getVirtualKeyBalance(playerUUID, getLocalKey().getId())
)
);
}
return;
}
throw new VirtualKeyStarvedError("No virtual key could be found to consume in exchange for a crate use. Report this to a developer.");
}
}
public boolean hasLocalKey(){
return useLocalKey;
}
public Key getLocalKey(){
return localKey;
}
public boolean isPreviewable() {
return previewable;
}
public boolean previewShowsRewards() {return previewShowsRewardCount; }
public ItemStack getCratePlacementBlock(ItemType itemType, int damage) {
ItemStack stack = ItemStack.builder()
.itemType(itemType)
.add(Keys.DISPLAY_NAME, Text.of(TextSerializers.FORMATTING_CODE.deserialize((this.name != null)?this.name:this.id)," Placement Block"))
.build();
return ItemStack.builder()
.fromContainer(stack.toContainer().set(DataQuery.of("UnsafeData","HCCRATEID"),this.id).set(DataQuery.of("UnsafeDamage"),damage))
.build();
}
public ItemStack getWandItem() {
ItemStack stack = ItemStack.builder()
.itemType(ItemTypes.BLAZE_ROD)
.add(Keys.DISPLAY_NAME, Text.of(TextSerializers.FORMATTING_CODE.deserialize((this.name != null)?this.name:this.id)," Wand"))
.add(Keys.ITEM_LORE, Arrays.asList(Text.of("Right click to set entity"),Text.of("or crate. You can also remove"),Text.of("crates from entities or crates with this.")))
.build();
return ItemStack.builder()
.fromContainer(stack.toContainer().set(DataQuery.of("UnsafeData","HCCRATEID"),this.id))
.build();
}
public ItemStack getCratePlacementBlock(int damage) {
return this.getCratePlacementBlock(ItemTypes.CHEST,damage);
}
public static String extractCrateID(ItemStack stack){
try {
return stack.toContainer().get(DataQuery.of("UnsafeData", "HCCRATEID")).get().toString();
}catch (Exception e){
return null;
}
}
public String getName() {
return (this.name != null)?this.name:this.id;
}
public ViewType getViewType() {
return viewType;
}
public ViewConfig getViewConfig() {
return viewConfig;
}
public List<Slot> getSlots() {
return slots;
}
public int getSlotCount() {
return slots.size();
}
public Slot getSlot(int slot){
return slots.get(slot);
}
public Effect getIdleEffect() {
return idleEffect;
}
public Effect getOpenEffect() {
return openEffect;
}
public Effect getRejectEffect() {
return rejectEffect;
}
public Effect getWinEffect() {
return winEffect;
}
public Hologram getHologram() {
return hologram;
}
public HashMap<String, Integer> getAcceptedKeys() {
return acceptedKeys;
}
public Boolean isFree() {
return free;
}
public long getCooldownSeconds() {
return cooldownSeconds;
}
public Messages getMessages() {
return messages;
}
public long getCooldownSeconds(Player player){
Long time = HuskyCrates.registry.getLastUse(this.id, player.getUniqueId());
if( time == null ){
return 0L;
}
return 1 + (long) Math.ceil(((time + (cooldownSeconds*1000)) - System.currentTimeMillis()) / 1000);
}
public boolean isTimedOut(UUID playerUUID) {
Long time = HuskyCrates.registry.getLastUse(id,playerUUID);
return time != null && (time + (cooldownSeconds*1000)) - System.currentTimeMillis() >= 0;
}
public void launchView(Crate ucrate, Player player, Location loc){
HuskyCrates.registry.updateLastUse(id,player.getUniqueId());
switch(viewType){
case SPINNER:
new SpinnerView(ucrate,player,loc);
break;
case INSTANT:
player.playSound(SoundTypes.ENTITY_EXPERIENCE_ORB_PICKUP, player.getPosition(), 1.0);
this.getSlot(selectSlot()).rewardPlayer(player,loc);
break;
case SIMPLE:
new SimpleView(ucrate,player,loc);
break;
default:
player.sendMessage(Text.of(TextColors.RED,"The view type \"" + viewType.name() + "\" is currently not supported."));
break;
}
}
public void launchPreview(Player player){
StateContainer previewContainer = new StateContainer();
Page.PageBuilder builder = Page.builder();
builder.setTitle(Text.of(TextSerializers.FORMATTING_CODE.deserialize(getName())));
builder.setAutoPaging(true);
for(int j = 0; j < slots.size(); j++) {
ItemStack orig = slots.get(j).getDisplayItem().toItemStack();
List<Text> oldLore = orig.getOrElse(Keys.ITEM_LORE,new ArrayList<>());
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(TextSerializers.FORMATTING_CODE.deserialize("&r&7"+previewTextRewardCount+ slots.get(j).getRewards().size()));
}
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");
previewContainer.setInitialState(built);
previewContainer.launchFor(player);
}
public static class Messages {
private String rejectionNeedKey;
private String rejectionCooldown;
private String virtualKeyConsumed;
private String crateID;
public enum Type {
RejectionNeedKey,
RejectionCooldown
}
public String getRejectionCooldown() {
return rejectionCooldown;
}
public String getRejectionNeedKey() {
return rejectionNeedKey;
}
public String getVirtualKeyConsumed() {
return virtualKeyConsumed;
}
public Messages(ConfigurationNode node, @Nullable String crateID, @Nullable Messages defaultMessages){
this.rejectionNeedKey = node.getNode("rejectionNeedKey")
.getString((defaultMessages != null)?defaultMessages.getRejectionNeedKey():"&cYou need a {key.0.name} to use this crate.");
this.rejectionCooldown = node.getNode("rejectionCooldown")
.getString((defaultMessages != null)?defaultMessages.getRejectionCooldown():"&aCalm down! &7You need to wait {cooldown.remaining} second{cooldown.remaining.plural} before you can use another {crate.name}&r&7!");
this.virtualKeyConsumed = node.getNode("virtualKeyConsumed")
.getString((defaultMessages != null)?defaultMessages.getVirtualKeyConsumed():"&eYou just used {amount} {key}{amount.plural}&r&e from your key balance. You have {amountRemaining} {key}&r&e{amountRemaining.plural} left.");
this.crateID = crateID;
}
public Messages(ConfigurationNode node,@Nullable String crateID){
this(node, crateID, null);
}
public Messages(String rnk, String rc, String crateID){
this.rejectionCooldown = rc;
this.rejectionNeedKey = rnk;
this.crateID = crateID;
}
public Messages clone() {
return new Messages(this.rejectionNeedKey,this.rejectionCooldown,this.crateID);
}
public void setCrateID(String crateID) {
this.crateID = crateID;
}
public Text format(Type messageType, Player player){
if(!HuskyCrates.registry.isCrate(crateID)){
throw new NoMessageContextError("Invalid crate id: " + crateID);
}
return format(messageType, HuskyCrates.registry.getCrate(crateID), player, null);
}
public Text getVirtualKeyConsumed(String keyName, Integer amountConsumed, Integer amountRemaining){
return TextSerializers.FORMATTING_CODE.deserialize(
this.virtualKeyConsumed
.replace("{amount}",amountConsumed.toString())
.replace("{amount.plural}",(amountConsumed != 1)?"s":"")
.replace("{amountRemaining}",amountRemaining.toString())
.replace("{amountRemaining.plural}",(amountRemaining != 1)?"s":"")
.replace("{key}",keyName));
}
public Text format(Type messageType, Crate crate, Player player, Slot slot){
String newMessage;
switch(messageType){
case RejectionNeedKey:
newMessage = rejectionNeedKey;
break;
case RejectionCooldown:
newMessage = rejectionCooldown;
break;
default:
throw new InvalidMessageTypeError("Invalid message type used!");
}
newMessage = newMessage
.replace("{crate.name}", crate.getName())
.replace("{crate.id}", crate.getId());
ArrayList<Key> keys = new ArrayList<>();
if(crate.hasLocalKey()){
keys.add(crate.getLocalKey());
}
for(String keyID : crate.getAcceptedKeys().keySet()) {
keys.add(HuskyCrates.registry.getKey(keyID));
}
int num = 0;
for(Key key : keys) {
Integer amountRequired = (crate.hasLocalKey() && num == 0)?1:crate.getAcceptedKeys().get(key.getId());
newMessage = newMessage
.replace("{key." + num + ".id}",key.getId())
.replace("{key." + num + ".name}",key.getName())
.replace("{key." + num + ".amountRequired}",amountRequired.toString())
.replace("{key." + num + ".amountRequired.plural}",(amountRequired != 0)?"s":"")
.replace("{key." + key.getId() + ".id}",key.getId())
.replace("{key." + key.getId() + ".name}",key.getName())
.replace("{key." + key.getId() + ".amountRequired}",amountRequired.toString())
.replace("{key." + key.getId() + ".amountRequired.plural}",(amountRequired != 0)?"s":"");
num++;
}
newMessage = newMessage
.replace("{cooldown.remaining}","" + crate.getCooldownSeconds(player))
.replace("{cooldown.remaining.plural}",(crate.getCooldownSeconds(player) != 1)?"s":"")
.replace("{cooldown.total}", "" + crate.getCooldownSeconds())
.replace("{cooldown.total.plural}",(crate.getCooldownSeconds() != 1)?"s":"");
return TextSerializers.FORMATTING_CODE.deserialize(newMessage);
}
}
}