classpublicPriority 3
ShopElement
com.hypixel.hytale.builtin.adventure.shop.ShopElement
extends ChoiceElement
2
Methods
2
Public Methods
2
Fields
1
Constructors
Constants
BuilderCodec<ShopElement>CODEC= BuilderCodec.builder(ShopElement.class, ShopElement::new, ChoiceElement.BASE_CODEC)
.append...
Constructors
public
ShopElement()Methods
Public Methods (2)
public
void addButton(UICommandBuilder commandBuilder, UIEventBuilder eventBuilder, String selector, PlayerRef playerRef)@Override
public
boolean canFulfillRequirements(Store<EntityStore> store, Ref<EntityStore> ref, PlayerRef playerRef)@Override
Fields
Protected Fields (2)
protected
int costprotected
String iconPathInheritance
Parent
Current
Interface
Child
Use mouse wheel to zoom, drag to pan. Click nodes to navigate.
Related Classes
Source Code
package com.hypixel.hytale.builtin.adventure.shop;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.codec.validation.Validators;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.server.core.entity.entities.player.pages.choices.ChoiceElement;
import com.hypixel.hytale.server.core.ui.LocalizableString;
import com.hypixel.hytale.server.core.ui.builder.UICommandBuilder;
import com.hypixel.hytale.server.core.ui.builder.UIEventBuilder;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import javax.annotation.Nonnull;
public class ShopElement extends ChoiceElement {
public static final BuilderCodec<ShopElement> CODEC = BuilderCodec.builder(ShopElement.class, ShopElement::new, ChoiceElement.BASE_CODEC)
.append(new KeyedCodec<>("Cost", Codec.INTEGER), (shopElement, integer) -> shopElement.cost = integer, shopElement -> shopElement.cost)
.addValidator(Validators.greaterThanOrEqual(0))
.add()
.append(new KeyedCodec<>("Icon", Codec.STRING), (shopElement, s) -> shopElement.iconPath = s, shopElement -> shopElement.iconPath)
.add()
.build();
protected int cost;
protected String iconPath;
public ShopElement() {
}
@Override
public void addButton(@Nonnull UICommandBuilder commandBuilder, UIEventBuilder eventBuilder, String selector, PlayerRef playerRef) {
commandBuilder.append("#ElementList", "Pages/ShopElementButton.ui");
commandBuilder.set(selector + " #Icon.Background", this.iconPath);
commandBuilder.setObject(selector + " #Name.Text", LocalizableString.fromMessageId(this.displayNameKey));
commandBuilder.setObject(selector + " #Description.Text", LocalizableString.fromMessageId(this.descriptionKey));
commandBuilder.set(selector + " #Cost.Text", this.cost + "");
}
@Override
public boolean canFulfillRequirements(@Nonnull Store<EntityStore> store, @Nonnull Ref<EntityStore> ref, @Nonnull PlayerRef playerRef) {
return super.canFulfillRequirements(store, ref, playerRef);
}
}