Untitled
unknown
java
a year ago
1.5 kB
10
Indexable
package com.trexmine.bedwars.database.content;
import com.trexmine.bedwars.constant.holder.HotbarItemHolder;
import lombok.Getter;
@Getter
public final class HotBarData {
private final int[] base = new int[9];
private final int[] changes = new int[9];
private boolean modified, temporary;
public HotBarData defaults() {
for (int i = 0; i < HotbarItemHolder.DEFAULTS.size(); i++) {
register(i, HotbarItemHolder.DEFAULTS.get(i));
}
return this;
}
public HotBarData setDefaults() {
for (int i = 0; i < HotbarItemHolder.DEFAULTS.size(); i++) {
set(i, HotbarItemHolder.DEFAULTS.get(i));
}
return this;
}
public HotBarData temporary() {
temporary = true;
return this;
}
public void register(int slot, int id) {
base[slot] = id;
changes[slot] = id;
}
public int get(int slot) {
return changes[slot];
}
public void set(int slot, HotbarItemHolder value) {
set(slot, value.ordinal());
}
public void set(int slot, int id) {
if (changes[slot] != id) {
modified = true;
changes[slot] = id;
}
}
public HotBarData applyChanges(HotBarData data) {
return applyChanges(data.getChanges());
}
public HotBarData applyChanges(int[] newChanges) {
for (int i = 0; i < newChanges.length; i++) {
set(i, newChanges[i]);
}
return this;
}
}Editor is loading...
Leave a Comment